Csound Csound-dev Csound-tekno Search About

[Csnd] rand, etc.

Date2010-07-27 22:49
FromMatt Barber
Subject[Csnd] rand, etc.
Hello,

Does anyone know if csound's rand* opcodes produce random values
within in the range inclusive or exclusive of the +/- amplitude value?

For instance, if I were to write:

anoise rand 0.5

to generate float samples, would 0.5 and -0.5 be included among
possible output samples, or would I get values up to but not including
0.5 (and down to but not including -0.5)?


Thanks,

Matt


Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"

Date2010-07-28 11:58
Fromk_o_m_p
Subject[Csnd] Re: rand, etc.
Hi Matt,
welcome to the csound list!
I tried a simple file to test the rand opcode and it seams like the range is inclusive the amplitude value.
You can take a look at the csd-file and play with the ithre variable.
Best,
Luis

<CsoundSynthesizer>

<CsOptions>

</CsOptions>

<CsInstruments> ;++++++++++++++++++++++++++++++++++++++++

; Initialize the global variables.

sr = 44100

ksmps = 1

nchnls = 1

gknoise init 0

instr 1

ithre = 0.4999

anoise rand 0.5

knoise downsamp anoise

ithre2 = -ithre

ktrig1 trigger knoise, ithre, 2

ktrig2 trigger knoise, ithre2, 2

gknoise = knoise

schedkwhen ktrig1, 0, 0, 2, 0, 0.001

schedkwhen ktrig2, 0, 0, 2, 0, 0.001

endin

instr 2

inoise = i(gknoise)

print inoise

turnoff

endin

</CsInstruments>

<CsScore>

i1 0 100

e

</CsScore>

</CsoundSynthesizer>



Am 27.07.10 23:49, schrieb Matt Barber:
Hello,

Does anyone know if csound's rand* opcodes produce random values
within in the range inclusive or exclusive of the +/- amplitude value?

For instance, if I were to write:

anoise rand 0.5

to generate float samples, would 0.5 and -0.5 be included among
possible output samples, or would I get values up to but not including
0.5 (and down to but not including -0.5)?


Thanks,

Matt


Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"




--
signatur ---
[new adress]

luis antunes pena
c/o Internationales Kuenstlerhaus Villa Concordia
Concordiastr. 28
D-96049 Bamberg
(Germany)

http://sumtone.com
http://ixherculean.com

+49 (0)176 968 09 867
skype: antunespena

Date2010-07-28 12:35
Fromjoachim heintz
Subject[Csnd] Re: Re: rand, etc.
thanks for the example! (each time i learn a bit more about csound -  
didn't really know about the trigger opcode ...)
i think it's in one point misleading, because print rounds to 3  
digits. so instr 2 should perhaps be written:
instr 2
inoise = i(gknoise)
prints "inoise = %f%n", inoise
turnoff
endin

doing this, i get -0.5, but not +0.5. so the lower limit can be  
touched, but not the upper?

i get the same result by this formulation:





ksmps = 1
instr 1
knois rand .5
if knois == 0.5 then
printks "wau!%n", 0
elseif knois == -0.5 then
printks "wauwau!%n", 0
endif
endin


i 1 0 100
e



best -

	joachim


Am 28.07.2010 um 12:58 schrieb k_o_m_p:

> Hi Matt,
> welcome to the csound list!
> I tried a simple file to test the rand opcode and it seams like the  
> range is inclusive the amplitude value.
> You can take a look at the csd-file and play with the ithre variable.
> Best,
> Luis
>
> 
> 
> 
>  ;++++++++++++++++++++++++++++++++++++++++
> ; Initialize the global variables.
> sr = 44100
> ksmps = 1
> nchnls = 1
> gknoise init 0
> instr 1
> ithre = 0.4999
> anoise rand 0.5
> knoise downsamp anoise
> ithre2 = -ithre
> ktrig1 trigger knoise, ithre, 2
> ktrig2 trigger knoise, ithre2, 2
> gknoise = knoise
> schedkwhen ktrig1, 0, 0, 2, 0, 0.001
> schedkwhen ktrig2, 0, 0, 2, 0, 0.001
> endin
> instr 2
> inoise = i(gknoise)
> print inoise
> turnoff
> endin
> 
> 
> i1 0 100
> e
> 
> 
>
>
> Am 27.07.10 23:49, schrieb Matt Barber:
>>
>> Hello,
>>
>> Does anyone know if csound's rand* opcodes produce random values
>> within in the range inclusive or exclusive of the +/- amplitude  
>> value?
>>
>> For instance, if I were to write:
>>
>> anoise rand 0.5
>>
>> to generate float samples, would 0.5 and -0.5 be included among
>> possible output samples, or would I get values up to but not  
>> including
>> 0.5 (and down to but not including -0.5)?
>>
>>
>> Thanks,
>>
>> Matt
>>
>>
>> Send bugs reports to the Sourceforge bug tracker
>>             https://sourceforge.net/tracker/?group_id=81968&atid=564599
>> Discussions of bugs and features can be posted here
>> To unsubscribe, send email sympa@lists.bath.ac.uk with body  
>> "unsubscribe csound"
>>
>>
>
>
> -- 
> ---
> [new adress]
>
> luis antunes pena
> c/o Internationales Kuenstlerhaus Villa Concordia
> Concordiastr. 28
> D-96049 Bamberg
> (Germany)
>
> http://sumtone.com
> http://ixherculean.com
>
> +49 (0)176 968 09 867
> skype: antunespena



Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"

Date2010-07-28 15:41
Fromben hackbarth
Subject[Csnd] Re: Re: Re: rand, etc.
hiya matt,

hope you're well.

joachim's right -- as far as i've ever been able to tell, rand outputs
a semi-open range corresponding to [-xamp, xamp).  if xamp < 0, you
effectively get the opposite, (-xamp, xamp]

cheers,
—  ben



On Wed, Jul 28, 2010 at 1:35 PM, joachim heintz  wrote:
> thanks for the example! (each time i learn a bit more about csound - didn't
> really know about the trigger opcode ...)
> i think it's in one point misleading, because print rounds to 3 digits. so
> instr 2 should perhaps be written:
> instr 2
> inoise = i(gknoise)
> prints "inoise = %f%n", inoise
> turnoff
> endin
>
> doing this, i get -0.5, but not +0.5. so the lower limit can be touched, but
> not the upper?
>
> i get the same result by this formulation:
>
> 
> 
> 
> 
> ksmps = 1
> instr 1
> knois rand .5
> if knois == 0.5 then
> printks "wau!%n", 0
> elseif knois == -0.5 then
> printks "wauwau!%n", 0
> endif
> endin
> 
> 
> i 1 0 100
> e
> 
> 
>
> best -
>
>        joachim
>
>
> Am 28.07.2010 um 12:58 schrieb k_o_m_p:
>
>> Hi Matt,
>> welcome to the csound list!
>> I tried a simple file to test the rand opcode and it seams like the range
>> is inclusive the amplitude value.
>> You can take a look at the csd-file and play with the ithre variable.
>> Best,
>> Luis
>>
>> 
>> 
>> 
>>  ;++++++++++++++++++++++++++++++++++++++++
>> ; Initialize the global variables.
>> sr = 44100
>> ksmps = 1
>> nchnls = 1
>> gknoise init 0
>> instr 1
>> ithre = 0.4999
>> anoise rand 0.5
>> knoise downsamp anoise
>> ithre2 = -ithre
>> ktrig1 trigger knoise, ithre, 2
>> ktrig2 trigger knoise, ithre2, 2
>> gknoise = knoise
>> schedkwhen ktrig1, 0, 0, 2, 0, 0.001
>> schedkwhen ktrig2, 0, 0, 2, 0, 0.001
>> endin
>> instr 2
>> inoise = i(gknoise)
>> print inoise
>> turnoff
>> endin
>> 
>> 
>> i1 0 100
>> e
>> 
>> 
>>
>>
>> Am 27.07.10 23:49, schrieb Matt Barber:
>>>
>>> Hello,
>>>
>>> Does anyone know if csound's rand* opcodes produce random values
>>> within in the range inclusive or exclusive of the +/- amplitude value?
>>>
>>> For instance, if I were to write:
>>>
>>> anoise rand 0.5
>>>
>>> to generate float samples, would 0.5 and -0.5 be included among
>>> possible output samples, or would I get values up to but not including
>>> 0.5 (and down to but not including -0.5)?
>>>
>>>
>>> Thanks,
>>>
>>> Matt
>>>
>>>
>>> Send bugs reports to the Sourceforge bug tracker
>>>            https://sourceforge.net/tracker/?group_id=81968&atid=564599
>>> Discussions of bugs and features can be posted here
>>> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
>>> csound"
>>>
>>>
>>
>>
>> --
>> ---
>> [new adress]
>>
>> luis antunes pena
>> c/o Internationales Kuenstlerhaus Villa Concordia
>> Concordiastr. 28
>> D-96049 Bamberg
>> (Germany)
>>
>> http://sumtone.com
>> http://ixherculean.com
>>
>> +49 (0)176 968 09 867
>> skype: antunespena
>
>
>
> Send bugs reports to the Sourceforge bug tracker
>           https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
> csound"
>
>


Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"


Date2010-07-28 15:50
Fromk_o_m_p
Subject[Csnd] Re: Re: Re: rand, etc.
hi joachim,
indeed. now it seams to be clear to me too.
thanks,
luís

Am 28.07.10 13:35, schrieb joachim heintz:
thanks for the example! (each time i learn a bit more about csound - didn't really know about the trigger opcode ...)
i think it's in one point misleading, because print rounds to 3 digits. so instr 2 should perhaps be written:
instr 2
inoise = i(gknoise)
prints "inoise = %f%n", inoise
turnoff
endin

doing this, i get -0.5, but not +0.5. so the lower limit can be touched, but not the upper?

i get the same result by this formulation:

<CsoundSynthesizer>
<CsOptions>
</CsOptions>
<CsInstruments>
ksmps = 1
instr 1
knois rand .5
if knois == 0.5 then
printks "wau!%n", 0
elseif knois == -0.5 then
printks "wauwau!%n", 0
endif
endin
</CsInstruments>
<CsScore>
i 1 0 100
e
</CsScore>
</CsoundSynthesizer>

best -

    joachim


Am 28.07.2010 um 12:58 schrieb k_o_m_p:

Hi Matt,
welcome to the csound list!
I tried a simple file to test the rand opcode and it seams like the range is inclusive the amplitude value.
You can take a look at the csd-file and play with the ithre variable.
Best,
Luis

<CsoundSynthesizer>
<CsOptions>
</CsOptions>
<CsInstruments> ;++++++++++++++++++++++++++++++++++++++++
; Initialize the global variables.
sr = 44100
ksmps = 1
nchnls = 1
gknoise init 0
instr 1
ithre = 0.4999
anoise rand 0.5
knoise downsamp anoise
ithre2 = -ithre
ktrig1 trigger knoise, ithre, 2
ktrig2 trigger knoise, ithre2, 2
gknoise = knoise
schedkwhen ktrig1, 0, 0, 2, 0, 0.001
schedkwhen ktrig2, 0, 0, 2, 0, 0.001
endin
instr 2
inoise = i(gknoise)
print inoise
turnoff
endin
</CsInstruments>
<CsScore>
i1 0 100
e
</CsScore>
</CsoundSynthesizer>


Am 27.07.10 23:49, schrieb Matt Barber:

Hello,

Does anyone know if csound's rand* opcodes produce random values
within in the range inclusive or exclusive of the +/- amplitude value?

For instance, if I were to write:

anoise rand 0.5

to generate float samples, would 0.5 and -0.5 be included among
possible output samples, or would I get values up to but not including
0.5 (and down to but not including -0.5)?


Thanks,

Matt


Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"




-- 
---
[new adress]

luis antunes pena
c/o Internationales Kuenstlerhaus Villa Concordia
Concordiastr. 28
D-96049 Bamberg
(Germany)

http://sumtone.com
http://ixherculean.com

+49 (0)176 968 09 867
skype: antunespena



Send bugs reports to the Sourceforge bug tracker
           https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"




--
signatur ---
[new adress]

luis antunes pena
c/o Internationales Kuenstlerhaus Villa Concordia
Concordiastr. 28
D-96049 Bamberg
(Germany)

http://sumtone.com
http://ixherculean.com

+49 (0)176 968 09 867
skype: antunespena

Date2010-07-28 16:18
FromAaron Krister Johnson
Subject[Csnd] Re: rand, etc.
Hi all,

This brings up an interesting question --- is it possible to incorporate an opcode that would read from /dev/urandom on Linux, so that we could get closer to true randomness instead of a pseudo-random generator?

AKJ

On Tue, Jul 27, 2010 at 4:49 PM, Matt Barber <brbrofsvl@gmail.com> wrote:
Hello,

Does anyone know if csound's rand* opcodes produce random values
within in the range inclusive or exclusive of the +/- amplitude value?

For instance, if I were to write:

anoise rand 0.5

to generate float samples, would 0.5 and -0.5 be included among
possible output samples, or would I get values up to but not including
0.5 (and down to but not including -0.5)?


Thanks,

Matt


Send bugs reports to the Sourceforge bug tracker
           https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"




--
Best,

Aaron Krister Johnson
http://www.akjmusic.com
http://www.untwelve.org


Date2010-07-28 17:06
Fromjpff@cs.bath.ac.uk
Subject[Csnd] Re: Re: rand, etc.
> Hi all,
>
> This brings up an interesting question --- is it possible to incorporate
> an
> opcode that would read from /dev/urandom on Linux, so that we could get
> closer to true randomness instead of a pseudo-random generator?
>
> AKJ

Yes; been considering it fopr a while.

Tomorrow OK?



Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"

Date2010-07-28 18:37
Fromjpff@cs.bath.ac.uk
Subject[Csnd] Re: Re: Re: rand, etc.
>> Hi all,
>>
>> This brings up an interesting question --- is it possible to incorporate
>> an
>> opcode that would read from /dev/urandom on Linux, so that we could get
>> closer to true randomness instead of a pseudo-random generator?
>>
>> AKJ
>
> Yes; been considering it fopr a while.
>
> Tomorrow OK?
>



I k0rate versionis running in CVS.  I assume an i-rate and a-rate version
will be required, and at presnt in in range (-1,+1) and that could be
scaled.

Suggestions?

>
>
>




Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"

Date2010-07-30 17:04
Frombrbrofsvl
Subject[Csnd] Re: Re: Re: rand, etc.
It's great to see old friends on the list!

It would make a great deal of sense for it to be inclusive at the bottom end
and exclusive at the top, as this is the standard for signed integers (e.g.
the -32768 to +32767 range of two's complement 16-bit ints).  It would
appear looking at the manual page that by default you get 16-bit random
numbers -- I haven't looked through the source, but it would make sense to
take a 16-bit int rand generator and simply scale the values to xamp.

Thanks a ton!

Matt