void start_note(int channel, int note, int vel) { int i; #ifdef WANT_AWE32 if (card_info.synth_type == SYNTH_TYPE_SAMPLE && card_info.synth_subtype == SAMPLE_TYPE_AWE32) { SEQ_START_NOTE(synth_dev,channel,note,vel); } else #endif { for (i=0; i<card_info.nr_voices;i++) if ((voices[i].note == -1) && (voices[i].channel == -1)) break; if (i != card_info.nr_voices) { voices[i].note = note; voices[i].channel = channel; if (((1<<channel) & drumflag)) /* drum note */ { SEQ_SET_PATCH(synth_dev, i, note + 128); } else { SEQ_SET_PATCH(synth_dev, i, program[channel]); } SEQ_START_NOTE(synth_dev, i, note, vel); } } }
static void adlib_start_note(int chn, int note, int velocity) { int free; struct timeval now; if (velocity == 0) { adlib_stop_note(chn, note, velocity); return; } gettimeofday(&now, NULL); if (free_voices <= 0) free = adlib_kill_one_note(chn); else for (free = 0; free < ADLIB_VOICES ; free++) if (oper_chn[free] == 255) break; /* printf("play operator %d/%d: %d %d %d\n", free, free_voices, chn, note, velocity); */ oper_chn[free] = chn; oper_note[free] = note; note_time[free] = now.tv_sec * 1000000 + now.tv_usec; free_voices--; SEQ_SET_PATCH(dev, free, instr[chn]); SEQ_START_NOTE(dev, free, note, velocity); SEQ_DUMPBUF(); }
void do_midi_msg(int synthno, unsigned char *msg, int mlen) { switch (msg[0] & 0xf0) { case 0x90: if (msg[2] != 0) { STORE(SEQ_START_NOTE(synthno, msg[0] & 0x0f, msg[1], msg[2])); break; } msg[2] = 64; case 0x80: STORE(SEQ_STOP_NOTE(synthno, msg[0] & 0x0f, msg[1], msg[2])); break; case 0xA0: STORE(SEQ_KEY_PRESSURE(synthno, msg[0] & 0x0f, msg[1], msg[2])); break; case 0xB0: STORE(SEQ_CONTROL(synthno, msg[0] & 0x0f, msg[1], msg[2])); break; case 0xC0: STORE(SEQ_SET_PATCH(synthno, msg[0] & 0x0f, msg[1])); break; case 0xD0: STORE(SEQ_CHN_PRESSURE(synthno, msg[0] & 0x0f, msg[1])); break; case 0xE0: STORE(SEQ_BENDER(synthno, msg[0] & 0x0f, (msg[1] & 0x7f) | ((msg[2] & 0x7f) << 7))); break; default: /* printk( "MPU: Unknown midi channel message %02x\n", msg[0]); */ ; } }
/* trigger the midi note, on channel, with velocity */ virtual void trigger( char note, char channel = 0x0, char velocity = 0x40 ) { if (mFile == -1) return; SEQ_START_NOTE( mDevice, channel, note, velocity ); SEQ_DUMPBUF(); // write immediately }
static int mlib_store_chn_voice_msg (mlib_desc * desc, mlib_track * track, int *optr, unsigned char *evbuf, int len) { unsigned char chn, pgm, note, vel; chn = evbuf[0] & 0x0f; /* Midi channel */ if (track->init_chn == -1) track->init_chn = chn; else if (chn != track->init_chn) track->flags |= TRK_MULTICHN; track->chnmask |= (1 << chn); /* Update channel mask */ switch (evbuf[0] & 0xf0) { case 0x90: /* Note on */ vel = evbuf[2]; note = evbuf[1]; if (vel != 0) { /* Velocity given -> true note on event */ track->flags |= TRK_NOTES; if (note > track->max_note) track->max_note = note; if (note < track->min_note) track->min_note = note; if (track->noteon_time == -1) track->noteon_time = track->current_time; if (vel != 64) track->flags |= TRK_VEL_NOTEON; STORE (SEQ_START_NOTE (0, chn, note, vel)); if (chn == 9) /* Drum channel */ track->drum_map[note] = note; break; /* NOTE! The break is here, not later */ } /* Note on with zero G -> note off with vel=64. */ /* Fall to the next case */ evbuf[2] = 64; /* Velocity for the note off handler */ case 0x80: /* Note off */ vel = evbuf[2]; note = evbuf[1]; if (vel != 64) track->flags |= TRK_VEL_NOTEOFF; STORE (SEQ_STOP_NOTE (0, chn, note, vel)); break; case 0xA0: /* Polyphonic key pressure/Aftertouch */ track->flags |= TRK_POLY_AFTERTOUCH | TRK_AFTERTOUCH; STORE (SEQ_KEY_PRESSURE (0, chn, note, vel)); break; case 0xB0: /* Control change */ { unsigned short value = evbuf[2]; /* Incorrect */ unsigned char ctl = evbuf[1]; track->flags |= TRK_CONTROLS; STORE (SEQ_CONTROL (0, chn, ctl, value)); } break; case 0xC0: /* Program change */ pgm = evbuf[1]; if (track->init_pgm == -1) track->init_pgm = pgm; else if (pgm != track->init_pgm) track->flags |= TRK_MULTIPGM; track->pgm_map[pgm] = pgm; STORE (SEQ_SET_PATCH (0, chn, pgm)); break; case 0xD0: /* Channel pressure/Aftertouch */ track->flags |= TRK_AFTERTOUCH; STORE (SEQ_CHN_PRESSURE (0, chn, evbuf[1])); break; case 0xE0: /* Pitch bend change */ track->flags |= TRK_BENDER; STORE (SEQ_BENDER (0, chn, (evbuf[1] & 0x7f) + ((evbuf[2] & 0x7f) << 7))); break; default: mlib_seterr ("Internal error: Unexpected midi event"); fprintf (stderr, "Internal error: Unexpected midi event %02x\n", evbuf[0]); return 0; } return 1; }
void do_midi_msg(int synthno, unsigned char *msg, int mlen) { switch (msg[0] & 0xf0) { case 0x90: if (msg[2] != 0) { STORE(SEQ_START_NOTE(synthno, msg[0] & 0x0f, msg[1], msg[2])); break; } msg[2] = 64; case 0x80: STORE(SEQ_STOP_NOTE(synthno, msg[0] & 0x0f, msg[1], msg[2])); break; case 0xA0: STORE(SEQ_KEY_PRESSURE(synthno, msg[0] & 0x0f, msg[1], msg[2])); break; case 0xB0: STORE(SEQ_CONTROL(synthno, msg[0] & 0x0f, msg[1], msg[2])); break; case 0xC0: STORE(SEQ_SET_PATCH(synthno, msg[0] & 0x0f, msg[1])); break; case 0xD0: STORE(SEQ_CHN_PRESSURE(synthno, msg[0] & 0x0f, msg[1])); break; case 0xE0: STORE(SEQ_BENDER(synthno, msg[0] & 0x0f, (msg[1] & 0x7f) | ((msg[2] & 0x7f) << 7))); break; default: #ifdef CONFIG_DEBUG_PRINTK /* printk( "MPU: Unknown midi channel message %02x\n", msg[0]); */ #else /* ; #endif ; } } EXPORT_SYMBOL(do_midi_msg); static void midi_outc(int midi_dev, int data) { int timeout; for (timeout = 0; timeout < 3200; timeout++) if (midi_devs[midi_dev]->outputc(midi_dev, (unsigned char) (data & 0xff))) { if (data & 0x80) /* * Status byte */ prev_out_status[midi_dev] = (unsigned char) (data & 0xff); /* * Store for running status */ return; /* * Mission complete */ } /* * Sorry! No space on buffers. */ #ifdef CONFIG_DEBUG_PRINTK printk("Midi send timed out\n"); #else ; #endif }