Csound Csound-dev Csound-tekno Search About

Re: hidden MIDI functions

Date1997-02-12 12:32
FromDavide Giacopello
SubjectRe: hidden MIDI functions
Mike Berry wrote:
> 
>         Does anyone have documentation on the "hidden" MIDI functions?
> After poking around in the MIDI parser I found that there are some
> functions to set global values, like pitch bend range, using a combination
> of controller 101 and controller 6.  But there is very little in the way
> of comments as to how this is meant to be used.

These are General Midi command sequences to set these parameters... 
unfortunately I don't have a documentation, but on some MIDI files
they are present ... 

>         I want to update the MIDI interpreters to include some optional
> scaling and preset values, for, among other things, setting the pitch bend
> range in the ***midib functions.  

> For the sake of cleanliness and speed, I
> was going to remove these hidden functions and update the documentation on
> MIDI.  This shouldn't break anyone's orchestras since this aren't instr
> functions anyway.  But if there is anyone who does use these hidden
> functions, please let me know.

I hope I'm still in time... Mike, please leave that code there!! I'm using
that ... very often :)

I would also suggest some improvements to the MIDI controllers code...

In MIDIRECV.C:

            if (n == 121) {
                register short *sp = chn->ctl_byt;
                register float *fp = chn->ctl_val;
                register short nn = 120;
                do {
                    *sp++ = 0;     /* reset all controllers to 0 */
                    *fp++ = 0.;
                } while (--nn);          /* exceptions:  */
                chn->ctl_byt[8] = 64;    /*      BALANCE */
                chn->ctl_val[8] = 64.;
                chn->ctl_byt[10] = 64;   /*      PAN     */
                chn->ctl_val[10] = 64.;

Add the following lines too:
        chn->ctl_byt[7] = 100;   /*      VOLUME */
        chn->ctl_val[7] = 100;

        chn->ctl_byt[11] = 100;  /*      EXPRESSION  */
        chn->ctl_val[11] = 100;

Otherwise, the volume and expression controllers are not initialized to
the correct values (as in GM specifications) and this would bring to strange 
results (VOLUME initialized to zero means... you won't hear anything until
you send an explicit controller 7 [volume])

and on the line which reads...

  chn->pbensens = 1.0;

  (just after the label "alcon")

I would suggest:

  chn->pbensens = 2.0;

... since (if I remember correctly) the range of the GM pitch bend is
usually initialized to 2 semitones. 

Warning: I based these changes on version 3.42 (15 aug 1996), I don't know
 if in the meantime something changed...

I would also suggest to automatically assign a predefined instrument number
to the channel 10 (the DRUM channel). Example: if Csound always assigns instr
128 to chn 10, we will be always sure that we can make a drum instrument with
number 128... without need of modifying the MIDI file to do an explicit program
change to our drum instrument on channel 10... 

These are only humble ideas :) Please don't flame me if they are stupid :)

Bye :)


Date1997-02-12 16:54
FromMike Berry
SubjectRe: hidden MIDI functions
	Here's what I did (but can be subject to alteration).
1) I removed the pitchbend sensitivity controller and moved that to an
optional i field on the xxxmidib opcodes.  Thus:
kcps	cpsmidib	6
gives you a +/- 6 semitone bend range.  If you don't give a field it
defaults to 1, which is what it did before.
2) I fixed a bug which prevented an opcode with only optional parameters.
3) I took out the coarse and fine tuning controls and the volume control
which did not seem to be connected to anything.  Please correct me if I am
wrong here.  There is a global variable Volume but it is never used, at
least in our version.  Controller 7 can still be used for volume control.

	Resetting the controllers is a good idea and I will add it.  As
for emulating GM, I am not in favor of it.  It smells to me too much
specification that is hidden from the user.  Its not hard to make your
orchestra behave like GM if you want, but reserving one of the 16
available channels just for drums rubs me wrong, as one who nevers seems
to end up with any drums.

Mike Berry
mikeb@mills.edu