/* * hexter_deactivate * * implements LADSPA (*deactivate)() */ void hexter_deactivate(LADSPA_Handle handle) { hexter_instance_t *instance = (hexter_instance_t *)handle; hexter_instance_all_voices_off(instance); /* stop all sounds immediately */ }
/* * hexter_activate * * implements LADSPA (*activate)() */ static void hexter_activate(LADSPA_Handle handle) { hexter_instance_t *instance = (hexter_instance_t *)handle; hexter_instance_all_voices_off(instance); /* stop all sounds immediately */ instance->current_voices = 0; dx7_lfo_reset(instance); }
/* * hexter_instance_handle_monophonic */ char * hexter_instance_handle_monophonic(hexter_instance_t *instance, const char *value) { int mode = -1; if (!strcmp(value, "on")) mode = DSSP_MONO_MODE_ON; else if (!strcmp(value, "once")) mode = DSSP_MONO_MODE_ONCE; else if (!strcmp(value, "both")) mode = DSSP_MONO_MODE_BOTH; else if (!strcmp(value, "off")) mode = DSSP_MONO_MODE_OFF; if (mode == -1) { return dssp_error_message("error: monophonic value not recognized"); } if (mode == DSSP_MONO_MODE_OFF) { /* polyphonic mode */ instance->monophonic = 0; instance->max_voices = instance->polyphony; } else { /* one of the monophonic modes */ if (!instance->monophonic) { dssp_voicelist_mutex_lock(instance); hexter_instance_all_voices_off(instance); instance->max_voices = 1; instance->mono_voice = NULL; hexter_instance_clear_held_keys(instance); dssp_voicelist_mutex_unlock(instance); } instance->monophonic = mode; } return NULL; /* success */ }
/* * hexter_instance_control_change */ void hexter_instance_control_change(hexter_instance_t *instance, unsigned int param, signed int value) { switch (param) { /* these controls we act on always */ case MIDI_CTL_SUSTAIN: DEBUG_MESSAGE(DB_NOTE, " hexter_instance_control_change: got sustain control of %d\n", value); instance->cc[param] = value; if (value < 64) hexter_instance_damp_voices(instance); return; case MIDI_CTL_ALL_SOUNDS_OFF: instance->cc[param] = value; hexter_instance_all_voices_off(instance); return; case MIDI_CTL_RESET_CONTROLLERS: instance->cc[param] = value; hexter_instance_init_controls(instance); return; case MIDI_CTL_ALL_NOTES_OFF: instance->cc[param] = value; hexter_instance_all_notes_off(instance); return; } if (param == MIDI_CTL_REGIST_PARM_NUM_LSB || param == MIDI_CTL_REGIST_PARM_NUM_MSB) { /* reset NRPN numbers on receipt of RPN */ instance->cc[MIDI_CTL_NONREG_PARM_NUM_LSB] = 127; instance->cc[MIDI_CTL_NONREG_PARM_NUM_MSB] = 127; } if (instance->cc[param] == value) /* do nothing if control value has not changed */ return; instance->cc[param] = value; switch (param) { #ifdef HEXTER_DEBUG_CONTROL case MIDI_CTL_MSB_PAN: /* panning */ // hexter_instance_channel_pressure(instance, value); // { float f; // f = 52.75f / (instance->sample_rate * 0.001f * (float)value); // instance->amp_mod_max_slew = FLOAT_TO_FP(f); // printf("new amp_mod_max_slew, %dms => %f = %d\n", value, f, instance->amp_mod_max_slew); // } { if (value == 0) instance->ramp_duration = 1; else instance->ramp_duration = (int)(instance->sample_rate * 0.001f * (float)value); /* value ms ramp */ printf("new ramp_duration, %dms => %d frames\n", value, instance->ramp_duration); dx7_lfo_set_speed_x(instance); } break; case MIDI_CTL_MSB_EXPRESSION: /* 'expression' */ hexter_instance_key_pressure(instance, 60, value); break; #endif /* HEXTER_DEBUG_CONTROL */ case MIDI_CTL_MSB_MODWHEEL: case MIDI_CTL_LSB_MODWHEEL: hexter_instance_update_mod_wheel(instance); break; case MIDI_CTL_MSB_BREATH: case MIDI_CTL_LSB_BREATH: hexter_instance_update_breath(instance); break; case MIDI_CTL_MSB_FOOT: case MIDI_CTL_LSB_FOOT: hexter_instance_update_foot(instance); break; case MIDI_CTL_MSB_MAIN_VOLUME: case MIDI_CTL_LSB_MAIN_VOLUME: hexter_instance_update_volume(instance); break; case MIDI_CTL_MSB_GENERAL_PURPOSE1: case MIDI_CTL_MSB_GENERAL_PURPOSE2: case MIDI_CTL_MSB_GENERAL_PURPOSE3: case MIDI_CTL_MSB_GENERAL_PURPOSE4: hexter_instance_update_fc(instance, param - MIDI_CTL_MSB_GENERAL_PURPOSE1, value); break; case MIDI_CTL_GENERAL_PURPOSE5: case MIDI_CTL_GENERAL_PURPOSE6: hexter_instance_update_fc(instance, param - MIDI_CTL_GENERAL_PURPOSE5 + 4, value); break; /* handle NRPN as real-time parameter change */ case MIDI_CTL_MSB_DATA_ENTRY: case MIDI_CTL_LSB_DATA_ENTRY: if (instance->cc[MIDI_CTL_NONREG_PARM_NUM_MSB] != 127 && instance->cc[MIDI_CTL_NONREG_PARM_NUM_LSB] != 127) { hexter_instance_handle_nrpn(instance); } break; /* what others should we respond to? */ /* these we ignore (let the host handle): * BANK_SELECT_MSB * BANK_SELECT_LSB * RPN_MSB * RPN_LSB * (may want to eventually implement RPN (0, 0) Pitch Bend Sensitivity) */ } }