For those interested check out wikipedia http://en.wikipedia.org/wiki/Linear_congruential_generator The waveform generation code has to be fast and it has to generate not just random but triangle, sawtooth, sine, square PWM as well. So I chose to pick a recurrence relation that was fast and "sounded" random and it does that "reasonably" well. It is by no means random it just sounds somewhat random. Mike. --- In korgpolyex@yahoogroups.com, ASSI <Stromeko@...> wrote: > > On Samstag 20 September 2008, Atom Smasher wrote: > > assembler?!?! i should have known.... and i've always considered C > > a low level language... > > In C: > > ((m ? m : -m) << 1) + 43; > > Better? :-) > > > despite the verbose comments (is all of the code commented that > > well?) i can't follow it. can you give a brief explanation? > > It is somwthing that looks like a LFSR, but isn't (the feedback is > actually missing). When I find some time I'll simulate to see what > the cycle length is for different seed values. > > > On Thu, 18 Sep 2008, korgpolyex800 wrote: > > > Here's my pseudo random number generator. > > > > > > It is by no means very random. > > > > > > ; 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 (seed) > > > mov a, m ; put the seed value into A > > > cpi 0 ; check for seed equals zero > > > jnz RANDOMIZEA ; if seed is zero jump to randomizea > > > cma ; compliment A > > > mov m, a ; put A back into seed > > This line is redundant because you save the seed again later on. > > > > RANDOMIZEA: rlc ; rotate left through carry > > > adi 43 ; add 43 offset > > > mov m, a ; save in seed > > > pop h ; load HL > > > ret ; return with pseudo random in A > > > > > > I would be more than happy for you to suggest something better as > > > long as it doesn't add any CPU cycles. :-) > > > 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 >
Message
Re: random LFO
2008-09-20 by korgpolyex800
Attachments
- No local attachments were found for this message.
