当前位置: 首页>>代码示例>>C++>>正文


C++ MidiMessage::isNoteOff方法代码示例

本文整理汇总了C++中MidiMessage::isNoteOff方法的典型用法代码示例。如果您正苦于以下问题:C++ MidiMessage::isNoteOff方法的具体用法?C++ MidiMessage::isNoteOff怎么用?C++ MidiMessage::isNoteOff使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MidiMessage的用法示例。


在下文中一共展示了MidiMessage::isNoteOff方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: processBlock

void SoftSynthAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
    MidiBuffer processedMidi;
    int time;
    MidiMessage m;
    
    for (MidiBuffer::Iterator i(midiMessages); i.getNextEvent(m, time);) {
        if (m.isNoteOn()) {
            m = MidiMessage::noteOn(m.getChannel(), m.getNoteNumber(), m.getVelocity());
            synth.keyPressed(m.getNoteNumber(), m.getVelocity());
        } else if (m.isNoteOff()) {
            m = MidiMessage::noteOff(m.getChannel(), m.getNoteNumber(), m.getVelocity());
            synth.keyReleased(m.getNoteNumber());
        }
        
        processedMidi.addEvent(m, time);
    }
    
    auto synthBuffer = synth.getNextBuffer(buffer.getNumSamples());
    float *leftData = buffer.getWritePointer(0);
    float *rightData = buffer.getWritePointer(1);
    for (int i = 0; i < buffer.getNumSamples(); ++i) {
        leftData[i] = synthBuffer[i];
        rightData[i] = synthBuffer[i];
    }
    
    midiMessages.swapWith(processedMidi);
}
开发者ID:tallen11,项目名称:polysynth-vst,代码行数:28,代码来源:PluginProcessor.cpp

示例2: RT_MIDI_send_msg_to_patch

static void RT_MIDI_send_msg_to_patch(struct Patch *patch, MidiMessage message, int64_t seq_time){       
  if (message.isNoteOn())
    RT_PATCH_play_note(patch, message.getNoteNumber(), -1, message.getVelocity() / 127.0f, 0.0f, seq_time);
  
  else if (message.isNoteOff())
    RT_PATCH_stop_note(patch, message.getNoteNumber(), -1, seq_time);
  
  else if (message.isAftertouch())
    RT_PATCH_change_velocity(patch, message.getNoteNumber(), -1, message.getChannelPressureValue() / 127.0f, seq_time);

  else {
    
    const uint8_t *raw_data = message.getRawData();
    int len = message.getRawDataSize();

    R_ASSERT_RETURN_IF_FALSE(len>=1 && len<=3);

    uint32_t msg;

    if (len==3)
      msg = MIDI_msg_pack3(raw_data[0],raw_data[1],raw_data[2]);
    else if (len==2)
      msg = MIDI_msg_pack2(raw_data[0],raw_data[1]);
    else if (len==1)
      msg = MIDI_msg_pack1(raw_data[0]);
    else
      return;
    
    RT_PATCH_send_raw_midi_message(patch, msg, seq_time);
  }
}
开发者ID:erdoukki,项目名称:radium,代码行数:31,代码来源:Juce_plugins.cpp

示例3: handleMidiEvent

void Synthesiser::handleMidiEvent (const MidiMessage& m)
{
    if (m.isNoteOn())
    {
        noteOn (m.getChannel(),
                m.getNoteNumber(),
                m.getFloatVelocity());
    }
    else if (m.isNoteOff())
    {
        noteOff (m.getChannel(),
                 m.getNoteNumber(),
                 true);
    }
    else if (m.isAllNotesOff() || m.isAllSoundOff())
    {
        allNotesOff (m.getChannel(), true);
    }
    else if (m.isPitchWheel())
    {
        const int channel = m.getChannel();
        const int wheelPos = m.getPitchWheelValue();
        lastPitchWheelValues [channel - 1] = wheelPos;

        handlePitchWheel (channel, wheelPos);
    }
    else if (m.isController())
    {
        handleController (m.getChannel(),
                          m.getControllerNumber(),
                          m.getControllerValue());
    }
}
开发者ID:0x4d52,项目名称:ugen,代码行数:33,代码来源:juce_Synthesiser.cpp

示例4: midiMessageToType

const CtrlrMidiMessageType midiMessageToType (const MidiMessage &midiMessage)
{
	if (midiMessage.isController())
	{
		return (CC);
	}
	else if (midiMessage.isSysEx())
	{
		return (SysEx);
	}
	else if (midiMessage.isNoteOn())
	{
		return (NoteOn);
	}
	else if (midiMessage.isNoteOff())
	{
		return (NoteOff);
	}
	else if (midiMessage.isAftertouch())
	{
		return (Aftertouch);
	}
	else if (midiMessage.isChannelPressure())
	{
		return (ChannelPressure);
	}
	else if (midiMessage.isProgramChange())
	{
		return (ProgramChange);
	}
	else if (midiMessage.isPitchWheel())
	{
		return (PitchWheel);
	}
	else if (midiMessage.isMidiClock())
	{
		return (MidiClock);
	}
	else if (midiMessage.isMidiContinue())
	{
		return (MidiClockContinue);
	}
	else if (midiMessage.isMidiStart())
	{
		return (MidiClockStart);
	}
	else if (midiMessage.isMidiStop())
	{
		return (MidiClockStop);
	}
	else if (midiMessage.isActiveSense())
	{
		return (ActiveSense);
	}
	return (SysEx);
}
开发者ID:Srikrishna31,项目名称:ctrlr,代码行数:56,代码来源:CtrlrUtilities.cpp

示例5: handleIncomingMidiMessage

void MIDIInputDevice::handleIncomingMidiMessage(MidiInput * source, const MidiMessage & message)
{
	if (source != device)
	{
		DBG("different device");
		return;
	}

	if (message.isNoteOn()) inputListeners.call(&MIDIInputListener::noteOnReceived, message.getChannel(), message.getNoteNumber(), message.getVelocity());
	else if(message.isNoteOff()) inputListeners.call(&MIDIInputListener::noteOffReceived, message.getChannel(), message.getNoteNumber(), 0); //force note off to velocity 0
	else if(message.isController()) inputListeners.call(&MIDIInputListener::controlChangeReceived, message.getChannel(), message.getControllerNumber(), message.getControllerValue());
	else if(message.isSysEx()) inputListeners.call(&MIDIInputListener::sysExReceived, message);
}
开发者ID:haskellstudio,项目名称:Chataigne,代码行数:13,代码来源:MIDIDevice.cpp

示例6: processNextMidiEvent

void MidiKeyboardState::processNextMidiEvent (const MidiMessage& message)
{
    if (message.isNoteOn())
    {
        noteOnInternal (message.getChannel(), message.getNoteNumber(), message.getFloatVelocity());
    }
    else if (message.isNoteOff())
    {
        noteOffInternal (message.getChannel(), message.getNoteNumber(), message.getFloatVelocity());
    }
    else if (message.isAllNotesOff())
    {
        for (int i = 0; i < 128; ++i)
            noteOffInternal (message.getChannel(), i, 0.0f);
    }
}
开发者ID:410pfeliciano,项目名称:JUCE,代码行数:16,代码来源:juce_MidiKeyboardState.cpp

示例7: PK_STRING

static PyObject *
PyMidiMessage_str(PyObject *self) {
  MidiMessage *m = ((PyMidiMessage*)self)->m;
  static char s[256];
  if(m->isNoteOn()) {
    sprintf(s, "<NOTE ON, note: %d (%s), velocity: %d, channel: %d>",
            m->getNoteNumber(),
            m->getMidiNoteName(m->getNoteNumber(), true, true, 3),
            m->getVelocity(),
            m->getChannel());
  } else if(m->isNoteOff()) {
    sprintf(s, "<NOTE OFF, note: %d (%s), channel: %d>",
            m->getNoteNumber(),
            m->getMidiNoteName(m->getNoteNumber(), true, true, 3),
            m->getChannel());
  } else if(m->isProgramChange()) {
    sprintf(s, "<PROGRAM CHANGE: program: %d, channel: %d>", m->getProgramChangeNumber(), m->getChannel());
  } else if(m->isPitchWheel()) {
    sprintf(s, "<PITCH WHEEL: value: %d, channel: %d>", m->getPitchWheelValue(), m->getChannel());
  } else if(m->isAftertouch()) {
    sprintf(s, "<AFTERTOUCH: note: %d (%s) value: %d, channel: %d>",
            m->getNoteNumber(),
            m->getMidiNoteName(m->getNoteNumber(), true, true, 3),
            m->getAfterTouchValue(),
            m->getChannel());
  } else if(m->isChannelPressure()) {
    sprintf(s, "<CHANNEL PRESSURE: pressure: %d, channel: %d>", m->getChannelPressureValue(), m->getChannel());
  } else if(m->isController()) {
    const char *name = m->getControllerName(m->getControllerNumber());
    if(strlen(name) > 0) {
      sprintf(s, "<CONTROLLER: %d (\"%s\"), value: %d, channel: %d>",
              m->getControllerNumber(),
              m->getControllerName(m->getControllerNumber()),
              m->getControllerValue(),
              m->getChannel());
    } else {
      sprintf(s, "<CONTROLLER: %d, value: %d, channel: %d>",
              m->getControllerNumber(),
              m->getControllerValue(),
              m->getChannel());
    }
  } else {
    sprintf(s, "<MidiMessage (misc type)>");
  }

  return PK_STRING(s);
}
开发者ID:,项目名称:,代码行数:47,代码来源:

示例8: processMidiMessage

void MidiManager::processMidiMessage(const MidiMessage& midi_message, int sample_position) {
  if (midi_message.isProgramChange()) {
    current_patch_ = midi_message.getProgramChangeNumber();
    File patch = LoadSave::loadPatch(current_bank_, current_folder_, current_patch_,
                                     synth_, *gui_state_);
    PatchLoadedCallback* callback = new PatchLoadedCallback(listener_, patch);
    callback->post();
    return;
  }

  if (midi_message.isNoteOn()) {
    engine_->noteOn(midi_message.getNoteNumber(),
                    midi_message.getVelocity() / (mopo::MIDI_SIZE - 1.0),
                    0, midi_message.getChannel() - 1);
  }
  else if (midi_message.isNoteOff())
    engine_->noteOff(midi_message.getNoteNumber());
  else if (midi_message.isAllNotesOff())
    engine_->allNotesOff();
  else if (midi_message.isSustainPedalOn())
    engine_->sustainOn();
  else if (midi_message.isSustainPedalOff())
    engine_->sustainOff();
  else if (midi_message.isAftertouch()) {
    mopo::mopo_float note = midi_message.getNoteNumber();
    mopo::mopo_float value = (1.0 * midi_message.getAfterTouchValue()) / mopo::MIDI_SIZE;
    engine_->setAftertouch(note, value);
  }
  else if (midi_message.isPitchWheel()) {
    double percent = (1.0 * midi_message.getPitchWheelValue()) / PITCH_WHEEL_RESOLUTION;
    double value = 2 * percent - 1.0;
    engine_->setPitchWheel(value, midi_message.getChannel());
  }
  else if (midi_message.isController()) {
    int controller_number = midi_message.getControllerNumber();
    if (controller_number == MOD_WHEEL_CONTROL_NUMBER) {
      double percent = (1.0 * midi_message.getControllerValue()) / MOD_WHEEL_RESOLUTION;
      engine_->setModWheel(percent, midi_message.getChannel());
    }
    else if (controller_number == BANK_SELECT_NUMBER)
      current_bank_ = midi_message.getControllerValue();
    else if (controller_number == FOLDER_SELECT_NUMBER)
      current_folder_ = midi_message.getControllerValue();
    midiInput(midi_message.getControllerNumber(), midi_message.getControllerValue());
  }
}
开发者ID:and3k5,项目名称:helm,代码行数:46,代码来源:midi_manager.cpp

示例9: handleIncomingMidiMessage

/** This function is called whenever the Seaboard object receives some Midi data from the physical Seaboard. It sends out the relevant midi message to all of its listeners, who in return overwrite the midi message functions in order to implement the desired response behaviour.*/
void Seaboard::handleIncomingMidiMessage(MidiInput *source, const MidiMessage &message)
{
	if (message.isNoteOn())
	{
		listeners.call(&Seaboard::Listener::seaboardDidGetNoteOn,message);
	}
	else if (message.isNoteOff())
	{
		listeners.call(&Seaboard::Listener::seaboardDidGetNoteOff,message);
	}
	else if (message.isAftertouch())
	{
		listeners.call(&Seaboard::Listener::seaboardDidGetAftertouch,message);
	}
	else if (message.isPitchWheel())
	{
		listeners.call(&Seaboard::Listener::seaboardDidGetPitchBend,message);
	}
	listeners.call(&Seaboard::Listener::seaboardDidGetMessage,message);
}
开发者ID:Haighton,项目名称:SeaboardAPI,代码行数:21,代码来源:Seaboard.cpp

示例10: it

void Tunefish4AudioProcessor::processEvents(MidiBuffer &midiMessages, eU32 messageOffset, eU32 frameSize)
{
    MidiBuffer::Iterator it(midiMessages);
    MidiMessage midiMessage;
    int samplePosition;

    it.setNextSamplePosition(messageOffset);

    while (it.getNextEvent(midiMessage, samplePosition))
    {
        if (samplePosition >= messageOffset + frameSize)
            break;

        if (midiMessage.isNoteOn())
        {
            eU8 velocity = midiMessage.getVelocity();
            eU8 note = midiMessage.getNoteNumber();

            eTfInstrumentNoteOn(*tf, note, velocity);
        }
        else if (midiMessage.isNoteOff())
        {
            eU8 note = midiMessage.getNoteNumber();

            eTfInstrumentNoteOff(*tf, note);
        }
        else if (midiMessage.isAllNotesOff())
        {
            eTfInstrumentAllNotesOff(*tf);
        }
        else if (midiMessage.isPitchWheel())
        {
            eS32 bend_lsb = midiMessage.getRawData()[1] & 0x7f;
            eS32 bend_msb = midiMessage.getRawData()[2] & 0x7f;

            eTfInstrumentPitchBend(*tf, ((eF32(bend_msb) / 127.0f) - 0.5f) * 2.0f,
                                   ((eF32(bend_lsb) / 127.0f) - 0.5f) * 2.0f);
        }
    }
}
开发者ID:kzantow,项目名称:tunefish,代码行数:40,代码来源:PluginProcessor.cpp

示例11: handleMidiEvent

void Synthesiser::handleMidiEvent (const MidiMessage& m)
{
    const int channel = m.getChannel();

    if (m.isNoteOn())
    {
        noteOn (channel, m.getNoteNumber(), m.getFloatVelocity());
    }
    else if (m.isNoteOff())
    {
        noteOff (channel, m.getNoteNumber(), m.getFloatVelocity(), true);
    }
    else if (m.isAllNotesOff() || m.isAllSoundOff())
    {
        allNotesOff (channel, true);
    }
    else if (m.isPitchWheel())
    {
        const int wheelPos = m.getPitchWheelValue();
        lastPitchWheelValues [channel - 1] = wheelPos;
        handlePitchWheel (channel, wheelPos);
    }
    else if (m.isAftertouch())
    {
        handleAftertouch (channel, m.getNoteNumber(), m.getAfterTouchValue());
    }
    else if (m.isChannelPressure())
    {
        handleChannelPressure (channel, m.getChannelPressureValue());
    }
    else if (m.isController())
    {
        handleController (channel, m.getControllerNumber(), m.getControllerValue());
    }
    else if (m.isProgramChange())
    {
        handleProgramChange (channel, m.getProgramChangeNumber());
    }
}
开发者ID:rorywalsh,项目名称:cabbage,代码行数:39,代码来源:juce_Synthesiser.cpp

示例12: processBlock

void LyrebirdAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
    
    // Do Midi things
    buffer.clear();
    
    int time;
    MidiMessage m;
    
    for (MidiBuffer::Iterator i (midiMessages); i.getNextEvent (m, time);)
    {
        sawGenerator->setWavelength(currentSampleRate, m.getMidiNoteInHertz(m.getNoteNumber()));
        if (m.isNoteOff())
        {
            sawGenerator->setWavelength(currentSampleRate, 0);
        }
    }
    
    
    // In case we have more outputs than inputs, this code clears any output
    // channels that didn't contain input data, (because these aren't
    // guaranteed to be empty - they may contain garbage).
    // I've added this to avoid people getting screaming feedback
    // when they first compile the plugin, but obviously you don't need to
    // this code if your algorithm already fills all the output channels.
    for (int i = getNumInputChannels(); i < getNumOutputChannels(); ++i)
        buffer.clear (i, 0, buffer.getNumSamples());


    float* leftData = buffer.getWritePointer (0);
    float* rightData = buffer.getWritePointer(1);
    for (int sample = 0; sample < buffer.getNumSamples(); sample++)
    {
        leftData[sample] = sawGenerator->getCurrentAmplitude();
        rightData[sample] = sawGenerator->getCurrentAmplitude();
        sawGenerator->incrementSaw();
    }
}
开发者ID:jorshi,项目名称:lyrebird_synth,代码行数:38,代码来源:PluginProcessor.cpp

示例13: getMidiMessageDescription

String ZenMidiVisualiserComponent::getMidiMessageDescription(const MidiMessage& m)
{
	if (m.isNoteOn())           return "Note on: " + S(m.getNoteNumber()) + " (" + MidiMessage::getMidiNoteName(m.getNoteNumber(), true, true, 3) + ") Vel: " + S(m.getVelocity());
	if (m.isNoteOff())          return "Note off: " + S(m.getNoteNumber()) + " (" + MidiMessage::getMidiNoteName(m.getNoteNumber(), true, true, 3) + ")";
	if (m.isProgramChange())    return "Program change (Number): " + String(m.getProgramChangeNumber());
	if (m.isPitchWheel())       return "Pitch wheel: " + String(m.getPitchWheelValue());
	if (m.isAftertouch())       return "After touch: " + MidiMessage::getMidiNoteName(m.getNoteNumber(), true, true, 3) + ": " + String(m.getAfterTouchValue());
	if (m.isChannelPressure())  return "Channel pressure: " + String(m.getChannelPressureValue());
	if (m.isAllNotesOff())      return "All notes off";
	if (m.isAllSoundOff())      return "All sound off";
	if (m.isMetaEvent())        return "Meta event";

	if (m.isController())
	{
		String temp = MidiMessage::getControllerName(m.getControllerNumber());
		String name = "Controller [" + S(m.getControllerNumber()) + "]";
		if (!temp.isEmpty())
			name += " " + temp;

		return name + ": " + String(m.getControllerValue());
	}

	return String::toHexString(m.getRawData(), m.getRawDataSize());
}
开发者ID:SonicZentropy,项目名称:ZynVerb,代码行数:24,代码来源:ZenMidiVisualiserComponent.cpp

示例14: getMidiMessageDescription

static String getMidiMessageDescription (const MidiMessage& m)
{
    if (m.isNoteOn())           return "Note on "  + MidiMessage::getMidiNoteName (m.getNoteNumber(), true, true, 3);
    if (m.isNoteOff())          return "Note off " + MidiMessage::getMidiNoteName (m.getNoteNumber(), true, true, 3);
    if (m.isProgramChange())    return "Program change " + String (m.getProgramChangeNumber());
    if (m.isPitchWheel())       return "Pitch wheel " + String (m.getPitchWheelValue());
    if (m.isAftertouch())       return "After touch " + MidiMessage::getMidiNoteName (m.getNoteNumber(), true, true, 3) +  ": " + String (m.getAfterTouchValue());
    if (m.isChannelPressure())  return "Channel pressure " + String (m.getChannelPressureValue());
    if (m.isAllNotesOff())      return "All notes off";
    if (m.isAllSoundOff())      return "All sound off";
    if (m.isMetaEvent())        return "Meta event";

    if (m.isController())
    {
        String name (MidiMessage::getControllerName (m.getControllerNumber()));

        if (name.isEmpty())
            name = "[" + String (m.getControllerNumber()) + "]";

        return "Controler " + name + ": " + String (m.getControllerValue());
    }

    return String::toHexString (m.getRawData(), m.getRawDataSize());
}
开发者ID:audient,项目名称:JUCE,代码行数:24,代码来源:MidiDemo.cpp

示例15: handleIncomingMidiMessage


//.........这里部分代码省略.........
            _mCenter->handleSignal(*ledStateSignal);
        }
        else if (message.isNoteOn() && _MidiDeviceManager->isNoteEnabled(source->getName(), true)
                 && appProperties->getUserSettings()->getIntValue("midiInputChannel") == message.getChannel())
        {
            // lets set the color based off MIDI note Velocity
            int MIDIVelocity = message.getVelocity();
            int r = 0;
            int g = 0;
            int b = 0;

            if (MIDIVelocity > 0) {
                // red
                if (MIDIVelocity <= 22)
                {
                    r = 127;
                }
                // yellow
                else if (MIDIVelocity <= 43)
                {
                    r = 127;
                    g = 127;
                }
                // green
                else if (MIDIVelocity <= 64)
                {
                    g = 127;
                }
                // teal
                else if (MIDIVelocity <= 85)
                {
                    g = 127;
                    b = 127;
                }
                // blue
                else if (MIDIVelocity <= 106)
                {
                    b = 127;
                }
                // purple
                else
                {
                    b = 127;
                    r = 127;
                }
            }

            // reference counted Signal ( string command, string origin )
            Signal::SignalP ledColourSignal = new Signal("SEND_OSC", "RCV_MIDI");

            ledColourSignal->addStringArg("/nomestate/grid/led/color");
            // get the x position: LED bumber % 8
            ledColourSignal->addIntArg(message.getNoteNumber() % 8);
            // get the y position: LED number / 8
            ledColourSignal->addIntArg(message.getNoteNumber() / 8);
            // get the LED RED:
            ledColourSignal->addIntArg(r);
            // get the LED GREEN:
            ledColourSignal->addIntArg(g);
            // get the LED BLUE:
            ledColourSignal->addIntArg(b);

            _mCenter->handleSignal(*ledColourSignal);

            // reference counted Signal ( string command, string origin )
            Signal::SignalP ledStateSignal = new Signal("SEND_OSC", "RCV_MIDI");

            ledStateSignal->addStringArg("/nomestate/grid/led/set");
            // get the x position: LED bumber % 8
            ledStateSignal->addIntArg(message.getNoteNumber() % 8);
            // get the y position: LED number / 8
            ledStateSignal->addIntArg(message.getNoteNumber() / 8);
            // get the LED state: toggleState

            ledStateSignal->addIntArg(1);

            _mCenter->handleSignal(*ledStateSignal);


        }
        else if (message.isNoteOff() && _MidiDeviceManager->isNoteEnabled(source->getName(), true)
                 && appProperties->getUserSettings()->getIntValue("midiInputChannel") == message.getChannel())
        {
            // reference counted Signal ( string command, string origin )
            Signal::SignalP ledStateSignal = new Signal("SEND_OSC", "RCV_MIDI");

            ledStateSignal->addStringArg("/nomestate/grid/led/set");
            // get the x position: LED bumber % 8
            ledStateSignal->addIntArg(message.getNoteNumber() % 8);
            // get the y position: LED number / 8
            ledStateSignal->addIntArg(message.getNoteNumber() / 8);
            // get the LED state: toggleState

            ledStateSignal->addIntArg(0);

            _mCenter->handleSignal(*ledStateSignal);
        }

    }
}
开发者ID:,项目名称:,代码行数:101,代码来源:


注:本文中的MidiMessage::isNoteOff方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。