Csound Csound-dev Csound-tekno Search About

Re: Midictrl vs. Ctrl7

Date2005-10-25 20:56
From"Art Hunkins"
SubjectRe: Midictrl vs. Ctrl7
Istvan,

OK, I appreciate what you are saying now. We have the problem of "channel
clog." All sixteen channels are being occupied by instrument 1(-16), and
there is no channel left for any controller messages not destined for
instrument 1(-16).

Of course, the same situation would apply if your i100 were to be triggered
externally as a note by midi. As your example stands, no notes would go to
i100; they'd go, according to channel number to i1-16. So my answer to your
question below, is that (as the example stands), no midictrl messages would
go to i100 and I'd expect nothing to be printed. Rather, messages would go
to the appropriate (via channel = instrument number) i1-16; as they are not
involved in these instruments, the messages would be effectively lost.

My suggested solution to this "ambiguity" is of course to recode the
example. As it stands, midictrl is doing nothing, so it probably should be
coded into i1-16 somewhere, where it will have an effect. (An equally
obvious improvement might be to reduce i1-16 to i1, and send all notes in on
channel 1; this is what is clogging channels.)

Of course you could always ask, how could midictrl affect several
instruments (triggered by different midi channels) when it came in on a
single channel?

There are several ways to do this - including simply using ctrl7 instead of
midictrl. Ctrl7 would be used for more complex situations; midictrl only for
simpler ones.

My solution, however, would be to save a single channel (if it must be
unique) for midictrl (probably #16 - and i16) and use it only for control
messages - paralleling your example i100. As many controllers as you like
(up to 128) can come in on a single channel; you only *need* one.
Midi-activated instruments would simply avoid i16.

Yes, there is the generic problem with midi in Csound that you can't easily
have more than 16 channels simultaneously. This means "more than 16
instrument types or control destinations simultaneously."  If we want to use
the more basic opcodes, we'll just have to code around these limitations.

All this said, though I'd prefer to be able to use midictrl in notes called
by the orchestra (in simpler situations where ctrl7 is not necessary), I'm
happy enough with the addition/clarification to the manual. It might also be
helpful to note under ctrl7's doc that it can be used for score-triggered
events whereas midictrl cannot.

Art Hunkins

----- Original Message -----
From: "Istvan Varga" 
To: 
Sent: Tuesday, October 25, 2005 4:44 AM
Subject: Re: [Csnd] Midictrl vs. Ctrl7


> Art Hunkins wrote:
>
> > Could you give a simple example? I still don't follow you.
>
> sr = 44100
> ksmps = 10
> nchnls = 1
>
> instr 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16
> kcps  cpsmidib
> iamp  veloc
> a1    vco2 iamp * iamp, kcps
>        out a1
> endin
>
> instr 100
> kctl  midictrl 7
> printk2 kctl
> endin
>
> Now, assume that MIDI control change messages arrive on all channels,
> and instr 100 is activated from the score. Which channel should be used
> by midictrl in instr 100 and why ?
> --
> Send bugs reports to this list.
> To unsubscribe, send email to csound-unsubscribe@lists.bath.ac.uk

Date2005-10-25 21:04
FromIstvan Varga
SubjectRe: Midictrl vs. Ctrl7
Art Hunkins wrote:

> OK, I appreciate what you are saying now. We have the problem of "channel
> clog." All sixteen channels are being occupied by instrument 1(-16), and
> there is no channel left for any controller messages not destined for
> instrument 1(-16).

Of course, we can modify the example as shown below

sr = 44100
ksmps = 10
nchnls = 1

instr 100
kctl  midictrl 7
printk2 kctl
endin

so that now all MIDI channels use instr 100, but when instr 100 is
triggered from the score, which one of the 16 channels should be read
by midictrl ?
Anyway, what I am trying to explain is that when midictrl is used
in a score note, there is no universally reliable and unambiguous
way to select the correct channel number. That is why you should
use ctrl7 instead in non-MIDI activated notes. One could try to
implement obscure heuristics in midictrl to attempt to guess the
channel number, but it would not always work, and is just not really
worth the effort.

Date2005-10-25 23:57
FromDavid Akbari
SubjectRe: Midictrl vs. Ctrl7
On Oct 25, 2005, at 4:04 PM, Istvan Varga wrote:

> when midictrl is used
> in a score note, there is no universally reliable and unambiguous
> way to select the correct channel number. That is why you should
> use ctrl7 instead in non-MIDI activated notes.

This reminds me of a question I've been meaning to ask the list for 
some time.

Do program change messages change the instrument number MIDI is using? 
How are the defaults implemented in terms of MIDI messages? I noticed 
this as default behavior and I was wondering if anyone could shed some 
light on it!


-David

Date2005-10-26 14:33
FromIstvan Varga
SubjectRe: Midictrl vs. Ctrl7
David Akbari wrote:

> Do program change messages change the instrument number MIDI is using? 
> How are the defaults implemented in terms of MIDI messages? I noticed 
> this as default behavior and I was wondering if anyone could shed some 
> light on it!

By default, program changes assign the channel on which the message
has arrived to the same instrument number (program 1 will use instr 1,
etc.), assuming that the instrument exists, otherwise the program change
is ignored. This behavior can be modified by the use of the pgmassign
opcode that is normally called from the orchestra header:

     pgmassign ipgm, inst[, ichn]

ipgm: the program number (1 to 128), if zero then all
inst: instrument number, if zero then ignore program change
ichn: channel number (1 to 16), if zero then all channels
       defaults to zero

examples:

   pgmassign 0, 0

     ignore all program changes completely

   pgmassign 1, 2, 3

     if program change to 1 is received on channel 3, then channel
     3 will use instr 2