noise
This commit is contained in:
parent
aeeafffc6b
commit
aa94ac20e3
|
@ -2,7 +2,7 @@
|
||||||
// sample rate is 8M / (3 * 64)
|
// sample rate is 8M / (3 * 64)
|
||||||
|
|
||||||
|
|
||||||
enum { WAVE_PULSE, WAVE_SAW, };
|
enum { WAVE_PULSE, WAVE_SAW, WAVE_NOISE };
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t wave;
|
uint8_t wave;
|
||||||
|
@ -43,14 +43,14 @@ static synth_t synth;
|
||||||
void synth_init(void)
|
void synth_init(void)
|
||||||
{
|
{
|
||||||
// some test values
|
// some test values
|
||||||
synth.channels[0].wave = WAVE_PULSE;
|
synth.channels[0].wave = WAVE_PULSE + 10;
|
||||||
synth.channels[0].speed = 1153;
|
synth.channels[0].speed = 1153;
|
||||||
synth.channels[0].pulse_sweep = 0;
|
synth.channels[0].pulse_sweep = 0;
|
||||||
synth.channels[0].pulse_width = 1 << 31;
|
synth.channels[0].pulse_width = 1 << 31;
|
||||||
|
|
||||||
synth.channels[1].wave = WAVE_SAW;
|
synth.channels[1].wave = WAVE_SAW;
|
||||||
|
synth.channels[1].wave = WAVE_NOISE;
|
||||||
synth.channels[1].speed = 1728;
|
synth.channels[1].speed = 1728;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t synth_mix(void)
|
uint16_t synth_mix(void)
|
||||||
|
@ -93,6 +93,11 @@ uint16_t synth_mix(void)
|
||||||
amp = (chan->phase >> 8);
|
amp = (chan->phase >> 8);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case WAVE_NOISE: // shitty noise
|
||||||
|
chan->phase = (chan->phase >> 1) ^ (-(chan->phase & 1) & 0xb400);
|
||||||
|
amp = (chan->phase >> 8);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
amp = 0;
|
amp = 0;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user