Exemplo n.º 1
0
void test14 ()
{
        printf("\n\n<TEST 14> send a note\n");
        DebugStr ("--> use g or G to send a note and go to the next test\n");

        sendNote(60);
}
Exemplo n.º 2
0
void NodeWindow::keyReleaseEvent(QKeyEvent* event) {
    int note = keyEventToNote(event);
    if (note == -1) {
        return QMainWindow::keyReleaseEvent(event);
    }
    sendNote(m_vstNode, note, 0);
}
Exemplo n.º 3
0
int main(int argc, char* argv[]){
	std::string address;
    if(argc < 2){
        address = "localhost";
    }else{
    	std::string line = argv[1];
    	
    	unsigned int colon_pos = line.find(":");
    	if(colon_pos != std::string::npos){
    		address = line.substr(0, colon_pos);
    		port = std::stoi(line.substr(colon_pos + 1, std::string::npos));
    	}else{
    		address = line;
    	}
    }
    std::cout << address << std::endl;
  	std::cout << port << std::endl;
    
    
    transmit_socket = new UdpTransmitSocket( IpEndpointName( address.c_str() , port ) );
    ros::init(argc, argv, "drum_machine_latency_test");
    ros::NodeHandle n;
    ros::Rate loop_rate(10);
    
	signal(SIGINT, [](int signum) {
		std::cout << "\nStopping Latency Test" << std::endl;
		quit = true;
	});
    
    std::cout << "Starting Latency Test" << std::endl;
    while(!quit){
		std_msgs::Float64MultiArray test;
		std::vector<double> stuff;
		stuff.push_back(49.0);
		stuff.push_back(0.5);
		stuff.push_back(100.0);
		test.data = stuff;
		std::cout << "looping" << std::endl;
		if(completed){	
			completed = false;
			startTime = ros::Time::now();
			std::cout << "Sending note.....";
			sendNote(test);
		}
				
		ros::spinOnce();
    	loop_rate.sleep();
    }
    
    
    delete transmit_socket;
	return 0;
}
Exemplo n.º 4
0
void NodeWindow::keyPressEvent(QKeyEvent* event) {
    if (event->isAutoRepeat()) {
        return;
    }

    int note = keyEventToNote(event);
    if (note == -1) {
        return QMainWindow::keyPressEvent(event);
    }

    sendNote(m_vstNode, note, 100);

}
Exemplo n.º 5
0
void NodeWindow::on_testNoteButton_pressed()
{
    int note = 0;

    // FUNKYTOWN
    if (QApplication::keyboardModifiers() == Qt::ShiftModifier) {

        note = m_funkyTown[m_funkyTownPos] + 72;
        m_funkyTownPos = (m_funkyTownPos + 1) % m_funkyTown.size();

    } else {

        note = m_note++;
        if (m_note > 72) {
            m_note = 60;
        }
    }


    sendNote(m_vstNode, note, 100);
    m_lastNote = note;

}
Exemplo n.º 6
0
pp_int32 InputControlListener::handleEvent(PPObject* sender, PPEvent* event)
{
	if (event->getID() == eCommand || event->getID() == eCommandRepeat)
	{
		switch (reinterpret_cast<PPControl*>(sender)->getID())
		{
			case INPUT_BUTTON_CAPSLOCK:
			{	
				capsLockPressed = !capsLockPressed;
				PPButton* button = reinterpret_cast<PPButton*>(sender);
				button->setPressed(capsLockPressed);
				refreshSIP();
				break;
			}

			case INPUT_BUTTON_LSHIFT:
			{	
				lShiftPressed = !lShiftPressed;
				PPButton* button = reinterpret_cast<PPButton*>(sender);
				button->setPressed(lShiftPressed);
				refreshSIP();
				break;
			}

			case INPUT_BUTTON_RSHIFT:
			{	
				rShiftPressed = !rShiftPressed;
				PPButton* button = reinterpret_cast<PPButton*>(sender);
				button->setPressed(rShiftPressed);
				refreshSIP();
				break;
			}
		
			case INPUT_BUTTON_0:
			case INPUT_BUTTON_1:
			case INPUT_BUTTON_2:
			case INPUT_BUTTON_3:
			case INPUT_BUTTON_4:
			case INPUT_BUTTON_5:
			case INPUT_BUTTON_6:
			case INPUT_BUTTON_7:
			case INPUT_BUTTON_8:
			case INPUT_BUTTON_9:
			{
				pp_uint16 key[2];
				key[0] = (pp_uint16)(reinterpret_cast<PPControl*>(sender)->getID() - INPUT_BUTTON_0 + '0');
				key[1] = scanCodesNumbers[key[0] - '0'];
				
				sendKey(eKeyDown, key[0], key[1], uppercase() ? key[0] : shiftNumbers[key[0]-'0']);
				sendKey(eKeyChar, uppercase() ? key[0] : shiftNumbers[key[0]-'0'], key[1], 0);
				sendKey(eKeyUp, key[0], key[1], uppercase() ? key[0] : shiftNumbers[key[0]-'0']);

				handleModifiers();
				break;
			}

			case INPUT_BUTTON_A:
			case INPUT_BUTTON_B:
			case INPUT_BUTTON_C:
			case INPUT_BUTTON_D:
			case INPUT_BUTTON_E:
			case INPUT_BUTTON_F:
			case INPUT_BUTTON_G:
			case INPUT_BUTTON_H:
			case INPUT_BUTTON_I:
			case INPUT_BUTTON_J:
			case INPUT_BUTTON_K:
			case INPUT_BUTTON_L:
			case INPUT_BUTTON_M:
			case INPUT_BUTTON_N:
			case INPUT_BUTTON_O:
			case INPUT_BUTTON_P:
			case INPUT_BUTTON_Q:
			case INPUT_BUTTON_R:
			case INPUT_BUTTON_S:
			case INPUT_BUTTON_T:
			case INPUT_BUTTON_U:
			case INPUT_BUTTON_V:
			case INPUT_BUTTON_W:
			case INPUT_BUTTON_X:
			case INPUT_BUTTON_Y:
			case INPUT_BUTTON_Z:
			{
				pp_uint16 key[2];
				key[0] = (pp_uint16)(reinterpret_cast<PPControl*>(sender)->getID() - INPUT_BUTTON_A + 'A');
				key[1] = scanCodesLetters[key[0] - 'A'];

				sendKey(eKeyDown, key[0], key[1], !uppercase() ? key[0] : tolower(key[0]));
				sendKey(eKeyChar, !uppercase() ? key[0] : tolower(key[0]), key[1], 0);
				sendKey(eKeyUp, key[0], key[1], !uppercase() ? key[0] : tolower(key[0]));

				handleModifiers();
				break;
			}
			
			case INPUT_BUTTON_MINUS:
			{
				sendKey(eKeyDown, 189, 12, !uppercase() ? '_' : '-');
				sendKey(eKeyChar, !uppercase() ? '_' : '-', 12, 0);
				sendKey(eKeyUp, 189, 12, !uppercase() ? '_' : '-');

				handleModifiers();
				break;
			}
			
			case INPUT_BUTTON_PLUS:
			{
				sendKey(eKeyDown, 187, 13, !uppercase() ? '+' : '=');
				sendKey(eKeyChar, !uppercase() ? '+' : '=', 13, 0);
				sendKey(eKeyUp, 187, 13, !uppercase() ? '+' : '=');

				handleModifiers();
				break;
			}
			
			case INPUT_BUTTON_BRACKETOPEN:
			{
				sendKey(eKeyDown, 219, 26, !uppercase() ? '{' : '[');
				sendKey(eKeyChar,  !uppercase() ? '{' : '[', 26, 0);
				sendKey(eKeyUp, 219, 26, !uppercase() ? '{' : '[');

				handleModifiers();
				break;
			}

			case INPUT_BUTTON_BRACKETCLOSE:
			{
				sendKey(eKeyDown, 221, 27, !uppercase() ? '}' : ']');
				sendKey(eKeyChar, !uppercase() ? '}' : ']', 27, 0);
				sendKey(eKeyUp, 221, 27, !uppercase() ? '}' : ']');

				handleModifiers();
				break;
			}

			case INPUT_BUTTON_SEMICOLON:
			{
				sendKey(eKeyDown, 186, 39, !uppercase() ? ':' : ';');
				sendKey(eKeyChar, !uppercase() ? ':' : ';', 39, 0);
				sendKey(eKeyUp, 186, 39, !uppercase() ? ':' : ';');

				handleModifiers();
				break;
			}

			case INPUT_BUTTON_TICK:
			{
				sendKey(eKeyDown, 222, 40, !uppercase() ? '\"' : '\'');
				sendKey(eKeyChar, !uppercase() ? '\"' : '\'', 40, 0);
				sendKey(eKeyUp, 222, 40, !uppercase() ? '\"' : '\'');

				handleModifiers();
				break;
			}

			case INPUT_BUTTON_BACKSLASH:
			{
				sendKey(eKeyDown, 220, 43, !uppercase() ? '|' : '\\');
				sendKey(eKeyChar, !uppercase() ? '|' : '\\', 43, 0);
				sendKey(eKeyUp, 220, 43, !uppercase() ? '|' : '\\');

				handleModifiers();
				break;
			}

			case INPUT_BUTTON_TILDE:
			{
				sendKey(eKeyDown, 226, 86, !uppercase() ? '|' : '~');
				sendKey(eKeyChar, !uppercase() ? '|' : '~', 86, 0);
				sendKey(eKeyUp, 226, 86, !uppercase() ? '|' : '~');

				handleModifiers();
				break;
			}

			case INPUT_BUTTON_COMMA:
			{
				sendKey(eKeyDown, 188, 51, !uppercase() ? '<' : ',');
				sendKey(eKeyChar, !uppercase() ? '<' : ',', 51, 0);
				sendKey(eKeyUp, 188, 51, !uppercase() ? '<' : ',');

				handleModifiers();
				break;
			}

			case INPUT_BUTTON_PERIOD:
			{
				sendKey(eKeyDown, 190, 52, !uppercase() ? '>' : '.');
				sendKey(eKeyChar, !uppercase() ? '>' : '.', 52, 0);
				sendKey(eKeyUp, 190, 52, !uppercase() ? '>' : '.');

				handleModifiers();
				break;
			}

			case INPUT_BUTTON_SLASH:
			{
				sendKey(eKeyDown, 191, 53, !uppercase() ? '?' : '/');
				sendKey(eKeyChar, !uppercase() ? '?' : '/', 53, 0);
				sendKey(eKeyUp, 191, 53, !uppercase() ? '?' : '/');

				handleModifiers();
				break;
			}

			case INPUT_BUTTON_INS:
				sendKey(eKeyDown, VK_INSERT, 0, 0);
				sendKey(eKeyUp, VK_INSERT, 0, 0);
				break;

			case INPUT_BUTTON_DEL:
				sendKey(eKeyDown, VK_DELETE, 0, 0);
				sendKey(eKeyUp, VK_DELETE, 0, 0);
				break;

			case INPUT_BUTTON_BACK:
				sendKey(eKeyDown, VK_BACK, 0, 0);
				sendKey(eKeyUp, VK_BACK, 0, 0);
				break;

			case INPUT_BUTTON_INSLINE:
				sendKey(eKeyDown, VK_SHIFT, 0, 0);
				::setForceKeyModifier(KeyModifierSHIFT);
				sendKey(eKeyDown, VK_INSERT, 0, 0);
				sendKey(eKeyUp, VK_INSERT, 0, 0);
				::clearForceKeyModifier(KeyModifierSHIFT);
				sendKey(eKeyUp, VK_SHIFT, 0, 0);
				break;

			case INPUT_BUTTON_BACKLINE:
				sendKey(eKeyDown, VK_SHIFT, 0, 0);
				::setForceKeyModifier(KeyModifierSHIFT);
				sendKey(eKeyDown, VK_BACK, 0, 0);
				sendKey(eKeyUp, VK_BACK, 0, 0);
				::clearForceKeyModifier(KeyModifierSHIFT);
				sendKey(eKeyUp, VK_SHIFT, 0, 0);
				break;

			case INPUT_BUTTON_WTF:
				if (!uppercase())
				{
					::setForceKeyModifier(KeyModifierSHIFT);
					sendKey(eKeyDown, VK_SHIFT, 0, 0);
				}
				sendKey(eKeyDown, VK_OEM_3, SC_WTF, '\x60');
				sendKey(eKeyChar, '\x60', 53, 0);
				sendKey(eKeyUp, VK_OEM_3, SC_WTF, '\x60');

				if (!uppercase())
				{
					::clearForceKeyModifier(KeyModifierSHIFT);
					sendKey(eKeyUp, VK_SHIFT, 0, 0);
				}
				handleModifiers();
				break;

			case INPUT_BUTTON_KEYOFF:
				sendKey(eKeyDown, 
						tracker.editMode == EditModeMilkyTracker ? VK_OEM_3 : VK_OEM_102, 
						tracker.editMode == EditModeMilkyTracker ? SC_WTF : SC_SMALLERGREATER, 0);
				sendKey(eKeyUp, 
						tracker.editMode == EditModeMilkyTracker ? VK_OEM_3 : VK_OEM_102, 
						tracker.editMode == EditModeMilkyTracker ? SC_WTF : SC_SMALLERGREATER, 0);	
				break;

			case INPUT_BUTTON_SPACE:
				sendKey(eKeyDown, VK_SPACE, 666, ' ');
				sendKey(eKeyChar, ' ', 666, 0);
				sendKey(eKeyUp, VK_SPACE, 666, ' ');

				handleModifiers();
				break;

			case INPUT_BUTTON_ENTER:
				sendKey(eKeyDown, VK_RETURN, 777, 0x0A);
				sendKey(eKeyChar, 0x0A, 777, 0);
				sendKey(eKeyUp, VK_RETURN, 777, 0x0A);

				handleModifiers();
				break;

			case INPUT_BUTTON_TAB:
				sendKey(eKeyDown, VK_TAB, 888, 0x08);
				sendKey(eKeyChar, 0x08, 888, 0);
				sendKey(eKeyUp, VK_TAB, 888, 0x08);

				handleModifiers();
				break;
				
			case INPUT_BUTTON_SHRINK:
			{
				if (event->getID() != eCommand)
					break;
				tracker.setInputControl(Tracker::SIPDefault);
				tracker.screen->paint();
				break;
			}

			case INPUT_BUTTON_EXPAND:
			{
				if (event->getID() != eCommand)
					break;
				tracker.setInputControl(Tracker::SIPExtended);
				tracker.screen->paint();
				break;
			}
		}
	}
	else if (event->getID() == eSelection)
	{
		switch (reinterpret_cast<PPControl*>(sender)->getID())
		{
			case PIANO_CONTROL:
			{
				pp_int32 v = *((pp_int32*)event->getDataPtr());

				sendNote(v);
				break;
			}
		}
	}
	
	return 0;	
}
Exemplo n.º 7
0
void NodeWindow::on_testNoteButton_released()
{
    sendNote(m_vstNode, m_lastNote, 0);
}