/* * hexter_instance_all_notes_off * * put all notes into the released state */ void hexter_instance_all_notes_off(hexter_instance_t* instance) { int i; dx7_voice_t *voice; /* reset the sustain controller */ instance->cc[MIDI_CTL_SUSTAIN] = 0; for (i = 0; i < instance->max_voices; i++) { voice = instance->voice[i]; if (_ON(voice) || _SUSTAINED(voice)) { dx7_voice_release_note(instance, voice); } } }
/* * nekobee_synth_all_notes_off * * put all notes into the released state */ void nekobee_synth_all_notes_off(nekobee_synth_t* synth) { int i; nekobee_voice_t *voice; /* reset the sustain controller */ synth->cc[MIDI_CTL_SUSTAIN] = 0; for (i = 0; i < synth->voices; i++) { //voice = synth->voice[i]; voice = synth->voice; if (_ON(voice) || _SUSTAINED(voice)) { nekobee_voice_release_note(synth, voice); } } }
/* * hexter_instance_note_off * * handle a note off message */ void hexter_instance_note_off(hexter_instance_t *instance, unsigned char key, unsigned char rvelocity) { int i; dx7_voice_t *voice; hexter_instance_remove_held_key(instance, key); for (i = 0; i < instance->max_voices; i++) { voice = instance->voice[i]; if (instance->monophonic ? (_PLAYING(voice)) : (_ON(voice) && (voice->key == key))) { DEBUG_MESSAGE(DB_NOTE, " hexter_instance_note_off: key %d rvel %d voice %d note id %d\n", key, rvelocity, i, voice->note_id); dx7_voice_note_off(instance, voice, key, rvelocity); } /* if voice on */ } /* for all voices */ }
/* * hexter_synth_alloc_voice */ static dx7_voice_t * hexter_synth_alloc_voice(hexter_instance_t* instance, unsigned char key) { int i; dx7_voice_t* voice; /* If there is another voice on the same key, advance it * to the release phase. Note that a DX7 doesn't do this, * but we do it here to keep our CPU usage low. */ for (i = 0; i < instance->max_voices; i++) { voice = instance->voice[i]; if (voice->key == key && (_ON(voice) || _SUSTAINED(voice))) { dx7_voice_release_note(instance, voice); } } voice = NULL; if (instance->current_voices < instance->max_voices) { /* check if there's an available voice */ for (i = 0; i < instance->max_voices; i++) { if (_AVAILABLE(instance->voice[i])) { voice = instance->voice[i]; break; } } /* if not, then stop a running voice. */ if (voice == NULL) { voice = hexter_synth_free_voice_by_kill(instance); } } else { /* at instance polyphony limit */ voice = hexter_synth_free_voice_by_kill(instance); } if (voice == NULL) { DEBUG_MESSAGE(DB_NOTE, " hexter_synth_alloc_voice: failed to allocate a voice (key=%d)\n", key); return NULL; } DEBUG_MESSAGE(DB_NOTE, " hexter_synth_alloc_voice: key %d voice %p\n", key, voice); return voice; }