diff --git a/TODO b/TODO index 8336032a..b4e96a6e 100644 --- a/TODO +++ b/TODO @@ -1,7 +1,5 @@ TODO List -- Implement new white noise -- Check SFX. - Adjust documentation diff --git a/basic/test.bsc b/basic/test.bsc index 5ca78156..382b89d9 100644 --- a/basic/test.bsc +++ b/basic/test.bsc @@ -1,4 +1,4 @@ -noise 0,100,100 +noise 0,300,100 end proc snd(ch,fq,ms,sl,ty,v) diff --git a/firmware/common/include/interface/whitenoise.h b/firmware/common/include/interface/whitenoise.h index b1aa0e4f..2ed844ce 100644 --- a/firmware/common/include/interface/whitenoise.h +++ b/firmware/common/include/interface/whitenoise.h @@ -16,7 +16,7 @@ #define NOISE_SIZE (1024) -static const uint8_t noisepattern[NOISE_SIZE] = { +static const uint8_t noisePattern[NOISE_SIZE] = { 7, 30, 30, 28, 28, 62, 60, 56,120,248,124, 30, 31,143, 7, 7,193,192,224, 241,224,240,227,225,192,224,120,126, 60, 56,224,225,195,195,135,199, 7, 30, 28, 31, 14, 14, 30, 14, 15, 15,195,195,241,225,227,193,227,195,195,252, 60, diff --git a/firmware/common/sources/interface/sndcreator.cpp b/firmware/common/sources/interface/sndcreator.cpp index 0f61e329..d1119845 100644 --- a/firmware/common/sources/interface/sndcreator.cpp +++ b/firmware/common/sources/interface/sndcreator.cpp @@ -21,7 +21,7 @@ struct _ChannelStatus { int state; int soundType; int volume; - bool modulate; + int samplePos; } audio[CHANNEL_COUNT]; // *************************************************************************************** @@ -70,11 +70,8 @@ int16_t SNDGetNextSample(void) { cs->state ^= 0xFF; switch (cs->soundType) { case SOUNDTYPE_NOISE: - if (cs->modulate) { - level += cs->state ? rand() % cs->volume : -(rand() % cs->volume); - } else { - level += rand() % (cs->volume * 2) - cs->volume; - } + level += ((noisePattern[cs->samplePos] - 0x80) * cs->volume / 128); + if (++cs->samplePos == NOISE_SIZE) cs->samplePos = 0; break; default: // Square wave level += cs->state ? cs->volume : -cs->volume;break; @@ -101,11 +98,7 @@ void SNDUpdateSoundChannel(uint8_t channel,SOUND_CHANNEL *c) { audio[channel].adder = SNDGetSampleFrequency() / c->currentFrequency / 2; audio[channel].soundType = c->currentType; audio[channel].volume = c->currentVolume; - audio[channel].modulate = true; - if (c->currentFrequency <= 100) { - audio[channel].modulate = false; - audio[channel].adder = SNDGetSampleFrequency() / 440 / 2; - } + audio[channel].samplePos = 0; } else { audio[channel].volume = 0; }