Csound Csound-dev Csound-tekno Search About

[Csnd] how to turn off an instance of an instrument from another instance of that instrument!!

Date2011-02-17 16:48
FromRory Walsh
Subject[Csnd] how to turn off an instance of an instrument from another instance of that instrument!!
No it's not a tongue twister. The following is a MIDI instrument. I
only want one note at a time, Users only have to press a note to start
it. Pressing another note should kill the previous instance but
shouldn't affect the current one. I know I could write a dedicated
MIDI event dispatcher but it sounds like overkill for what I want?

instr 1
icnt active 1
print icnt
if(icnt>1) then
turnoff2 1, 1, 0
endif
k1 linenr 1, .01, 100, 0.01
a1 oscil p4, p5, 1
out a1*k1
endin


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"

Date2011-02-17 17:00
FromVictor Lazzarini
SubjectRe: [Csnd] how to turn off an instance of an instrument from another
Attachmentsmoogm.csd  
Maybe this moog emulation CSD does what you want?

Victor
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"


On 17 Feb 2011, at 16:48, Rory Walsh wrote:

> No it's not a tongue twister. The following is a MIDI instrument. I
> only want one note at a time, Users only have to press a note to start
> it. Pressing another note should kill the previous instance but
> shouldn't affect the current one. I know I could write a dedicated
> MIDI event dispatcher but it sounds like overkill for what I want?
>
> instr 1
> icnt active 1
> print icnt
> if(icnt>1) then
> turnoff2 1, 1, 0
> endif
> k1 linenr 1, .01, 100, 0.01
> a1 oscil p4, p5, 1
> out a1*k1
> endin
>
>
> 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"
>


Date2011-02-17 17:20
FromAndres Cabrera
SubjectRe: [Csnd] how to turn off an instance of an instrument from another
Hi,

Use the decimal part of the instrument number to identify note instances.

Cheers,
Andres

On Thu, Feb 17, 2011 at 4:48 PM, Rory Walsh  wrote:
> No it's not a tongue twister. The following is a MIDI instrument. I
> only want one note at a time, Users only have to press a note to start
> it. Pressing another note should kill the previous instance but
> shouldn't affect the current one. I know I could write a dedicated
> MIDI event dispatcher but it sounds like overkill for what I want?
>
> instr 1
> icnt active 1
> print icnt
> if(icnt>1) then
> turnoff2 1, 1, 0
> endif
> k1 linenr 1, .01, 100, 0.01
> a1 oscil p4, p5, 1
> out a1*k1
> endin
>
>
> 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"


Date2011-02-17 17:33
FromRory Walsh
SubjectRe: [Csnd] how to turn off an instance of an instrument from another
Do these decimals get added by default when each new instance is
created? I've used decimals before from the score but hadn't thought
of using them with midi. I'll give it a go.

Rory.


On 17 February 2011 17:20, Andres Cabrera  wrote:
> Hi,
>
> Use the decimal part of the instrument number to identify note instances.
>
> Cheers,
> Andres
>
> On Thu, Feb 17, 2011 at 4:48 PM, Rory Walsh  wrote:
>> No it's not a tongue twister. The following is a MIDI instrument. I
>> only want one note at a time, Users only have to press a note to start
>> it. Pressing another note should kill the previous instance but
>> shouldn't affect the current one. I know I could write a dedicated
>> MIDI event dispatcher but it sounds like overkill for what I want?
>>
>> instr 1
>> icnt active 1
>> print icnt
>> if(icnt>1) then
>> turnoff2 1, 1, 0
>> endif
>> k1 linenr 1, .01, 100, 0.01
>> a1 oscil p4, p5, 1
>> out a1*k1
>> endin
>>
>>
>> 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"
>
>


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"


Date2011-02-17 17:46
FromRory Walsh
SubjectRe: [Csnd] how to turn off an instance of an instrument from another
Maybe you could elaborate a little Andres. I can't see how your
suggestion will work with instances that are triggered by MIDI notes?



On 17 February 2011 17:33, Rory Walsh  wrote:
> Do these decimals get added by default when each new instance is
> created? I've used decimals before from the score but hadn't thought
> of using them with midi. I'll give it a go.
>
> Rory.
>
>
> On 17 February 2011 17:20, Andres Cabrera  wrote:
>> Hi,
>>
>> Use the decimal part of the instrument number to identify note instances.
>>
>> Cheers,
>> Andres
>>
>> On Thu, Feb 17, 2011 at 4:48 PM, Rory Walsh  wrote:
>>> No it's not a tongue twister. The following is a MIDI instrument. I
>>> only want one note at a time, Users only have to press a note to start
>>> it. Pressing another note should kill the previous instance but
>>> shouldn't affect the current one. I know I could write a dedicated
>>> MIDI event dispatcher but it sounds like overkill for what I want?
>>>
>>> instr 1
>>> icnt active 1
>>> print icnt
>>> if(icnt>1) then
>>> turnoff2 1, 1, 0
>>> endif
>>> k1 linenr 1, .01, 100, 0.01
>>> a1 oscil p4, p5, 1
>>> out a1*k1
>>> endin
>>>
>>>
>>> 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"
>>
>>
>


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"


Date2011-02-17 20:13
FromRory Walsh
SubjectRe: [Csnd] how to turn off an instance of an instrument from another
I've a few more queries about using turnoff2 and event together. I
would like instr1 to start instr1001 if it's not already playing, and
restart it if it is. After instr1 is called for the second time in the
code below it stops the current instance of 1001 and restarts 1001 but
I get no audio?



-odac


sr = 44100
nchnls = 1

instr 1
icnt active 1001
print icnt
if(icnt>0) then		;kill instance of 1001
turnoff2 1001, 2, 0
endif
event_i "i", 1001, 0, 100 ;start new instace
endin

instr 1001
a1 oscil 10000, 300, 1
out a1
endin



f1 0 1024 10 1
f0 3600
i1 0 1
i1 2 1




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"

Date2011-02-17 20:43
FromIain McCurdy
SubjectRE: [Csnd] how to turn off an instance of an instrument from another
Hi Rory,

I don't know whether this helps in your investigations but below is a rather ungraceful method I used to control polyphony but at the same time allow release stages complete. I'm sure you can improve upon it.

Iain

<CsoundSynthesizer>

<CsOptions>
-odevaudio -M0 -+rtmidi=virtual
</CsOptions>

<CsInstruments>

sr     =     44100 
ksmps     =     2
nchnls     =     1
0dbfs    =    1
   
gisine ftgen 0,0,4096,10,1
gkvoice init 1

instr    1    ; NOTE TRIGGERING INSTRUMENT
    icps    cpsmidi
    asig    subinstr    i(gkvoice)+1 , icps    ;CALL SOUND GENERATING INSTRUMENT AS A SUB-INSTRUMENT
    out    asig
endin

instr    2,3    ;SOUND GENERATING INSTRUMENTS
    gkvoice    init    (i(gkvoice)=1?2:1) ;FLIP VOICE ALLOCATION AT INIT TIME
if    gkvoice=p1-1    then ;IF THE OTHER VOICE IS NOW PLAYING...
    turnoff ;...TURN THIS INSTRUMENT OFF (ENVELOPE RELEASE STAGE WILL BE ALLOWED TO COMPLETE)
endif
    aenv     linsegr     0,0.01,1,0.4,0
    asig    poscil    0.1*aenv, p4, gisine
    out    asig            ;SEND AUDIO BACK TO INSTR 1
endin

</CsInstruments>
<CsScore>
f 0 3600
</CsScore>
</CsoundSynthesizer>



> Date: Thu, 17 Feb 2011 20:13:08 +0000
> From: rorywalsh@ear.ie
> To: csound@lists.bath.ac.uk
> Subject: Re: [Csnd] how to turn off an instance of an instrument from another
>
> I've a few more queries about using turnoff2 and event together. I
> would like instr1 to start instr1001 if it's not already playing, and
> restart it if it is. After instr1 is called for the second time in the
> code below it stops the current instance of 1001 and restarts 1001 but
> I get no audio?
>
> <CsoundSynthesizer>
> <CsOptions>
> -odac
> </CsOptions>
> <CsInstruments>
> sr = 44100
> nchnls = 1
>
> instr 1
> icnt active 1001
> print icnt
> if(icnt>0) then ;kill instance of 1001
> turnoff2 1001, 2, 0
> endif
> event_i "i", 1001, 0, 100 ;start new instace
> endin
>
> instr 1001
> a1 oscil 10000, 300, 1
> out a1
> endin
>
> </CsInstruments>
> <CsScore>
> f1 0 1024 10 1
> f0 3600
> i1 0 1
> i1 2 1
> </CsScore>
> </CsoundSynthesizer>
>
>
> 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"
>

Date2011-02-17 20:47
FromAndres Cabrera
SubjectRe: [Csnd] how to turn off an instance of an instrument from another
Hi,

Yes, you could do something like:

inote notnum
p3 = p3 + (notnum/100)

Cheers,
Andres

On Thu, Feb 17, 2011 at 5:46 PM, Rory Walsh  wrote:
> Maybe you could elaborate a little Andres. I can't see how your
> suggestion will work with instances that are triggered by MIDI notes?
>
>
>
> On 17 February 2011 17:33, Rory Walsh  wrote:
>> Do these decimals get added by default when each new instance is
>> created? I've used decimals before from the score but hadn't thought
>> of using them with midi. I'll give it a go.
>>
>> Rory.
>>
>>
>> On 17 February 2011 17:20, Andres Cabrera  wrote:
>>> Hi,
>>>
>>> Use the decimal part of the instrument number to identify note instances.
>>>
>>> Cheers,
>>> Andres
>>>
>>> On Thu, Feb 17, 2011 at 4:48 PM, Rory Walsh  wrote:
>>>> No it's not a tongue twister. The following is a MIDI instrument. I
>>>> only want one note at a time, Users only have to press a note to start
>>>> it. Pressing another note should kill the previous instance but
>>>> shouldn't affect the current one. I know I could write a dedicated
>>>> MIDI event dispatcher but it sounds like overkill for what I want?
>>>>
>>>> instr 1
>>>> icnt active 1
>>>> print icnt
>>>> if(icnt>1) then
>>>> turnoff2 1, 1, 0
>>>> endif
>>>> k1 linenr 1, .01, 100, 0.01
>>>> a1 oscil p4, p5, 1
>>>> out a1*k1
>>>> endin
>>>>
>>>>
>>>> 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"
>>>
>>>
>>
>
>
> 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"


Date2011-02-17 20:55
Fromjoachim heintz
SubjectRe: [Csnd] how to turn off an instance of an instrument from another
interesting example. seems like the turnoff2 statement and the event_i
conflict because of the i-rate? it works, if you trigger the
subinstrument at k-rate:



-odac


sr = 44100
nchnls = 1
gicnt init 1
instr 1
icnt active 1001
print icnt
if(icnt>0) then		;kill instance of 1001
turnoff2 1001, 2, 0
endif
event "i", 1001, 0, 100 ;start new instace
turnoff
endin
instr 1001
prints "turned on instance %d!\n", gicnt
gicnt = gicnt+1
a1 oscil 10000, 300, 1
out a1
endin


f1 0 1024 10 1
f0 3600
i1 0 1
i1 2 1



best -

	joachim

Am 17.02.2011 21:13, schrieb Rory Walsh:
> I've a few more queries about using turnoff2 and event together. I
> would like instr1 to start instr1001 if it's not already playing, and
> restart it if it is. After instr1 is called for the second time in the
> code below it stops the current instance of 1001 and restarts 1001 but
> I get no audio?
> 
> 
> 
> -odac
> 
> 
> sr = 44100
> nchnls = 1
> 
> instr 1
> icnt active 1001
> print icnt
> if(icnt>0) then		;kill instance of 1001
> turnoff2 1001, 2, 0
> endif
> event_i "i", 1001, 0, 100 ;start new instace
> endin
> 
> instr 1001
> a1 oscil 10000, 300, 1
> out a1
> endin
> 
> 
> 
> f1 0 1024 10 1
> f0 3600
> i1 0 1
> i1 2 1
> 
> 
> 
> 
> 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"

Date2011-02-17 21:06
FromRory Walsh
SubjectRe: [Csnd] how to turn off an instance of an instrument from another
That's nice, I hadn't thought of using k-rate and turnoff. Thanks to
everyone for their assistance.

Rory.


On 17 February 2011 20:55, joachim heintz  wrote:
> interesting example. seems like the turnoff2 statement and the event_i
> conflict because of the i-rate? it works, if you trigger the
> subinstrument at k-rate:
>
> 
> 
> -odac
> 
> 
> sr = 44100
> nchnls = 1
> gicnt init 1
> instr 1
> icnt active 1001
> print icnt
> if(icnt>0) then         ;kill instance of 1001
> turnoff2 1001, 2, 0
> endif
> event "i", 1001, 0, 100 ;start new instace
> turnoff
> endin
> instr 1001
> prints "turned on instance %d!\n", gicnt
> gicnt = gicnt+1
> a1 oscil 10000, 300, 1
> out a1
> endin
> 
> 
> f1 0 1024 10 1
> f0 3600
> i1 0 1
> i1 2 1
> 
> 
>
> best -
>
>        joachim
>
> Am 17.02.2011 21:13, schrieb Rory Walsh:
>> I've a few more queries about using turnoff2 and event together. I
>> would like instr1 to start instr1001 if it's not already playing, and
>> restart it if it is. After instr1 is called for the second time in the
>> code below it stops the current instance of 1001 and restarts 1001 but
>> I get no audio?
>>
>> 
>> 
>> -odac
>> 
>> 
>> sr = 44100
>> nchnls = 1
>>
>> instr 1
>> icnt active 1001
>> print icnt
>> if(icnt>0) then               ;kill instance of 1001
>> turnoff2 1001, 2, 0
>> endif
>> event_i "i", 1001, 0, 100 ;start new instace
>> endin
>>
>> instr 1001
>> a1 oscil 10000, 300, 1
>> out a1
>> endin
>>
>> 
>> 
>> f1 0 1024 10 1
>> f0 3600
>> i1 0 1
>> i1 2 1
>> 
>> 
>>
>>
>> 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"
>
>


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"