Csound Csound-dev Csound-tekno Search About

[Csnd] Re: Re: csound Digest Fri, 07 Mar 2008 (2/3)

Date2008-03-07 16:04
Frommark jamerson
Subject[Csnd] Re: Re: csound Digest Fri, 07 Mar 2008 (2/3)

Even Brenden,

    This is how I have done it, placing a trigger before the schedkwhen:

turnon 44
 instr 44

    kf1 init 0

    kk OSClisten gihandle, "/pd100", "f", kf1

    kthresh = (whatever you want your threshold to be)
    ktrig   trigger kf1,kthresh,kmode
    schedkwhen  trig, 0.1, 2, 100, 0, 2

endin


                              Mark Jamerson
   

----- Original Message ----
From: Even Brenden <evenbrenden@gmail.com>
To: csound@lists.bath.ac.uk
Sent: Friday, March 7, 2008 6:52:10 AM
Subject: [Csnd] Re: csound Digest Fri, 07 Mar 2008 (2/3)

"segmentaton violation - problems with event, event_i and schedkwhen"

i'm using OSC for communication between PD and csound for triggering single instances of of my instruments from events in PD. i have tried these two approaches:

----1----

turnon 44
instr  44

    kf1 init 0
   
    nxtmsg:
        kk  OSClisten gihandle, "/pd100", "f", kf1
    if (kk == 0) goto ex
        event_i "i", 100, 0.1 ,1.2
        kgoto nxtmsg
    ex:

endin

----2----

turnon 44 ; slår på osctriglytting for perks
instr  44 ;LYTTE OSC -> TRIG

    kf1 init 0
    kk  OSClisten gihandle, "/pd100", "f", kf1
    schedkwhen kk, 0.1, 2, 100, 0, 2
       
endin

----

both attempts, which have been tried out with several duration values and such, give a "segmentaton violation" the instant that schekwhen/event_i is executed. any suggestions? is there perhaps a better approach for triggering instruments via OSC?

-Even Brenden



Never miss a thing. Make Yahoo your homepage.

Date2008-03-07 17:08
FromCortaigne
Subject[Csnd] Random Question
Heyas.  I'm really new to Csound, so most of it's way over my head.   
I've got this little experiment going, though, and I'm trying to  
figure out how to get it to work properly.  Essentially, I'd like to  
have an instrument select notes at random -- ideally, diatonically,  
but for right now I'm just trying to get it to work chromatically.   
The problem is, with the current revision, it seems to repeat notes  
four or five times before selecting a different note.  I suspect I'm  
using the wrong randomizing opcode, but when I've tried others, I get  
conflicts (like it produces a k-rate variable and I need it to make  
an i-rate variable, or whatever; remember, I'm very new at this, so  
what I'm saying might be gibberish).  Anyway, here's what I've got --  
I hope someone can make sense of it and tell me what I'm doing wrong:




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

instr 1

	; Random Note Selector
	seed 0
	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 260

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




Date2008-03-07 18:16
FromCortaigne
Subject[Csnd] Random Question (Supplemental)
Just in case this might help, here's an earlier experiment that uses  
a different randomizing opcode.  It definitely does a better job at  
randomization, but as I mentioned in the other message, I couldn't  
figure out a way to harness the output of the randh and mold it into  
something cpspch could use.




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

instr 101
	kFreq	randh 1024, 5, 5
	aFreq	linen kFreq, 1, p3, 3
	aSig	oscil	p4, aFreq, 1
	aRev	reverb aSig, 0.25
	out	aRev
endin




f1 0 8192 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

i101	0	4	4000
i.	+	.	.
i.	.	.	.
i.	.	.	.




Date2008-03-07 18:21
FromRory Walsh
Subject[Csnd] Re: Random Question (Supplemental)
You could do something like this:



-odevaudio -b10 -idevaudio


sr = 44100
kr = 44100
ksmps = 1
nchnls = 1
#define MIDI2CPS(xmidi) # (440.0*exp(log(2.0)*(($xmidi)-69.0)/12.0)) #

instr 1
kfreq randh 12, 1
kenv oscil 10000, 1, 2
kfreq = $MIDI2CPS(60+kfreq)
a1 oscil kenv, kfreq, 1
out a1
endin



f1 0 1024 10 1
f2 0 1024 7 0 100 1 824 1 100 0
i1 0 100



Rory.


Cortaigne wrote:
> Just in case this might help, here's an earlier experiment that uses a 
> different randomizing opcode.  It definitely does a better job at 
> randomization, but as I mentioned in the other message, I couldn't 
> figure out a way to harness the output of the randh and mold it into 
> something cpspch could use.
> 
> 
> 
> 
> sr = 44100
> kr = 4410
> ksmps = 10
> nchnls = 1
> 
> instr 101
>     kFreq    randh 1024, 5, 5
>     aFreq    linen kFreq, 1, p3, 3
>     aSig    oscil    p4, aFreq, 1
>     aRev    reverb aSig, 0.25
>     out    aRev
> endin
> 
> 
> 
> 
> f1 0 8192 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
> 
> i101    0    4    4000
> i.    +    .    .
> i.    .    .    .
> i.    .    .    .
> 
> 
> 
> 
> 
> Send bugs reports to this list.
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe 
> csound"
> 

Date2008-03-07 18:36
FromCortaigne
Subject[Csnd] Re: Re: Random Question (Supplemental)
There's definitely stuff going on in there that I haven't learned  
about yet, so I'll need to hit the manual, but on first glance, it  
looks like you might be randomizing MIDI notes.  That's an excellent  
possibility I hadn't even considered!  (I won't even pretend to  
understand the math in that, by the way -- something about exponents  
and logarithms, maybe?)   ;-)

Thanks for the suggestion!  I'll need to pick it apart further and  
see what I can derive from it.


On Mar 7, 2008, at 12:21:57 PM CST, Rory Walsh wrote:

> You could do something like this:
>
> 
> 
> -odevaudio -b10 -idevaudio
> 
> 
> sr = 44100
> kr = 44100
> ksmps = 1
> nchnls = 1
> #define MIDI2CPS(xmidi) # (440.0*exp(log(2.0)*(($xmidi)-69.0)/12.0)) #
>
> instr 1
> kfreq randh 12, 1
> kenv oscil 10000, 1, 2
> kfreq = $MIDI2CPS(60+kfreq)
> a1 oscil kenv, kfreq, 1
> out a1
> endin
>
> 
> 
> f1 0 1024 10 1
> f2 0 1024 7 0 100 1 824 1 100 0
> i1 0 100
> 
> 
>
> Rory.
>
>
> Cortaigne wrote:
>> Just in case this might help, here's an earlier experiment that  
>> uses a different randomizing opcode.  It definitely does a better  
>> job at randomization, but as I mentioned in the other message, I  
>> couldn't figure out a way to harness the output of the randh and  
>> mold it into something cpspch could use.
>> 
>> 
>> sr = 44100
>> kr = 4410
>> ksmps = 10
>> nchnls = 1
>> instr 101
>>     kFreq    randh 1024, 5, 5
>>     aFreq    linen kFreq, 1, p3, 3
>>     aSig    oscil    p4, aFreq, 1
>>     aRev    reverb aSig, 0.25
>>     out    aRev
>> endin
>> 
>> 
>> f1 0 8192 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
>> i101    0    4    4000
>> i.    +    .    .
>> i.    .    .    .
>> i.    .    .    .
>> 
>> 
>> 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-07 18:37
FromRory Walsh
Subject[Csnd] Re: Re: Random Question (Supplemental)
You could also load the diatonic scale into a function table and read 
back the values randomly, in fact that would be easier I think. You can 
use GEN02.

Rory.


Rory Walsh wrote:
> You could do something like this:
> 
> 
> 
> -odevaudio -b10 -idevaudio
> 
> 
> sr = 44100
> kr = 44100
> ksmps = 1
> nchnls = 1
> #define MIDI2CPS(xmidi) # (440.0*exp(log(2.0)*(($xmidi)-69.0)/12.0)) #
> 
> instr 1
> kfreq randh 12, 1
> kenv oscil 10000, 1, 2
> kfreq = $MIDI2CPS(60+kfreq)
> a1 oscil kenv, kfreq, 1
> out a1
> endin
> 
> 
> 
> f1 0 1024 10 1
> f2 0 1024 7 0 100 1 824 1 100 0
> i1 0 100
> 
> 
> 
> Rory.
> 
> 
> Cortaigne wrote:
>> Just in case this might help, here's an earlier experiment that uses a 
>> different randomizing opcode.  It definitely does a better job at 
>> randomization, but as I mentioned in the other message, I couldn't 
>> figure out a way to harness the output of the randh and mold it into 
>> something cpspch could use.
>>
>> 
>> 
>>
>> sr = 44100
>> kr = 4410
>> ksmps = 10
>> nchnls = 1
>>
>> instr 101
>>     kFreq    randh 1024, 5, 5
>>     aFreq    linen kFreq, 1, p3, 3
>>     aSig    oscil    p4, aFreq, 1
>>     aRev    reverb aSig, 0.25
>>     out    aRev
>> endin
>>
>> 
>> 
>>
>> f1 0 8192 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
>>
>> i101    0    4    4000
>> i.    +    .    .
>> i.    .    .    .
>> i.    .    .    .
>>
>> 
>> 
>>
>>
>> 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-07 18:41
FromCortaigne
Subject[Csnd] Re: Re: Re: Random Question (Supplemental)
I haven't done anything like that yet, but as I understand these  
things so far, that sounds like it might just be exactly the answer I  
need.  It could be set to whatever bizarre sort of scale one would  
wish to use, couldn't it?


On Mar 7, 2008, at 12:37:45 PM CST, Rory Walsh wrote:

> You could also load the diatonic scale into a function table and  
> read back the values randomly, in fact that would be easier I  
> think. You can use GEN02.
>
> Rory.
>
>
> Rory Walsh wrote:
>> You could do something like this:
>> 
>> 
>> -odevaudio -b10 -idevaudio
>> 
>> 
>> sr = 44100
>> kr = 44100
>> ksmps = 1
>> nchnls = 1
>> #define MIDI2CPS(xmidi) # (440.0*exp(log(2.0)*(($xmidi)-69.0)/ 
>> 12.0)) #
>> instr 1
>> kfreq randh 12, 1
>> kenv oscil 10000, 1, 2
>> kfreq = $MIDI2CPS(60+kfreq)
>> a1 oscil kenv, kfreq, 1
>> out a1
>> endin
>> 
>> 
>> f1 0 1024 10 1
>> f2 0 1024 7 0 100 1 824 1 100 0
>> i1 0 100
>> 
>> 
>> Rory.
>> Cortaigne wrote:
>>> Just in case this might help, here's an earlier experiment that  
>>> uses a different randomizing opcode.  It definitely does a better  
>>> job at randomization, but as I mentioned in the other message, I  
>>> couldn't figure out a way to harness the output of the randh and  
>>> mold it into something cpspch could use.
>>>
>>> 
>>> 
>>>
>>> sr = 44100
>>> kr = 4410
>>> ksmps = 10
>>> nchnls = 1
>>>
>>> instr 101
>>>     kFreq    randh 1024, 5, 5
>>>     aFreq    linen kFreq, 1, p3, 3
>>>     aSig    oscil    p4, aFreq, 1
>>>     aRev    reverb aSig, 0.25
>>>     out    aRev
>>> endin
>>>
>>> 
>>> 
>>>
>>> f1 0 8192 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
>>>
>>> i101    0    4    4000
>>> i.    +    .    .
>>> i.    .    .    .
>>> i.    .    .    .
>>>
>>> 
>>> 
>>>
>>>
>>> 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"
>
>
> Send bugs reports to this list.
> To unsubscribe, send email sympa@lists.bath.ac.uk with body  
> "unsubscribe csound"
>


Date2008-03-07 18:42
From"Aidan Collins"
Subject[Csnd] Re: Random Question
AttachmentsNone  

Date2008-03-07 18:43
FromRory Walsh
Subject[Csnd] Re: Re: Re: Random Question (Supplemental)
That midi2cps macro simply converts midi numbers to frequencies. Istvan 
Varga posted it to this list a while back and I've used it quite a bit. 
To tell you the truth I've never even looked at the equation.

Rory.


Cortaigne wrote:
> There's definitely stuff going on in there that I haven't learned about 
> yet, so I'll need to hit the manual, but on first glance, it looks like 
> you might be randomizing MIDI notes.  That's an excellent possibility I 
> hadn't even considered!  (I won't even pretend to understand the math in 
> that, by the way -- something about exponents and logarithms, maybe?)   ;-)
> 
> Thanks for the suggestion!  I'll need to pick it apart further and see 
> what I can derive from it.
> 
> 
> On Mar 7, 2008, at 12:21:57 PM CST, Rory Walsh wrote:
> 
>> You could do something like this:
>>
>> 
>> 
>> -odevaudio -b10 -idevaudio
>> 
>> 
>> sr = 44100
>> kr = 44100
>> ksmps = 1
>> nchnls = 1
>> #define MIDI2CPS(xmidi) # (440.0*exp(log(2.0)*(($xmidi)-69.0)/12.0)) #
>>
>> instr 1
>> kfreq randh 12, 1
>> kenv oscil 10000, 1, 2
>> kfreq = $MIDI2CPS(60+kfreq)
>> a1 oscil kenv, kfreq, 1
>> out a1
>> endin
>>
>> 
>> 
>> f1 0 1024 10 1
>> f2 0 1024 7 0 100 1 824 1 100 0
>> i1 0 100
>> 
>> 
>>
>> Rory.
>>
>>
>> Cortaigne wrote:
>>> Just in case this might help, here's an earlier experiment that uses 
>>> a different randomizing opcode.  It definitely does a better job at 
>>> randomization, but as I mentioned in the other message, I couldn't 
>>> figure out a way to harness the output of the randh and mold it into 
>>> something cpspch could use.
>>> 
>>> 
>>> sr = 44100
>>> kr = 4410
>>> ksmps = 10
>>> nchnls = 1
>>> instr 101
>>>     kFreq    randh 1024, 5, 5
>>>     aFreq    linen kFreq, 1, p3, 3
>>>     aSig    oscil    p4, aFreq, 1
>>>     aRev    reverb aSig, 0.25
>>>     out    aRev
>>> endin
>>> 
>>> 
>>> f1 0 8192 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
>>> i101    0    4    4000
>>> i.    +    .    .
>>> i.    .    .    .
>>> i.    .    .    .
>>> 
>>> 
>>> 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"
>>
> 
> 
> 
> Send bugs reports to this list.
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe 
> csound"
> 

Date2008-03-07 18:47
FromRory Walsh
Subject[Csnd] Re: Re: Re: Re: Random Question (Supplemental)
You can also try the cpstun opcode if you want to mess around with your 
own scales. I don't know much about it but others on the list do.

Rory.


Cortaigne wrote:
> I haven't done anything like that yet, but as I understand these things 
> so far, that sounds like it might just be exactly the answer I need.  It 
> could be set to whatever bizarre sort of scale one would wish to use, 
> couldn't it?
> 
> 
> On Mar 7, 2008, at 12:37:45 PM CST, Rory Walsh wrote:
> 
>> You could also load the diatonic scale into a function table and read 
>> back the values randomly, in fact that would be easier I think. You 
>> can use GEN02.
>>
>> Rory.
>>
>>
>> Rory Walsh wrote:
>>> You could do something like this:
>>> 
>>> 
>>> -odevaudio -b10 -idevaudio
>>> 
>>> 
>>> sr = 44100
>>> kr = 44100
>>> ksmps = 1
>>> nchnls = 1
>>> #define MIDI2CPS(xmidi) # (440.0*exp(log(2.0)*(($xmidi)-69.0)/12.0)) #
>>> instr 1
>>> kfreq randh 12, 1
>>> kenv oscil 10000, 1, 2
>>> kfreq = $MIDI2CPS(60+kfreq)
>>> a1 oscil kenv, kfreq, 1
>>> out a1
>>> endin
>>> 
>>> 
>>> f1 0 1024 10 1
>>> f2 0 1024 7 0 100 1 824 1 100 0
>>> i1 0 100
>>> 
>>> 
>>> Rory.
>>> Cortaigne wrote:
>>>> Just in case this might help, here's an earlier experiment that uses 
>>>> a different randomizing opcode.  It definitely does a better job at 
>>>> randomization, but as I mentioned in the other message, I couldn't 
>>>> figure out a way to harness the output of the randh and mold it into 
>>>> something cpspch could use.
>>>>
>>>> 
>>>> 
>>>>
>>>> sr = 44100
>>>> kr = 4410
>>>> ksmps = 10
>>>> nchnls = 1
>>>>
>>>> instr 101
>>>>     kFreq    randh 1024, 5, 5
>>>>     aFreq    linen kFreq, 1, p3, 3
>>>>     aSig    oscil    p4, aFreq, 1
>>>>     aRev    reverb aSig, 0.25
>>>>     out    aRev
>>>> endin
>>>>
>>>> 
>>>> 
>>>>
>>>> f1 0 8192 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
>>>>
>>>> i101    0    4    4000
>>>> i.    +    .    .
>>>> i.    .    .    .
>>>> i.    .    .    .
>>>>
>>>> 
>>>> 
>>>>
>>>>
>>>> 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"
>>
>>
>> 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-07 18:51
FromCortaigne
Subject[Csnd] Re: Re: Random Question
I'd actually considered the possibility of close results, which is why I put in the "print iBase" bit, and it turns out to produce sequences like:

instr 1:  iBase = 19.119
instr 1:  iBase = 19.119
instr 1:  iBase = 19.119
instr 1:  iBase = 6.965
instr 1:  iBase = 6.965
instr 1:  iBase = 6.965
instr 1:  iBase = 6.965
instr 1:  iBase = 19.812
instr 1:  iBase = 19.812
instr 1:  iBase = 19.812
instr 1:  iBase = 19.812
instr 1:  iBase = 19.812
instr 1:  iBase = 7.658
instr 1:  iBase = 7.658
instr 1:  iBase = 7.658

Incidentally, one thing I've noticed is that it tends to climb in two alternating bits -- like, four or five low-ish notes, then four or five high-ish notes, then four or five slightly-higher-than-the-previous-low-ish notes, then four or five slightly-higher-than-the-previous-high-ish notes, and so on.  (Very technical, I know.)   ;-)


On Mar 7, 2008, at 12:42:51 PM CST, Aidan Collins wrote:

I wonder if the problem is that you are getting random numbers that
are close together and then truncated to the same integer.
like 7.11. 7.89, 7.23 or something like that.
maybe you could try making the range 0 - 1 and then multiplying by 100
before you force it to an integer.

Aidan



On Fri, Mar 7, 2008 at 12:08 PM, Cortaigne <cortaigne@mitb.net> wrote:
Heyas.  I'm really new to Csound, so most of it's way over my head.
 I've got this little experiment going, though, and I'm trying to
 figure out how to get it to work properly.  Essentially, I'd like to
 have an instrument select notes at random -- ideally, diatonically,
 but for right now I'm just trying to get it to work chromatically.
 The problem is, with the current revision, it seems to repeat notes
 four or five times before selecting a different note.  I suspect I'm
 using the wrong randomizing opcode, but when I've tried others, I get
 conflicts (like it produces a k-rate variable and I need it to make
 an i-rate variable, or whatever; remember, I'm very new at this, so
 what I'm saying might be gibberish).  Anyway, here's what I've got --
 I hope someone can make sense of it and tell me what I'm doing wrong:

 <CsoundSynthesizer>
 <CsInstruments>

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

 instr 1

        ; Random Note Selector
        seed 0
        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

 </CsInstruments>
 <CsScore>

 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 260

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

 </CsScore>
 </CsoundSynthesizer>


 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-07 19:42
FromFrank Hübenthal
Subject[Csnd] Re: Random Question
Cortaigne schrieb:
> Heyas.  I'm really new to Csound, so most of it's way over my head.  
> I've got this little experiment going, though, and I'm trying to 
> figure out how to get it to work properly.  Essentially, I'd like to 
> have an instrument select notes at random -- ideally, diatonically, 
> but for right now I'm just trying to get it to work chromatically.  
> The problem is, with the current revision, it seems to repeat notes 
> four or five times before selecting a different note.  I suspect I'm 
> using the wrong randomizing opcode, but when I've tried others, I get 
> conflicts (like it produces a k-rate variable and I need it to make an 
> i-rate variable, or whatever; remember, I'm very new at this, so what 
> I'm saying might be gibberish).  Anyway, here's what I've got -- I 
> hope someone can make sense of it and tell me what I'm doing wrong:
>
> [...]
>
> instr 1
>
>     ; Random Note Selector
>     seed 0
>     iBase    linrand 25
>     iNum = int(iBase)
>     iNote = (iNum/100) + 7
> [...]

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)
    [...]





Date2008-03-07 19:53
FromCesare Marilungo
Subject[Csnd] Re: Re: Re: Re: Random Question (Supplemental)
Since version 5.07 there's also the cpsmidinn opcode for this.

Best,

-c.

Rory Walsh wrote:
> That midi2cps macro simply converts midi numbers to frequencies. 
> Istvan Varga posted it to this list a while back and I've used it 
> quite a bit. To tell you the truth I've never even looked at the 
> equation.
>
> Rory.
>
>
> Cortaigne wrote:
>> There's definitely stuff going on in there that I haven't learned 
>> about yet, so I'll need to hit the manual, but on first glance, it 
>> looks like you might be randomizing MIDI notes.  That's an excellent 
>> possibility I hadn't even considered!  (I won't even pretend to 
>> understand the math in that, by the way -- something about exponents 
>> and logarithms, maybe?)   ;-)
>>
>> Thanks for the suggestion!  I'll need to pick it apart further and 
>> see what I can derive from it.
>>
>>
>> On Mar 7, 2008, at 12:21:57 PM CST, Rory Walsh wrote:
>>
>>> You could do something like this:
>>>
>>> 
>>> 
>>> -odevaudio -b10 -idevaudio
>>> 
>>> 
>>> sr = 44100
>>> kr = 44100
>>> ksmps = 1
>>> nchnls = 1
>>> #define MIDI2CPS(xmidi) # (440.0*exp(log(2.0)*(($xmidi)-69.0)/12.0)) #
>>>
>>> instr 1
>>> kfreq randh 12, 1
>>> kenv oscil 10000, 1, 2
>>> kfreq = $MIDI2CPS(60+kfreq)
>>> a1 oscil kenv, kfreq, 1
>>> out a1
>>> endin
>>>
>>> 
>>> 
>>> f1 0 1024 10 1
>>> f2 0 1024 7 0 100 1 824 1 100 0
>>> i1 0 100
>>> 
>>> 
>>>
>>> Rory.
>>>
>>>
>>> Cortaigne wrote:
>>>> Just in case this might help, here's an earlier experiment that 
>>>> uses a different randomizing opcode.  It definitely does a better 
>>>> job at randomization, but as I mentioned in the other message, I 
>>>> couldn't figure out a way to harness the output of the randh and 
>>>> mold it into something cpspch could use.
>>>> 
>>>> 
>>>> sr = 44100
>>>> kr = 4410
>>>> ksmps = 10
>>>> nchnls = 1
>>>> instr 101
>>>>     kFreq    randh 1024, 5, 5
>>>>     aFreq    linen kFreq, 1, p3, 3
>>>>     aSig    oscil    p4, aFreq, 1
>>>>     aRev    reverb aSig, 0.25
>>>>     out    aRev
>>>> endin
>>>> 
>>>> 
>>>> f1 0 8192 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
>>>> i101    0    4    4000
>>>> i.    +    .    .
>>>> i.    .    .    .
>>>> i.    .    .    .
>>>> 
>>>> 
>>>> 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"
>>>
>>
>>
>>
>> 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"
>
>


-- 
www.cesaremarilungo.com 


Date2008-03-08 02:47
FromCortaigne
Subject[Csnd] Re: Re: Random Question
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)
>    [...]


Date2008-03-08 02:51
FromCortaigne
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"