Tabula Sonora
0.1.0
A native C++20 implementation of the Roland Sound Canvas VA synth voice
Toggle main menu visibility
Loading...
Searching...
No Matches
engine_noise.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <cstdint>
4
5
namespace
ts
{
6
18
class
EngineNoise
{
19
public
:
21
[[nodiscard]] std::uint16_t
next
() noexcept
22
{
23
auto
step =
static_cast<
std::uint16_t
>
(shift_ >> 1);
24
if
(((shift_ & 0x20) != 0) != ((shift_ & 0x8000) != 0)) {
25
step =
static_cast<
std::uint16_t
>
(step | 0x8000);
26
}
27
shift_ = step;
28
29
const
bool
insert_one = (walk_ & 4) != 0 ? (walk_ & 0x2000) == 0 : (walk_ & 0x200) != 0;
30
walk_ =
static_cast<
std::uint16_t
>
((walk_ << 1) | (insert_one ? 1 : 0));
31
32
return
static_cast<
std::uint16_t
>
(walk_ ^ shift_);
33
}
34
39
[[nodiscard]]
int
next_pan
() noexcept {
return
next
() >> 9; }
40
42
void
reset
() noexcept
43
{
44
shift_ = 0xEFA6;
45
walk_ = 0x9C23;
46
}
47
48
private
:
49
std::uint16_t shift_ = 0xEFA6;
50
std::uint16_t walk_ = 0x9C23;
51
};
52
53
}
// namespace ts
ts::EngineNoise
The engine's shared pseudo-random generator.
Definition
engine_noise.hpp:18
ts::EngineNoise::next
std::uint16_t next() noexcept
Draws the next 16-bit value.
Definition
engine_noise.hpp:21
ts::EngineNoise::next_pan
int next_pan() noexcept
Draws a random pan position, 0 to 127, on the same scale as CC#10.
Definition
engine_noise.hpp:39
ts::EngineNoise::reset
void reset() noexcept
Returns the generator to the engine's reset state.
Definition
engine_noise.hpp:42
ts
Definition
control_decode.hpp:7
include
tabulasonora
engine_noise.hpp
Generated by
1.17.0