void stop_all() { int i; #ifdef WANT_AWE32 int j; if (card_info.synth_type == SYNTH_TYPE_SAMPLE && card_info.synth_subtype == SAMPLE_TYPE_AWE32) { for (i=0; i<16;i++) for (j=0;j<128;j++) SEQ_STOP_NOTE(synth_dev,i,j,0); } else #endif #ifdef WANT_MPU401 if (card_info.synth_type==SYNTH_TYPE_MIDI) { MIDI_RESET; SEQ_DUMPBUF(); } else #endif { for (i=0; i<card_info.nr_voices;i++) SEQ_STOP_NOTE(synth_dev,i,voices[i].note,0); } }
int adlib_stop_note(int chn, int note, int velocity) { int i, op=255; for (i=0;i<ADLIB_VOICES && op==255;i++) { if (oper_chn[i] == chn) if (oper_note[i] == note) op=i; } if (op==255) { printf ("can't stop.. chn %d %d %d\n", chn, note, velocity); return 255; /* not playing */ } SEQ_STOP_NOTE(dev, op, note, velocity); SEQ_DUMPBUF(); oper_chn[op] = 255; oper_note[op] = 255; note_time[op] = 0; free_voices++; return op; }
void cut_trough() { int i; int j; if (card_info.synth_type == SYNTH_TYPE_SAMPLE && card_info.synth_subtype == SAMPLE_TYPE_AWE32) { for (i=4; i<16;i++) for (j=4;j<32;j++) SEQ_STOP_NOTE(synth_dev,i,j,0); } else { for (i=0; i<card_info.nr_voices;i++) SEQ_STOP_NOTE(synth_dev,i,voices[i].note,0); } }
void stop_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_STOP_NOTE(synth_dev,channel,note,vel); } else #endif { for (i=0; i<card_info.nr_voices;i++) if ((voices[i].note == note) && (voices[i].channel == channel)) break; if (i != card_info.nr_voices) { voices[i].note = -1; voices[i].channel = -1; SEQ_STOP_NOTE(synth_dev,i,note,vel); } } }
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]); */ ; } }
int adlib_kill_one_note(int chn) { int oldest = 255, i = 255; long time = 0; if (free_voices >= ADLIB_VOICES) { printf("Free list empty but no notes playing\n"); return 255; } /* No notes playing */ for (i = 0; i < ADLIB_VOICES ; i++) { if (oper_chn[i] != chn) continue; if (note_time[i] == 0) continue; if (time == 0) { time = note_time[i]; oldest = i; continue; } if (note_time[i] < time) { time = note_time[i]; oldest = i; } } /* printf("Killing chn %d, oper %d\n", chn, oldest); */ if (oldest == 255) return 255; /* Was already stopped. Why? */ SEQ_STOP_NOTE(dev, oldest, oper_note[oldest], 0); SEQ_DUMPBUF(); oper_chn[oldest] = 255; oper_note[oldest] = 255; note_time[oldest] = 0; free_voices++; return oldest; }
/* release the midi note, velocity is ignored and should be 0 */ virtual void release( char note, char channel = 0x0, char velocity = 0x00 ) { if (mFile == -1) return; SEQ_STOP_NOTE( mDevice, channel, note, 0 ); 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 }