Csound Csound-dev Csound-tekno Search About

[Csnd] Re: Re: Re: Re: Random Question

Date2008-03-08 05:05
From"Art Hunkins"
Subject[Csnd] Re: Re: Re: Re: Random Question
When seed 0 is used in a .csd header, rand is initialized by the system 
clock, and should give differing values for each performance or rendering. 
At least this is supposed to be the case on all systems.

Art Hunkins

----- Original Message ----- 
From: "Cortaigne" 
To: 
Sent: Friday, March 07, 2008 9:51 PM
Subject: [Csnd] Re: Re: Re: Random Question


Er, okay, so, maybe I spoke too soon.  Though each successive note is
now different, it gives the same sequence with each performance.   :-\


On Mar 7, 2008, at 08:47:42 PM CST, Cortaigne wrote:

> YES!  That was the answer!  It works!  Thank you so much!   :-)
>
> Now to explore diatonic techniques -- starting, I think, with  Rory's 
> suggestion of a function table and GEN02 (if I can figure  out how to do 
> it!).   >:)
>
>
> On Mar 7, 2008, at 01:42:56 PM CST, Frank Hübenthal wrote:
>
>> You should remove the "seed 0" line from your instrument, because  this 
>> command reinitializes the random generator everytime you use  instrument 
>> 1.  Don't know how it is implemented in csound, but  usually the system 
>> time is used as the new seed if zero is given  to the command. If the 
>> resolution is low (e.g. on a one second  base), you start the same random 
>> sequence again and again until  the system time advances one step.
>>
>> Place the "seed 0" line directly after the header (it is then  called 
>> once when your performance starts) and have fun :-)
>> Example follows:
>>
>> sr = 44100
>> kr = 4410
>> ksmps = 10
>> nchnls = 1
>>
>> seed 0
>>
>> instr 1
>>
>>    ; Random Note Selector
>>    iBase    linrand 25
>>    iNum = int(iBase)
>>    [...]
>
>
> Send bugs reports to this list.
> To unsubscribe, send email sympa@lists.bath.ac.uk with body  "unsubscribe 
> csound"



Send bugs reports to this list.
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe 
csound"= 


Date2008-03-08 08:06
FromCortaigne
Subject[Csnd] Re: Re: Re: Re: Re: Random Question
On Mar 7, 2008, at 11:05:38 PM CST, Art Hunkins wrote:
> When seed 0 is used in a .csd header, rand is initialized by the  
> system clock, and should give differing values for each performance  
> or rendering. At least this is supposed to be the case on all systems.

That would be my understanding as well, based on what I've read in  
the manual -- more or less, anyway.  The entry for seed says  
specifically, "rand, randh, randi, rnd(x) and birnd(x) are not  
affected by seed" -- but that shouldn't be an issue anyway, since I'm  
using linrand.  Now, since the entry for seed also says it "Sets the  
global seed value for all x-class noise generators...", and the entry  
for linrand says, "This is an x-class noise generator," it would seem  
to me that linrand should be affected by seed -- and indeed it seems  
to be, when seed is included within the instrument.  However, having  
moved seed out of the instrument and under the header, it seems to  
have absolutely no effect on the linrand, as deleting the seed line  
entirely will produce exactly the same sequence of output, namely:

instr 1:  iBase = 4.393
instr 1:  iBase = 7.716
instr 1:  iBase = 4.293
instr 1:  iBase = 5.660
instr 1:  iBase = 3.117
instr 1:  iBase = 2.097
instr 1:  iBase = 6.931
instr 1:  iBase = 13.385
instr 1:  iBase = 16.162
instr 1:  iBase = 19.179
instr 1:  iBase = 3.798
instr 1:  iBase = 7.867
instr 1:  iBase = 8.673
instr 1:  iBase = 10.029
instr 1:  iBase = 15.169
instr 1:  iBase = 21.748

If it makes a difference, I'm using MacCsound, which, according to  
the same output log, uses "Csound Version 4.23f12 (Mar  9 2005)."   
I'm very curious what sort of performance/rendering another system  
would produce from the same CSD. Would someone please try to run  
this?  The only other changes I've made are the tempo and the note  
durations; giving it a shuffle makes the sequence easier to remember  
from one performance/rendering to the next.




sr = 44100
kr = 4410
ksmps = 10
nchnls = 1

seed 0

instr 1

	; Random Note Selector
	iBase	linrand 25
	iNum = int(iBase)
	iNote = (iNum/100) + 7

	; Envelope
	aEnv linen db(p4), (p3 / 3), p3, (p3 / 3)

	; Output
	aSig	oscil aEnv, cpspch(iNote), 1
	print iBase
	print iNote
	out aSig

endin




f1 0 16384 10 1 0.618 0.382 0.236 0.146 0.090 0.056 0.034 0.021 0.013  
0.008 0.005 0.003 0.002 0.001

t 0 390

i1	0	2	85
i.	+	1	.
i.	.	2	.
i.	.	1	.
i.	.	2	.
i.	.	1	.
i.	.	2	.
i.	.	1	.
i.	.	2	.
i.	.	1	.
i.	.	2	.
i.	.	1	.
i.	.	2	.
i.	.	1	.
i.	.	2	.
i.	.	1	.






Date2008-03-08 08:26
FromCortaigne
Subject[Csnd] Re: Re: Re: Re: Re: Re: Random Question
Possible solution found -- albeit rather inelegant.  By adding this  
to the orchestra:

instr 2
	seed 0
endin

... and adding this to the score:

i2	0	1

... it seems to allow instr 1 (and its linrand) to produce a  
different random sequence with each performance/rendering, without  
repeating notes (beyond those expected by chance)!


On Mar 8, 2008, at 02:06:46 AM CST, Cortaigne wrote:

> On Mar 7, 2008, at 11:05:38 PM CST, Art Hunkins wrote:
>> When seed 0 is used in a .csd header, rand is initialized by the  
>> system clock, and should give differing values for each  
>> performance or rendering. At least this is supposed to be the case  
>> on all systems.
>
> That would be my understanding as well, based on what I've read in  
> the manual -- more or less, anyway.  The entry for seed says  
> specifically, "rand, randh, randi, rnd(x) and birnd(x) are not  
> affected by seed" -- but that shouldn't be an issue anyway, since  
> I'm using linrand.  Now, since the entry for seed also says it  
> "Sets the global seed value for all x-class noise generators...",  
> and the entry for linrand says, "This is an x-class noise  
> generator," it would seem to me that linrand should be affected by  
> seed -- and indeed it seems to be, when seed is included within the  
> instrument.  However, having moved seed out of the instrument and  
> under the header, it seems to have absolutely no effect on the  
> linrand, as deleting the seed line entirely will produce exactly  
> the same sequence of output, namely:
>
> instr 1:  iBase = 4.393
> instr 1:  iBase = 7.716
> instr 1:  iBase = 4.293
> instr 1:  iBase = 5.660
> instr 1:  iBase = 3.117
> instr 1:  iBase = 2.097
> instr 1:  iBase = 6.931
> instr 1:  iBase = 13.385
> instr 1:  iBase = 16.162
> instr 1:  iBase = 19.179
> instr 1:  iBase = 3.798
> instr 1:  iBase = 7.867
> instr 1:  iBase = 8.673
> instr 1:  iBase = 10.029
> instr 1:  iBase = 15.169
> instr 1:  iBase = 21.748
>
> If it makes a difference, I'm using MacCsound, which, according to  
> the same output log, uses "Csound Version 4.23f12 (Mar  9 2005)."   
> I'm very curious what sort of performance/rendering another system  
> would produce from the same CSD. Would someone please try to run  
> this?  The only other changes I've made are the tempo and the note  
> durations; giving it a shuffle makes the sequence easier to  
> remember from one performance/rendering to the next.
>
> 
> 
>
> sr = 44100
> kr = 4410
> ksmps = 10
> nchnls = 1
>
> seed 0
>
> instr 1
>
> 	; Random Note Selector
> 	iBase	linrand 25
> 	iNum = int(iBase)
> 	iNote = (iNum/100) + 7
>
> 	; Envelope
> 	aEnv linen db(p4), (p3 / 3), p3, (p3 / 3)
>
> 	; Output
> 	aSig	oscil aEnv, cpspch(iNote), 1
> 	print iBase
> 	print iNote
> 	out aSig
>
> endin
>
> 
> 
>
> f1 0 16384 10 1 0.618 0.382 0.236 0.146 0.090 0.056 0.034 0.021  
> 0.013 0.008 0.005 0.003 0.002 0.001
>
> t 0 390
>
> i1	0	2	85
> i.	+	1	.
> i.	.	2	.
> i.	.	1	.
> i.	.	2	.
> i.	.	1	.
> i.	.	2	.
> i.	.	1	.
> i.	.	2	.
> i.	.	1	.
> i.	.	2	.
> i.	.	1	.
> i.	.	2	.
> i.	.	1	.
> i.	.	2	.
> i.	.	1	.
>
> 
> 
>
>
>
>
> Send bugs reports to this list.
> To unsubscribe, send email sympa@lists.bath.ac.uk with body  
> "unsubscribe csound"
>