Archive of the former Yahoo!Groups mailing list: Korg Poly800/EX800 Users

previous by date index next by date
previous in topic topic list next in topic

Subject: Re: random LFO

From: "korgpolyex800" <korgpolyex800@...>
Date: 2008-09-20

Actually, the more time I spend writing this code in assembler, the
more I realize how clever the guys who came up with C were. And I wish
I was doing this all in C.

The pseudo number generator is known as a Linear Congruential Random
Number Generator. You can all about it
http://www.daylight.com/meetings/emug98/Sayle/sample.html.

Since we're working in 8 bits, it's periodicity is short. And it could
be made to be much better than it is. I just got a result that sounded
OK and stayed with that. But I am sure that I will go back and revisit
this little code snippet and work on it some time.

Meanwhile, the equation looks like this.

Xn+1 = (aXn+c) mod m

And yes, all of the code that I have written is commented like that
and all of the original Korg code that I understand is commented like
that. Is there a problem with my commenting?

Mike


--- In korgpolyex@yahoogroups.com, Atom Smasher <atom@...> wrote:
>
> assembler?!?! i should have known.... and i've always considered C a
low
> level language...
>
> despite the verbose comments (is all of the code commented that
well?) i
> can't follow it. can you give a brief explanation?
>
>
>
>
> 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:pushh ; save HL
> > lxih, M_RANDOM ; point at the previous value (seed)
> > mova, m ; put the seed value into A
> > cpi0 ; check for seed equals zero
> > jnzRANDOMIZEA ; if seed is zero jump to randomizea
> > cma ; compliment A
> > movm, a ; put A back into seed
> > RANDOMIZEA:rlc ; rotate left through carry
> > adi43 ; add 43 offset
> > movm, a ; save in seed
> > poph ; 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. :-)
>
>
> --
> ...atom
>
> ________________________
> http://atom.smasher.org/
> 762A 3B98 A3C3 96C9 C6B7 582A B88D 52E4 D9F5 7808
> -------------------------------------------------
>
> "It has become appallingly obvious that our
> technology has exceeded our humanity."
> -- Albert Einstein
>