Csound Csound-dev Csound-tekno Search About

31 bit PRNG for x-class noise ugens

Date1998-11-13 14:24
FromRobin Whittle
Subject31 bit PRNG for x-class noise ugens
I tackled this random number business in July.  Take a look at:
  
   http://www.firstpr.com.au/csound/

and scroll down to the heading:

   "1 - Adding a better Random Number Generator to Csound"

I installed a single 31 bit Park-Miller Pseudo Random Number 
Generator (PRNG) for use by all the "x-class noise" ugens.  There is 
a seed ugen for that PRNG:  such that if the input paremeter to the
seed opcode is 0, then the time of day will be used, and if it is 
anything else, then the seed is used to three decimal places, with a 
range of any positive or negative number to a maximum value of +/- 
2,147,483.645. Input above this is treated mod 2,147,483.645. 

The new system runs marginally faster (28% on my Linux PPro machine) 
than the internal C library PRNG rand() function.


I also added functions in cmath.c and lines in entry.c to implement 
three new bipolar uniform random opcodes: 

     ibunirand, kbunirand and abunirand. 

          ir   ibunirand   irange 
          kr   kbunirand   krange 
          ar   abunirand   krange

These behave just like the xbunirand opcodes (erroneously called 
xuniform in the current manual) except that their ouput range is 
positive and negative, rather than positive from 0 to xrange.  For 
instance: 

          ar   abunirand   100

will write evenly distributed random numbers - ie white noise - in 
the range -100 to +100. 


The source code and patch files to achieve the changes are all at my 
site, in the directory:

    http://www.firstpr.com.au/csound/rand31/

An updated version of the x-class noise page of Jean Piché's HTML 
manual is at:

    http://www.firstpr.com.au/csound/rand31/xnoise.html

I haven't done any Csounding for a while, but what I did a few months 
ago, I did use these features.  These changes have also been 
incorporated in the [Infamous - or whatever the name is to 
distinguish it from John Fitch's] Linux version of Csound as 
maintained by Nicola Bernardini . 


Matt J. Ingalls wrote:

> well- i can see times where a composer (maybe one who had not gone through a
> cagean-worship graduate program like some of us) would want to recreate a
> specific stream of pseudorandom numbers...

That's exactly what I have been doing.  All the random elements of a piece use 
the x-class-noise ugens and therefore depend entirely on the single seed.  I 
have made mulitple versions of the one piece with multiple seeds (chosen for 
instance by rolling dice or whatever) and then I can listen to them and decide 
which ones I like.  Then the seed number, the .orc and the .sco is all I need 
to recreate it.  The randomness is used for audio noise and for control rate 
things which have a significant outcome on the piece.

I saw John Cage perform in Adelaide in 1976, when a mini-busload of us LaTrobe 
University music students went to the Adelaide Festival.  In the midst of a 40 
(?) minute mind-numbing recitation of randomly chosen, softly spoken, 
meaningless disconnected sylables, spontaneous, nervous applause broke out and 
I joined in. The man with the sunny disposition didn't miss a stochastic beat 
and continued for the remaining 15 minutes or so of the piece.


> that said, i think backwards compatibility is not that big of an issue, as i
> said before i have loads of orchestras that used to work but dont now due to
> changes in csound.

My changes do not affect backwards compatibility.  See my site for a review of 
the various random number subsystems in Csound - its not a pretty sight, and I 
may have missed something.  Apart from the x-class-noise ugens, I leave them 
all alone: I leave the source code alone and don't use the ugens.

- Robin



===============================================================

Robin Whittle     rw@firstpr.com.au  http://www.firstpr.com.au
                  Heidelberg Heights, Melbourne, Australia 

First Principles  Research and expression: music, Internet 
                  music marketing, telecommunications, human 
                  factors in technology adoption. Consumer 
                  advocacy in telecommunications, especially 
                  privacy. Consulting and technical writing. 

Real World        Electronics and software for music: eg.
Interfaces        the Devil Fish mods for the TB-303. 

==================================================

Date1998-11-13 14:53
Fromtolve
SubjectRe: 31 bit PRNG for x-class noise ugens
robin whittle wrote:

>I saw John Cage perform in Adelaide in 1976, when a mini-busload of us LaTrobe
>University music students went to the Adelaide Festival.  In the midst of a 40
>(?) minute mind-numbing recitation of randomly chosen, softly spoken,
>meaningless disconnected sylables, spontaneous, nervous applause broke out and
>I joined in. The man with the sunny disposition didn't miss a stochastic beat
>and continued for the remaining 15 minutes or so of the piece.

believe i caught that tour in potsdam, ny usa. cage explained that the
syllables were chinese and selected via the I Ching. my mind similarly
numbed. if it was actually the same piece, our common experience was merely
derived from excerpts of what i believe had a running time of 48 hours. at
the performance i attended, an entire theater emptied save for 20 audience
members who were then invited onstage for a question answer period. i cut
my next class and remained (took a bit of hell for it but ultimately worth
it).

cage then went on for around 30 minutes explaining how the universe was
completely random. after which someone suggested that he might not be
correct as every event can only be based on what comes before. cage looked
up, scratched his beard, looked back at the man and said: "you're right."
and we moved on to other topics.

incidentally robin, without myself really understanding: my you tied that
random thread together nicely!

tolve