Hi, im trying to emulate the LFSR Noise from the Commodore 64.
This websites have been helpful:
//base:noise_waveform [Codebase64 wiki]
//SID reference
Also read about what is an LFSR and I think I understood.
I came up with this but it does not sound quite right, am I missing something?
It should sound like this: https://www.youtube.com/watch?v=XKBy974e7uk
(~lfsrC64={|seed = #[]|
var decimal, register, numeroBits, xor, waveform, binary;
register = seed;
bitNumber = seed.size;
waveform = (2**bitNumber-1).asInteger.collect{ //max lfsr cycle is 2**bitNumber-1 wide
if (register[0] != register[5], {xor = 1},{xor = 0}); //xor beetween bits 0 and 5
register = register.rotate(1); //rotate to the right
register = register.put(0, xor); //replace the first bit
//8bit waveform only gets bits 2 4 8 11 13 17 20 22
binary = [register[2], register[4], register[8], register[11], register[13], register[17], register[20], register[22]];
decimal = 8.collect{ |i| 2**((8)-i-1) * binary[i]}; //8bit waveform from binary to decimal
decimal = decimal.sum.asInteger;
};
waveform
})
~lfsrC64.value(Array.fill(23, {rrand(0,1)}))
b = Buffer.sendCollection(s, ~lfsrC64.value(Array.fill(23, {rrand(0,1)}))/255, 1);
(
SynthDef(\lfsrC64, { |bufnum, amp = 0.1, freq = 2000|
var phase, sig;
phase = Phasor.ar(0, freq * SampleDur.ir, 0, BufFrames.kr(bufnum));
sig = BufRd.ar(1, bufnum, phase, interpolation: 1);
Out.ar(0, sig*amp !2)
}
).add)
Synth(\lfsrC64, [\freq, 1000])
Please feel free to roast my code, I know is pretty bad. tysm
Edit: also I’m aware of this post but i cannot understand the code: LFSR Noise Generator.
And please ask me anything that is confusing about my code.