mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2024-12-13 03:34:35 +00:00
Compact with unique, best Noise Gererator option.
This commit is contained in:
parent
d77102426a
commit
5a336d5e71
@ -55,7 +55,7 @@ private:
|
||||
"Saw up signal ",
|
||||
"Saw down signal",
|
||||
"Square signal ",
|
||||
"White Noise " // using 16 bits LFSR register, 16 order polynomial feedback.
|
||||
"Noise signal " // using 16 bits LFSR register, 16 order polynomial feedback.
|
||||
};
|
||||
|
||||
bool auto_update { false };
|
||||
|
@ -61,36 +61,29 @@ void SigGenProcessor::execute(const buffer_c8_t& buffer) {
|
||||
} else if (tone_shape == 5) {
|
||||
// Square
|
||||
sample = (((tone_phase & 0xFF000000) >> 24) & 0x80) ? 127 : -128;
|
||||
} else if (tone_shape == 6) { // White Noise generator, pseudo random noise generator, 8 bits linear-feedback shift register (LFSR) algorithm, variant Fibonacci.
|
||||
} else if (tone_shape == 6) {
|
||||
// Noise generator, pseudo random noise generator, 16 bits linear-feedback shift register (LFSR) algorithm, variant Fibonacci.
|
||||
// https://en.wikipedia.org/wiki/Linear-feedback_shift_register
|
||||
// 16 bits LFSR .taps: 16, 15, 13, 4 ;feedback polynomial: x^16 + x^15 + x^13 + x^4 + 1
|
||||
// Periode 65535= 2^n-1, harmonics every < 1Khz , quite continuous .
|
||||
if (counter == 0) {
|
||||
// Periode 65535= 2^n-1, quite continuous .
|
||||
if (counter == 0) { // we slow down the shift register, because the pseudo random noise clock freq was too high for modulator.
|
||||
bit_16 = ((lfsr_16 >> 0) ^ (lfsr_16 >> 1) ^ (lfsr_16 >> 3) ^ (lfsr_16 >> 4) ^ (lfsr_16 >> 12) & 1);
|
||||
lfsr_16 = (lfsr_16 >> 1) | (bit_16 << 15);
|
||||
sample = (lfsr_16 & 0x00FF);
|
||||
counter++;
|
||||
} else { // counter == 1 , no need to shift the register again, just use the top 8 bits.
|
||||
// sample = ((lfsr_16 & 0XFF00) >> 8); // it becomes less continuous the spectrum. Better skip it .
|
||||
counter = 0;
|
||||
sample = (lfsr_16 & 0x00FF); // main pseudo random noise generator.
|
||||
}
|
||||
if (counter == 5) { // after many empiric test, that combination mix of >>4 and >>5, gives a reasonable trade off white noise / good rf power level .
|
||||
sample = ((lfsr_16 & 0b0000111111110000) >> 4); // just changing the spectrum shape .
|
||||
}
|
||||
}
|
||||
|
||||
/* else if (tone_shape == 7) { // 8 bit options, finally not used-
|
||||
bit = ((lfsr >> 2) ^ (lfsr >> 3)) & 1; // taps: 6 5; feedback polynomial: x^6 + x^5 + 1 , Periode 63 = 2^n-1,it generates armonincs n x 20Khz
|
||||
lfsr = (lfsr >> 1) | (bit << 7);
|
||||
sample = lfsr;
|
||||
} else if (tone_shape == 8) { // taps: 7 6; feedback polynomial: x^7 + x^6 + 1 , Periode 127 = 2^n-1,it generates armonincs n x 10Khz
|
||||
bit = ((lfsr >> 1) ^ (lfsr >> 2)) & 1;
|
||||
lfsr = (lfsr >> 1) | (bit << 7);
|
||||
sample = lfsr;
|
||||
} else if (tone_shape == 9) { //taps:8,6,5,4;feedback polynomial: x^8 + x^6 + x^5 + x^4 + 1,Periode 255= 2^n-1, armonics n x 5khz
|
||||
bit = ((lfsr >> 0) ^ (lfsr >> 2) ^ (lfsr >> 3) ^ (lfsr >> 4)) & 1;
|
||||
lfsr = (lfsr >> 1) | (bit << 7);
|
||||
sample = lfsr; } */
|
||||
if (counter == 10) {
|
||||
sample = ((lfsr_16 & 0b0001111111100000) >> 5); // just changing the spectrum shape .
|
||||
}
|
||||
counter++;
|
||||
if (counter ==15) {
|
||||
counter=0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (tone_shape < 6) {
|
||||
if (tone_shape < 6) { // we are in periodic signals, we need tone phases update.
|
||||
tone_phase += tone_delta;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user