Activating instruments with midi

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Activating instruments with midi

Lars Indrek Hansson
Hi everyone,
 
 
I wonder wether it´s possible to assign one midichannel to several instruments. The massign opcode doesn´t seem to
permit this. The manual tells nothing about this possibility and my attempts with one massign opcode for each instrument
hasn´t worked so far. Csound only assigns the last one of the massign opcodes.
 
In my case I would like to activate several instruments by only pushing one button on my Korg Nanokontrol and turning them off
with the same button in toggle mode.
 
I´ve tried by placing several "turnon" opcodes in one instrument and it works alright but how do I turn all the instruments off
exactly at the same time? Seems like it´s easier to turn instruments on in Csound than it is to turn them off!
 
Also one more question: I´ve tried to turn instruments on with the "FLkeyIn" opcode. In those cases the instruments durations have
been defined in the instruments themselves and that worked fine. But is there a way to make some kind of toggle-function with this opcode so that the user can define the duration himself?
 
All the best,
Lars Indrek Hansson
 
   
Reply | Threaded
Open this post in threaded view
|

Re: Activating instruments with midi

Joel Ross-2
This is odd, I was just reading through some threads in the list
archives describing this very problem.
I think the idea was floated of adding this function to massign, but I
don't know if it ever happened.
Alternatively it is possible to use the event and kschedwhen opcodes
to redirect the midi notes.

Regards,
-Joel

On 5 August 2010 18:03, Lars Indrek Hansson
<[hidden email]> wrote:

> Hi everyone,
>
>
> I wonder wether it´s possible to assign one midichannel to several
> instruments. The massign opcode doesn´t seem to
> permit this. The manual tells nothing about this possibility and my attempts
> with one massign opcode for each instrument
> hasn´t worked so far. Csound only assigns the last one of the massign
> opcodes.
>
> In my case I would like to activate several instruments by only pushing one
> button on my Korg Nanokontrol and turning them off
> with the same button in toggle mode.
>
> I´ve tried by placing several "turnon" opcodes in one instrument and it
> works alright but how do I turn all the instruments off
> exactly at the same time? Seems like it´s easier to turn instruments on in
> Csound than it is to turn them off!
>
> Also one more question: I´ve tried to turn instruments on with the "FLkeyIn"
> opcode. In those cases the instruments durations have
> been defined in the instruments themselves and that worked fine. But is
> there a way to make some kind of toggle-function with this opcode so that
> the user can define the duration himself?
>
> All the best,
> Lars Indrek Hansson
>
>
>


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 [hidden email] with body "unsubscribe csound"

Reply | Threaded
Open this post in threaded view
|

Re: Activating instruments with midi

joachim-3
In reply to this post by Lars Indrek Hansson
hi lars -

as you said, you can turn on any number of instruments from the  
instrument which is triggered by midi, via event_i.
because you can get the control cycle where the instrument is turned  
off, via release, you can turn off the subinstruments.
i made an example with negative p3 for switch on, and negative p1 for  
switch off. it should also work with the turnoff2 opcode.

best regards -

        joachim

<CsoundSynthesizer>
<CsOptions>
-Ma
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 32
nchnls = 1
0dbfs = 1
massign 0, 1
instr 1; turns on and off instr 2 and 3
event_i "i", 2, 0, -1
event_i "i", 3, 0, -1
kend release
if kend == 1 then
event "i", -2, 0, 1
event "i", -3, 0, 1
endif
endin
instr 2
printks "instr 2 playing!%n", 1
endin
instr 3
printks "instr 3 playing!%n", 1
endin
</CsInstruments>
<CsScore>
f 0 3600
e
</CsScore>
</CsoundSynthesizer>


Am 05.08.2010 um 18:03 schrieb Lars Indrek Hansson:

> Hi everyone,
>
>
> I wonder wether it´s possible to assign one midichannel to several  
> instruments. The massign opcode doesn´t seem to
> permit this. The manual tells nothing about this possibility and my  
> attempts with one massign opcode for each instrument
> hasn´t worked so far. Csound only assigns the last one of the  
> massign opcodes.
>
> In my case I would like to activate several instruments by only  
> pushing one button on my Korg Nanokontrol and turning them off
> with the same button in toggle mode.
>
> I´ve tried by placing several "turnon" opcodes in one instrument and  
> it works alright but how do I turn all the instruments off
> exactly at the same time? Seems like it´s easier to turn instruments  
> on in Csound than it is to turn them off!
>
> Also one more question: I´ve tried to turn instruments on with the  
> "FLkeyIn" opcode. In those cases the instruments durations have
> been defined in the instruments themselves and that worked fine. But  
> is there a way to make some kind of toggle-function with this opcode  
> so that the user can define the duration himself?
>
> All the best,
> Lars Indrek Hansson
>
>



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 [hidden email] with body "unsubscribe csound"

Reply | Threaded
Open this post in threaded view
|

Re: Re: Activating instruments with midi

Victor Lazzarini
Also, for polyphony, you might want to use fractional p1, so you can turn off the correct notes.
You can create fractional p1 numbers that are unique to MIDI note and channel (by encoding these
as part of the fractional number):

ip1 =  instr + ichan/100 + inote/100000
event_i "i", ip1, 0, -1 ...
...
if kend == 1 then
event "i", -ip1, 0, 1
...
endif

----- Original Message -----
From: joachim heintz <[hidden email]>
Date: Thursday, August 5, 2010 7:40 pm
Subject: [Csnd] Re: Activating instruments with midi
To: [hidden email]

> hi lars -
>
> as you said, you can turn on any number of instruments from
> the 
> instrument which is triggered by midi, via event_i.
> because you can get the control cycle where the instrument is
> turned 
> off, via release, you can turn off the subinstruments.
> i made an example with negative p3 for switch on, and negative
> p1 for 
> switch off. it should also work with the turnoff2 opcode.
>
> best regards -
>
> joachim
>
> <CsoundSynthesizer>
> <CsOptions>
> -Ma
> </CsOptions>
> <CsInstruments>
> sr = 44100
> ksmps = 32
> nchnls = 1
> 0dbfs = 1
> massign 0, 1
> instr 1; turns on and off instr 2 and 3
> event_i "i", 2, 0, -1
> event_i "i", 3, 0, -1
> kend release
> if kend == 1 then
> event "i", -2, 0, 1
> event "i", -3, 0, 1
> endif
> endin
> instr 2
> printks "instr 2 playing!%n", 1
> endin
> instr 3
> printks "instr 3 playing!%n", 1
> endin
> </CsInstruments>
> <CsScore>
> f 0 3600
> e
> </CsScore>
> </CsoundSynthesizer>
>
>
> Am 05.08.2010 um 18:03 schrieb Lars Indrek Hansson:
>
> > Hi everyone,
> >
> >
> > I wonder wether it´s possible to assign one midichannel to
> several 
> > instruments. The massign opcode doesn´t seem to
> > permit this. The manual tells nothing about this possibility
> and my 
> > attempts with one massign opcode for each instrument
> > hasn´t worked so far. Csound only assigns the last one of
> the 
> > massign opcodes.
> >
> > In my case I would like to activate several instruments by
> only 
> > pushing one button on my Korg Nanokontrol and turning them off
> > with the same button in toggle mode.
> >
> > I´ve tried by placing several "turnon" opcodes in one
> instrument and 
> > it works alright but how do I turn all the instruments off
> > exactly at the same time? Seems like it´s easier to turn
> instruments 
> > on in Csound than it is to turn them off!
> >
> > Also one more question: I´ve tried to turn instruments on with
> the 
> > "FLkeyIn" opcode. In those cases the instruments durations have
> > been defined in the instruments themselves and that worked
> fine. But 
> > is there a way to make some kind of toggle-function with this
> opcode 
> > so that the user can define the duration himself?
> >
> > All the best,
> > Lars Indrek Hansson
> >
> >
>
>
>
> 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 [hidden email] with body
> "unsubscribe csound"
>

Dr Victor Lazzarini, Senior Lecturer, Dept. of Music,
National University of Ireland, Maynooth
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Activating instruments with midi

Doctor B
Dear Lars, Joachim, and Victor,

Thanks for this important "request" and for these wonderful, insightful, and brilliant solutions.

but

These work-arounds are quite advanced and complex.

Wouldn't it be really great - intuitive - simple - obvious - cool - and incredibly useful and practical, if there was a new "massign" opcode (massign2 or mlayer) that let the user layer the MIDI instruments in their orchestra (like one can do on most commercial MIDI workstations, and could do from all the way back to 1995 or so.)

This instrument opcode might have a parameter for the master channel, followed by all the instrument numbers that were controlled/triggered/played from that MIDI channel
AND maybe even...
another parameter that would scale the relative velocities of each instrument in the layer (so that once could initialize a rough "global mix" of the layers)

ALSO

Along these lines, it would be great to see/use a MIDI layering companion to the "ctlinit" opcode, so that, controllers transmitted on one channel from a MasterKeyboard could act as "master controllers" and control multiple instruments (ctllayer or ctlinit2)

Would these opcode additions be possible?  

They would make a big difference in how one would use, control, and perform with Csound.

-dB 


On Thu, Aug 5, 2010 at 7:09 PM, <[hidden email]> wrote:
Also, for polyphony, you might want to use fractional p1, so you can turn off the correct notes.
You can create fractional p1 numbers that are unique to MIDI note and channel (by encoding these
as part of the fractional number):

ip1 =  instr + ichan/100 + inote/100000
event_i "i", ip1, 0, -1 ...
...
if kend == 1 then
event "i", -ip1, 0, 1
...
endif


----- Original Message -----
From: joachim heintz <[hidden email]>
Date: Thursday, August 5, 2010 7:40 pm
Subject: [Csnd] Re: Activating instruments with midi
To: [hidden email]

> hi lars -
>
> as you said, you can turn on any number of instruments from
> the 
> instrument which is triggered by midi, via event_i.
> because you can get the control cycle where the instrument is
> turned 
> off, via release, you can turn off the subinstruments.
> i made an example with negative p3 for switch on, and negative
> p1 for 
> switch off. it should also work with the turnoff2 opcode.
>

> best regards -
>
> joachim
>
> <CsoundSynthesizer>
> <CsOptions>
> -Ma
> </CsOptions>
> <CsInstruments>
> sr = 44100
> ksmps = 32
> nchnls = 1
> 0dbfs = 1
> massign 0, 1
> instr 1; turns on and off instr 2 and 3
> event_i "i", 2, 0, -1
> event_i "i", 3, 0, -1
> kend release
> if kend == 1 then
> event "i", -2, 0, 1
> event "i", -3, 0, 1
> endif
> endin
> instr 2
> printks "instr 2 playing!%n", 1
> endin
> instr 3
> printks "instr 3 playing!%n", 1
> endin
> </CsInstruments>
> <CsScore>
> f 0 3600
> e
> </CsScore>
> </CsoundSynthesizer>
>
>
> Am 05.08.2010 um 18:03 schrieb Lars Indrek Hansson:
>
> > Hi everyone,
> >
> >
> > I wonder wether it´s possible to assign one midichannel to
> several 
> > instruments. The massign opcode doesn´t seem to
> > permit this. The manual tells nothing about this possibility
> and my 
> > attempts with one massign opcode for each instrument
> > hasn´t worked so far. Csound only assigns the last one of
> the 
> > massign opcodes.
> >
> > In my case I would like to activate several instruments by
> only 
> > pushing one button on my Korg Nanokontrol and turning them off
> > with the same button in toggle mode.
> >
> > I´ve tried by placing several "turnon" opcodes in one
> instrument and 
> > it works alright but how do I turn all the instruments off
> > exactly at the same time? Seems like it´s easier to turn
> instruments 
> > on in Csound than it is to turn them off!
> >
> > Also one more question: I´ve tried to turn instruments on with
> the 
> > "FLkeyIn" opcode. In those cases the instruments durations have
> > been defined in the instruments themselves and that worked
> fine. But 
> > is there a way to make some kind of toggle-function with this
> opcode 
> > so that the user can define the duration himself?
> >
> > All the best,
> > Lars Indrek Hansson
> >
> >
>
>
>
> 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 [hidden email] with body
> "unsubscribe csound"
>

Dr Victor Lazzarini, Senior Lecturer, Dept. of Music,
National University of Ireland, Maynooth

Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Activating instruments with midi

joachim-3
In reply to this post by Victor Lazzarini
very nice. so this could be a way to do it with a UDO, and a function  
table containing the instrument numbers you want to trigger:

<CsoundSynthesizer>
<CsOptions>
-Ma
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 32
nchnls = 1
0dbfs = 1

           massign   0, 1; assign all incoming midi to instr 1
giInstrs  ftgen     0, 0, -5, -2, 2, 3, 4, 10, 100; instruments to be  
triggered

   opcode MidiTrig, 0, io
;triggers the first inum instruments in the function table ifn by a  
midi event, with fractional numbers containing channel and note number  
information
ifn, inum  xin; if inum=0 or not given, all instrument numbers in ifn  
are triggered
inum      =         (inum == 0 ? ftlen(ifn) : inum)
inote     notnum
ichn      midichn
iturnon   =         0
turnon:
iinstrnum tab_i     iturnon, ifn
  if iinstrnum > 0 then
ifracnum  =         iinstrnum + ichn/100 + inote/100000
           event_i   "i", ifracnum, 0, -1
  endif
           loop_lt   iturnon, 1, inum, turnon
kend      release
  if kend == 1 then
kturnoff  =         0
turnoff:
kinstrnum tab       kturnoff, ifn
   if kinstrnum > 0 then
kfracnum  =         kinstrnum + ichn/100 + inote/100000
           event     "i", -kfracnum, 0, 1
           loop_lt   kturnoff, 1, inum, turnoff
   endif
  endif
   endop

   instr 1; global midi instrument
           MidiTrig  giInstrs, 2; triggers the first two instruments  
in the giInstrs table
   endin

   instr 2
ichn      =         int(frac(p1)*100)
inote     =         round(frac(frac(p1)*100)*1000)
           prints    "instr %f: ichn = %f, inote = %f%n", p1, ichn,  
inote
           printks   "instr %f playing!%n", 1, p1
   endin

   instr 3
ichn      =         int(frac(p1)*100)
inote     =         round(frac(frac(p1)*100)*1000)
           prints    "instr %f: ichn = %f, inote = %f%n", p1, ichn,  
inote
           printks   "instr %f playing!%n", 1, p1
   endin


</CsInstruments>
<CsScore>
f 0 36000
e
</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 [hidden email] with body "unsubscribe csound"

Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Re: Activating instruments with midi

joachim-3
( i was referring to victor's fractional instrument numbers - didn't  
read richard's mail before)


Am 06.08.2010 um 14:03 schrieb joachim heintz:

> very nice. so this could be a way to do it with a UDO, and a  
> function table containing the instrument numbers you want to trigger:
>
> <CsoundSynthesizer>
> <CsOptions>
> -Ma
> </CsOptions>
> <CsInstruments>
> sr = 44100
> ksmps = 32
> nchnls = 1
> 0dbfs = 1
>
>          massign   0, 1; assign all incoming midi to instr 1
> giInstrs  ftgen     0, 0, -5, -2, 2, 3, 4, 10, 100; instruments to  
> be triggered
>
>  opcode MidiTrig, 0, io
> ;triggers the first inum instruments in the function table ifn by a  
> midi event, with fractional numbers containing channel and note  
> number information
> ifn, inum  xin; if inum=0 or not given, all instrument numbers in  
> ifn are triggered
> inum      =         (inum == 0 ? ftlen(ifn) : inum)
> inote     notnum
> ichn      midichn
> iturnon   =         0
> turnon:
> iinstrnum tab_i     iturnon, ifn
> if iinstrnum > 0 then
> ifracnum  =         iinstrnum + ichn/100 + inote/100000
>          event_i   "i", ifracnum, 0, -1
> endif
>          loop_lt   iturnon, 1, inum, turnon
> kend      release
> if kend == 1 then
> kturnoff  =         0
> turnoff:
> kinstrnum tab       kturnoff, ifn
>  if kinstrnum > 0 then
> kfracnum  =         kinstrnum + ichn/100 + inote/100000
>          event     "i", -kfracnum, 0, 1
>          loop_lt   kturnoff, 1, inum, turnoff
>  endif
> endif
>  endop
>
>  instr 1; global midi instrument
>          MidiTrig  giInstrs, 2; triggers the first two instruments  
> in the giInstrs table
>  endin
>
>  instr 2
> ichn      =         int(frac(p1)*100)
> inote     =         round(frac(frac(p1)*100)*1000)
>          prints    "instr %f: ichn = %f, inote = %f%n", p1, ichn,  
> inote
>          printks   "instr %f playing!%n", 1, p1
>  endin
>
>  instr 3
> ichn      =         int(frac(p1)*100)
> inote     =         round(frac(frac(p1)*100)*1000)
>          prints    "instr %f: ichn = %f, inote = %f%n", p1, ichn,  
> inote
>          printks   "instr %f playing!%n", 1, p1
>  endin
>
>
> </CsInstruments>
> <CsScore>
> f 0 36000
> e
> </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 [hidden email] 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 [hidden email] with body "unsubscribe csound"

Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Re: Activating instruments with midi

Doctor B
In reply to this post by joachim-3
Joachim,

This MIDI layering UDO is really super.  Thanks for developing and sharing it with us.
It would be great to have an actual sounding version of this included under either the 
"useful" or "miscellaneous"  menus in the next release of QuteCsound.

Dr. B.


On Fri, Aug 6, 2010 at 8:03 AM, joachim heintz <[hidden email]> wrote:
<CsoundSynthesizer>
<CsOptions>
-Ma
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 32
nchnls = 1
0dbfs = 1

         massign   0, 1; assign all incoming midi to instr 1
giInstrs  ftgen     0, 0, -5, -2, 2, 3, 4, 10, 100; instruments to be triggered

 opcode MidiTrig, 0, io
;triggers the first inum instruments in the function table ifn by a midi event, with fractional numbers containing channel and note number information
ifn, inum  xin; if inum=0 or not given, all instrument numbers in ifn are triggered
inum      =         (inum == 0 ? ftlen(ifn) : inum)
inote     notnum
ichn      midichn
iturnon   =         0
turnon:
iinstrnum tab_i     iturnon, ifn
 if iinstrnum > 0 then
ifracnum  =         iinstrnum + ichn/100 + inote/100000
         event_i   "i", ifracnum, 0, -1
 endif
         loop_lt   iturnon, 1, inum, turnon

kend      release
 if kend == 1 then
kturnoff  =         0
turnoff:
kinstrnum tab       kturnoff, ifn
 if kinstrnum > 0 then
kfracnum  =         kinstrnum + ichn/100 + inote/100000
         event     "i", -kfracnum, 0, 1
         loop_lt   kturnoff, 1, inum, turnoff
 endif
 endif
 endop

 instr 1; global midi instrument
         MidiTrig  giInstrs, 2; triggers the first two instruments in the giInstrs table
 endin

 instr 2
ichn      =         int(frac(p1)*100)
inote     =         round(frac(frac(p1)*100)*1000)
         prints    "instr %f: ichn = %f, inote = %f%n", p1, ichn, inote
         printks   "instr %f playing!%n", 1, p1
 endin

 instr 3
ichn      =         int(frac(p1)*100)
inote     =         round(frac(frac(p1)*100)*1000)
         prints    "instr %f: ichn = %f, inote = %f%n", p1, ichn, inote
         printks   "instr %f playing!%n", 1, p1
 endin


</CsInstruments>
<CsScore>
f 0 36000
e
</CsScore>
</CsoundSynthesizer>