void MidiOutputDevice::setPitchBendRange(int channel, uint8_t semiTones)
{
    sendMidiMessage(ControlChange + channel, RpnMsb, 0);
    sendMidiMessage(ControlChange + channel, RpnLsb, 0);
    sendMidiMessage(ControlChange + channel, DataEntryCoarse, semiTones);
    sendMidiMessage(ControlChange + channel, DataEntryFine, 0);
}
예제 #2
0
void Bridge::onStatusByte(uint8_t byte) {
  if(byte == MSG_SYSEX_END && bufferStartsWith(MSG_SYSEX_START)) {
    this->msg_data.append(byte); // bookends of a complete SysEx message
    sendMidiMessage();
    return;
  }

  if(this->data_expected > 0) {
    emit displayMessage(applyTimeStamp(QString("Warning: got a status byte when we were expecting %1 more data bytes, sending possibly incomplete MIDI message 0x%2").arg(this->data_expected).arg((uint8_t)this->msg_data[0], 0, 16)));
    sendMidiMessage();
  }

  if(is_voice_msg(byte))
    this->running_status = byte;
  if(is_syscommon_msg(byte))
    this->running_status = 0;

  this->data_expected = get_data_length(byte);
  if(this->data_expected == UNKNOWN_MIDI) {
      emit displayMessage(applyTimeStamp(QString("Warning: got unexpected status byte %1").arg((uint8_t)byte,0,16)));
      this->data_expected = 0;
  }
  this->msg_data.clear();
  this->msg_data.append(byte);
}
예제 #3
0
void threadDraw::drawMatrice() {
	sendMidiMessage(144, 1, 0, 0);
	for (int i = 0; i < 8; i++) {
		for (int j = 0; j < 8; j = j+2) {
			sendMidiMessage(144, 3, matrice[j][7-i], matrice[j + 1][7-i]);
		}
	}
	for (int i = 0; i < 8; i = i + 2) {
		sendMidiMessage(144, 3, matrice[8][7 - i], matrice[8][7 - i - 1]);
	}
	for (int i = 0; i < 8; i=i+2) {
		sendMidiMessage(144, 3, matrice[i][8], matrice[i+1][8]);
	}
}
bool MidiOutputDevice::setPitchBend (int channel, uint8_t bend)
{
    if (bend > 127)
        bend = 127;

    return sendMidiMessage(PitchWheel + channel, 0, bend);
}
void CtrlrModulatorProcessor::setValueFromHost(const float inValue)
{
	/* called from the audio thread */
	{
		/* first quickly check if we need to change anything at all */
		const ScopedReadLock sl (processorLock);
		
		const int possibleNewValue	= denormalizeValue (inValue, minValue, maxValue);

		if (possibleNewValue == currentValue)
		{
			/* the host told us the same exact value we already have, we won't do anything about it */
			triggerAsyncUpdate();
			return;
		}
	}

	{
		/* if we got here the value from the host is new and we need to update things */
		const ScopedWriteLock sl(processorLock);
		
		/* set the new value for the modulator */
		currentValue = denormalizeValue (inValue, minValue, maxValue);

		/* send a midi message */
		sendMidiMessage();
	}

	/* update the modulator ValueTree and tell the GUI about the changes */
	triggerAsyncUpdate();
} 
bool MidiOutputDevice::setVibrato(int channel, uint8_t modulation)
{
    if (modulation > 127)
        modulation = 127;

    return sendMidiMessage(ControlChange + channel, ModWheel, modulation);
}
 void ChordPlayer::stop()
 {
     std::vector<Note>::iterator it;
     for (it = pitches.begin(); it != pitches.end(); ++it)
     {
         sendMidiMessage(rt::CommandName::NoteOff, channel, it->pitch, it->vel);
     }
 }
예제 #8
0
void rhythmBlock::play(unsigned char vel)
{
	message.clear();
	message.push_back(MIDI_NOTE_ON+channel);
	message.push_back(note);
	message.push_back(vel);
	sendMidiMessage(message);
}
예제 #9
0
 // Pops a note from the back of playedNotes queue and sends a corresponding noteoff midi message
 void Player::stop()
 {
     if (playedNotes.empty()) {
         return;
     }
     Note note = playedNotes.front();
     sendMidiMessage(rt::CommandName::NoteOff, channel, note.pitch, note.vel);
     playedNotes.pop();
 }
bool MidiOutputDevice::stopNote(int channel, uint8_t pitch)
{
    if (pitch > 127)
        pitch=127;

    // MIDI note off
    // first parameter 0x80-9x8F with 8 being the id and 0-F being the channel (0-15)
    // second parameter is the pitch of the note (0-127), 60 would be a 'middle C'
    return sendMidiMessage(NoteOff + channel, pitch, 127);
}
bool MidiOutputDevice::setVolume (int channel, uint8_t volume)
{
    assert(volume <= 127);

    channelActiveVolumes[channel] = volume;

    return sendMidiMessage(
        ControlChange + channel, ChannelVolume,
        static_cast<int>((volume / 127.0) * channelMaxVolumes[channel]));
}
bool MidiOutputDevice::setPatch(int channel, uint8_t patch)
{
    if (patch > 127)
    {
        patch = 127;
    }

    // MIDI program change:
    // - first parameter is 0xC0-0xCF with C being the id and 0-F being the
    //   channel (0-15).
    // - second parameter is the new patch (0-127).
    return sendMidiMessage(ProgramChange + channel, patch, -1);
}
예제 #13
0
void Bridge::onSerialAvailable()
{
    emit serialTraffic();
    QByteArray data = this->serial->readAll();
    foreach(uint8_t next, data) {
      if (next & STATUS_MASK)
        this->onStatusByte(next);
      else
        this->onDataByte(next);
      if(this->data_expected == 0)
        sendMidiMessage();
    }
}
bool MidiOutputDevice::setPan(int channel, uint8_t pan)
{
    if (pan > 127)
    { 
        pan = 127;
    }

    // MIDI control change
    // first parameter is 0xB0-0xBF with B being the id and 0-F being the channel (0-15)
    // second parameter is the control to change (0-127), 10 is channel pan
    // third parameter is the new pan (0-127)
    return sendMidiMessage(ControlChange + channel, PanChange, pan);
}
bool MidiOutputDevice::playNote(int channel, uint8_t pitch, uint8_t velocity)
{
    if (pitch > 127)
    {
        pitch = 127;
    }

    if (velocity == 0)
    {
        velocity = 1;
    }
    else if (velocity > 127)
    {
        velocity = 127;
    }

    // MIDI note on
    // first parameter 0x90-9x9F with 9 being the id and 0-F being the channel (0-15)
    // second parameter is the pitch of the note (0-127), 60 would be a 'middle C'
    // third parameter is the velocity of the note (1-127), 0 is not allowed, 64 would be no velocity
    return sendMidiMessage(NoteOn + channel, pitch, velocity);
}
bool MidiOutputDevice::setSustain(int channel, bool sustainOn)
{
    const uint8_t value = sustainOn ? 127 : 0;
    
    return sendMidiMessage(ControlChange + channel, HoldPedal, value);
}
예제 #17
0
void CtrlrModulatorProcessor::setValueFromGUI(const double inValue, const bool force, const bool mute)
{
	/* there are 3 sources of value changes

		- gui
		- midi
		- host

		- gui should affect the MIDI first and then send the value to host, when it comes back from host
			and is the same as the value set before sending it to host, nothing should happen, if theyre
			different it should be set to the MIDI and a async update should be triggered

		- midi should affect the host first

		- host update has to check what's different from the value received, if it is different an update
			should be triggered (midi sent and/or async update done)


		** problem, when a value comes back from host it needs to be re-mapped to a midi value that lives
			in the UI component, this will be the audio thread so asking the component will require locking
			it might be better to keep a copy of value mapping (just the numeric part, we don't need the text, or do we?)
			internaly in the processor so we can avoid locking at runtime
	*/
	{
		/* if the values are already the same, and the force flag is set to false
			don't do anything the modulator is already in the state it should be */

		const ScopedReadLock sl(processorLock);

		if (currentValue == inValue && force == false)
		{
			return;
		}
	}

	{
		/* set the current value and the midi messages value,
			send the MIDI out and notify the host about the parameter change */
		const ScopedWriteLock sl(processorLock);

		/* it's the same value, but it's forced, send out MIDI and triggerAsyncUpdate
			don't inform the host, it already knows about it

			if mute is true, no midi goes out */
		if (currentValue == inValue && force == true)
		{
			if (!mute)
				sendMidiMessage();

			triggerAsyncUpdate();

			return;
		}

		/* first we se the currentValue to the new value comming from the gui, it's needed for the
			expressions evaluations to work */

		currentValue = inValue;

		/* send the midi message, this is done using a special thread so it won't wait until it's actualy sent */
		if (!mute)
			sendMidiMessage();

		triggerAsyncUpdate();
	}

	/* notify the pluginHost about the change */
	setParameterNotifyingHost();
}