void HelmVoiceHandler::init() { // Create modulation and pitch wheels. mod_wheel_amount_ = new SmoothValue(0); pitch_wheel_amount_ = new SmoothValue(0); mod_sources_["pitch_wheel"] = pitch_wheel_amount_->output(); mod_sources_["mod_wheel"] = mod_wheel_amount_->output(); // Create all synthesizer voice components. createArticulation(note(), velocity(), voice_event()); createOscillators(current_frequency_->output(), amplitude_envelope_->output(Envelope::kFinished)); createModulators(amplitude_envelope_->output(Envelope::kFinished)); createFilter(osc_feedback_->output(0), note_from_center_->output(), amplitude_envelope_->output(Envelope::kFinished), voice_event()); Value* aftertouch_value = new Value(); aftertouch_value->plug(aftertouch()); addProcessor(aftertouch_value); mod_sources_["aftertouch"] = aftertouch_value->output(); output_->plug(formant_container_, 0); output_->plug(amplitude_, 1); addProcessor(output_); addGlobalProcessor(pitch_wheel_amount_); addGlobalProcessor(mod_wheel_amount_); setVoiceKiller(amplitude_envelope_->output(Envelope::kValue)); HelmModule::init(); }
void MMidi::midiHandler() { //midiTime = millis(); uint8_t midiChannel = (midiBuffer[0] & 0x0F); switch(midiBuffer[0] & 0xF0) { // bit mask with &0xF0 ? case 0x80: noteOff (midiBuffer[0] & 0x0F, // midi channel 0-16 midiBuffer[1] & 0x7F, // note value 0-127 midiBuffer[2] & 0x7F); // note velocity 0-127 break; case 0x90: noteOn (midiBuffer[0] & 0x0F, // midi channel 0-16 midiBuffer[1] & 0x7F, // note value 0-127 midiBuffer[2] & 0x7F); // note velocity 0-127 break; case 0xA0: aftertouch (midiBuffer[0] & 0x0F, // midi channel 0-16 midiBuffer[1] & 0x7F, // note value 0-127 midiBuffer[2] & 0x7F);// note velocity 0-127 break; case 0xB0: controller (midiBuffer[0] & 0x0F, // midi channel 0-16 midiBuffer[1] & 0x7F, // controller number 0-127 midiBuffer[2] & 0x7F);// controller value 0-127 break; case 0xC0: programChange (midiBuffer[0] & 0x0F, // midi channel 0-16 midiBuffer[1] & 0x7F); // program number 0-127 break; case 0xD0: channelPressure (midiBuffer[0] & 0x0F, // midi channel 0-16 midiBuffer[1] & 0x7F); // pressure amount 0-127 break; case 0xE0: pitchWheel (midiBuffer[0] & 0x0F, // midi channel 0-16 midiBuffer[1] & 0x7F, // higher bits 0-6 midiBuffer[2] & 0x7F);// lower bits 7-13 break; default: break; } }
inline uint16_t value() const { switch (type()) { case MIDI_CMD_CONTROL: return cc_value(); case MIDI_CMD_BENDER: return pitch_bender_value(); case MIDI_CMD_NOTE_PRESSURE: return aftertouch(); case MIDI_CMD_CHANNEL_PRESSURE: return channel_pressure(); default: return 0; } }