Beispiel #1
0
void MidiManager::processMidiMessage(const juce::MidiMessage &midi_message, int sample_position) {
  ScopedLock lock(*critical_section_);
  if (midi_message.isNoteOn()) {
    float velocity = (1.0 * midi_message.getVelocity()) / mopo::MIDI_SIZE;
    synth_->noteOn(midi_message.getNoteNumber(), velocity, sample_position);
  }
  else if (midi_message.isNoteOff())
    synth_->noteOff(midi_message.getNoteNumber(), sample_position);
  else if (midi_message.isSustainPedalOn())
    synth_->sustainOn();
  else if (midi_message.isSustainPedalOff())
    synth_->sustainOff();
  else if (midi_message.isAllNotesOff())
    synth_->allNotesOff();
  else if (midi_message.isAftertouch()) {
    mopo::mopo_float note = midi_message.getNoteNumber();
    mopo::mopo_float value = (1.0 * midi_message.getAfterTouchValue()) / mopo::MIDI_SIZE;
    synth_->setAftertouch(note, value);
  }
  else if (midi_message.isPitchWheel()) {
    double percent = (1.0 * midi_message.getPitchWheelValue()) / PITCH_WHEEL_RESOLUTION;
    double value = 2 * percent - 1.0;
    synth_->setPitchWheel(value);
  }
  else if (midi_message.isController()) {
    if (midi_message.getControllerNumber() == MOD_WHEEL_CONTROL_NUMBER) {
      double percent = (1.0 * midi_message.getControllerValue()) / MOD_WHEEL_RESOLUTION;
      synth_->setModWheel(percent);
    }
    midiInput(midi_message.getControllerNumber(), midi_message.getControllerValue());
  }
}
void SeaboardVisualiser::seaboardDidGetAftertouch(const juce::MidiMessage & message)
{
	int channel = message.getChannel();
	float aftertouch = message.getAfterTouchValue() / 127.f; //Normalise the aftertouch value between 0 and 1.
	String childName = kChannelNo + String(channel);
	
	ValueTree noteTree = theSeaboardData.getChildWithName(childName);
	if (noteTree.isValid())
	{
		noteTree.setProperty(kAftertouch, aftertouch, 0);
	}
}