On Samstag 20 September 2008, korgpolyex800 wrote:
> Wow, now that I look at it in C, it definitely needs improvement.
If it's really implemented like you've commented, that would be so bad
you should have heard as the longest cycle would be 9. Maybe your
assembler uses different mnemonics, but I think RLC should be "rotate
circular", not "rotate through carry". If so, then the C expression
transforms to something more complicated:
m = ((m ? m : -m) << 1) + (m&0x80 ? 44 : 43);
Since you're not using a homogeneous recurrence (by virtue of adding
43) zero is actually not a forbidden state and by excluding zero you
indeed shorten the longest cycle from 128 to 121. A better
recurrence would therefore be:
m += (m&0x80 ? 44 : 43);
or equivalently:
; my pseudo random number generator - used for the LFO randomiser
; returns a random number in A
RANDOMIZE: push h ; save HL
lxi h, M_RANDOM ; point at the previous value
mov a, m ; put the seed value into A
RANDOMIZEA: rlc ; rotate A circular
adi 43 ; add 43 offset
mov m, a ; save in seed
pop h ; load HL
ret ; return with pseudo random in A
The cycles associated with different seed values then are (seed before
the colon, cycle length at the end in brackets):
0:43, 129, 46, 135, 58, 159, 106, 255, 42, 127, 41, 125, 37, 117, 21,
85, 213, 214, 216, 220, 228, 244, 20, 83, 209, 206, 200, 188, 164,
116, 19, 81, 205, 198, 184, 156, 100, 243, 18, 79, 201, 190, 168,
124, 35, 113, 13, 69, 181, 150, 88, 219, 226, 240, 12, 67, 177, 142,
72, 187, 162, 112, 11, 65, 173, 134, 56, 155, 98, 239, 10, 63, 169,
126, 39, 121, 29, 101, 245, 22, 87, 217, 222, 232, 252, 36, 115, 17,
77, 197, 182, 152, 92, 227, 242, 16, 75, 193, 174, 136, 60, 163, 114,
15, 73, 189, 166, 120, 27, 97, 237, 6, 55, 153, 94, 231, 250, 32,
107, 1, 45, 133, 54, 151, 90, 223, 234, 0,
[128]
2:47, 137, 62, 167, 122, 31, 105, 253, 38, 119, 25, 93, 229, 246, 24,
91, 225, 238, 8, 59, 161, 110, 7, 57, 157, 102, 247, 26, 95, 233,
254, 40, 123, 33, 109, 5, 53, 149, 86, 215, 218, 224, 236, 4, 51,
145, 78, 199, 186, 160, 108, 3, 49, 141, 70, 183, 154, 96, 235, 2,
[60]
9:61, 165, 118, 23, 89, 221, 230, 248, 28, 99, 241, 14, 71, 185, 158,
104, 251, 34, 111, 9,
[20]
30:103, 249, 30,
[3]
44:131, 50, 143, 74, 191, 170, 128, 44,
[8]
48:139, 66, 175, 138, 64, 171, 130, 48,
[8]
52:147, 82, 207, 202, 192, 172, 132, 52,
[8]
68:179, 146, 80, 203, 194, 176, 140, 68,
[8]
76:195, 178, 144, 76,
[4]
84:211, 210, 208, 204, 196, 180, 148, 84,
[8]
212:212,
[1]
There is a slight DC bias to the longest sequence and a strong one to
all the others. I think it would be easier to just put a random
table into memory (if you can spare the 256 bytes). That way you
could even make this a general waveform by allowing to load new
tables into memory and/or switch between different ones later on.
Achim.
--
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk]>+
Factory and User Sound Singles for Waldorf Blofeld:
http://Synth.Stromeko.net/Downloads.html#WaldorfSounds