bool SignalModifier::convertToNotePressure(Signal &s) { // reference counted Signal ( string command, string origin ) Signal::SignalP midiSignal = new Signal("SEND_MIDI", "SIG_MOD"); // allow this to set the MIDI Channel midiSignal->addStringArg("NOTE"); midiSignal->addIntArg(1); midiSignal->addIntArg(s.getArgAsInt32(1)); int pressureValue = int((s.getArgAsInt32(2)/1024.00)*127.00); midiSignal->addIntArg(pressureValue); _mCenter->handleSignal(*midiSignal); // reference counted Signal ( string command, string origin ) Signal::SignalP ledStateSignal = new Signal("SEND_OSC", "SIG_MOD"); ledStateSignal->addStringArg("/nomestate/grid/led/set"); // get the x position: LED bumber % 8 ledStateSignal->addIntArg(s.getArgAsInt32(1) % 8); // get the y position: LED number / 8 ledStateSignal->addIntArg(s.getArgAsInt32(1) / 8); // get the LED state: toggleState int state = 0; if(s.getArgAsInt32(2) > 0) state = 1; ledStateSignal->addIntArg(state); _mCenter->handleSignal(*ledStateSignal); return true; }
bool SignalModifier::convertToTrigger(Signal &s) { // reference counted Signal ( string command, string origin ) Signal::SignalP midiSignal = new Signal("SEND_MIDI", "SIG_MOD"); midiSignal->addStringArg("CC"); // TODO: allow this to set the MIDI Channel midiSignal->addIntArg(1); midiSignal->addIntArg(s.getArgAsInt32(1)); midiSignal->addIntArg(s.getArgAsInt32(2) * 127); _mCenter->handleSignal(*midiSignal); // reference counted Signal ( string command, string origin ) Signal::SignalP ledStateSignal = new Signal("SEND_OSC", "SIG_MOD"); ledStateSignal->addStringArg("/nomestate/grid/led/set"); // get the x position: LED bumber % 8 ledStateSignal->addIntArg(s.getArgAsInt32(1) % 8); // get the y position: LED number / 8 ledStateSignal->addIntArg(s.getArgAsInt32(1) / 8); // get the LED state: toggleState ledStateSignal->addIntArg(s.getArgAsInt32(2)); _mCenter->handleSignal(*ledStateSignal); return true; }
bool SignalModifier::convertToTogglePressure(Signal &s) { if(s.getArgAsInt32(2) == 0 && s.getArgAsInt32(2) != lastPressValue ) { int toggleState = (bool)PropertiesManager::getInstance()->getButtonPropertyContainer(s.getArgAsInt32(1))->propertyTree.getPropertyAsValue("buttonState", NULL).getValue() ? 0 : 1; PropertiesManager::getInstance()->getButtonPropertyContainer(s.getArgAsInt32(1))->propertyTree.setProperty("buttonState", toggleState, NULL); // reference counted Signal ( string command, string origin ) Signal::SignalP midiSignal = new Signal("SEND_MIDI", "SIG_MOD"); // allow this to set the MIDI Channel midiSignal->addStringArg("CC"); midiSignal->addIntArg(1); midiSignal->addIntArg(s.getArgAsInt32(1)); midiSignal->addIntArg(toggleState); _mCenter->handleSignal(*midiSignal); // reference counted Signal ( string command, string origin ) Signal::SignalP ledStateSignal = new Signal("SEND_OSC", "SIG_MOD"); ledStateSignal->addStringArg("/nomestate/grid/led/set"); // get the x position: LED bumber % 8 ledStateSignal->addIntArg(s.getArgAsInt32(1) % 8); // get the y position: LED number / 8 ledStateSignal->addIntArg(s.getArgAsInt32(1) / 8); // get the LED state: toggleState ledStateSignal->addIntArg(toggleState); _mCenter->handleSignal(*ledStateSignal); } lastPressValue = s.getArgAsInt32(2); return true; }
void MIDIReceiver::handleIncomingMidiMessage (MidiInput *source, const MidiMessage &message) { DBG("midi in"); // is this midi input source enabled if(_MidiDeviceManager->isMidiInputEnabled(source->getName())) { DBG(source->getName()); if(message.isController() && _MidiDeviceManager->isCcEnabled(source->getName(), true) && appProperties->getUserSettings()->getIntValue("midiInputChannel") == message.getChannel()) { DBG(message.getControllerNumber() ); // 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.getControllerNumber() % 8); // get the y position: LED number / 8 ledStateSignal->addIntArg(message.getControllerNumber() / 8); // get the LED state: toggleState int ledState; if (message.getControllerValue() > 0) { ledState = 1; } ledStateSignal->addIntArg(ledState); _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); } } }