void NsmClient::createInitialClient() { /* * Make first contact with NSM server. */ nsm_client_t* nsm = 0; H2Core::Preferences *pPref = H2Core::Preferences::get_instance(); QString H2ProcessName = pPref->getH2ProcessName(); QByteArray byteArray = H2ProcessName.toLatin1(); const char *nsm_url = getenv( "NSM_URL" ); if ( nsm_url ) { nsm = nsm_new(); if ( nsm ) { nsm_set_open_callback( nsm, nsm_open_cb, (void*) 0 ); nsm_set_save_callback( nsm, nsm_save_cb, (void*) 0 ); if ( nsm_init( nsm, nsm_url ) == 0 ) { nsm_send_announce( nsm, "Hydrogen", "", byteArray.data() ); nsm_check_wait( nsm, 10000 ); if(pthread_create(&m_NsmThread, NULL, nsm_processEvent, nsm)) { ___ERRORLOG("Error creating NSM thread\n "); return; } } else { ___ERRORLOG("failed, freeing NSM client"); nsm_free( nsm ); nsm = 0; } } } else { ___WARNINGLOG("No NSM URL available: no NSM management\n"); } }
static void midiProc ( const MIDIPacketList * pktlist, void * readProcRefCon, void * srcConnRefCon ) { UNUSED( srcConnRefCon ); MIDIPacket* packet = ( MIDIPacket * )pktlist->packet; //_ERRORLOG( QString( "MIDIPROC packets # %1" ).arg( pktlist->numPackets ) ); CoreMidiDriver *instance = ( CoreMidiDriver * )readProcRefCon; MidiMessage msg; for ( uint i = 0; i < pktlist->numPackets; i++ ) { int nEventType = packet->data[0]; if ( ( nEventType >= 128 ) && ( nEventType < 144 ) ) { // note off msg.m_nChannel = nEventType - 128; msg.m_type = MidiMessage::NOTE_OFF; } else if ( ( nEventType >= 144 ) && ( nEventType < 160 ) ) { // note on msg.m_nChannel = nEventType - 144; msg.m_type = MidiMessage::NOTE_ON; } else if ( ( nEventType >= 160 ) && ( nEventType < 176 ) ) { // Polyphonic Key Pressure (After-touch) msg.m_nChannel = nEventType - 160; msg.m_type = MidiMessage::POLYPHONIC_KEY_PRESSURE; } else if ( ( nEventType >= 176 ) && ( nEventType < 192 ) ) { // Control Change msg.m_nChannel = nEventType - 176; msg.m_type = MidiMessage::CONTROL_CHANGE; } else if ( ( nEventType >= 192 ) && ( nEventType < 208 ) ) { // Program Change msg.m_nChannel = nEventType - 192; msg.m_type = MidiMessage::PROGRAM_CHANGE; } else if ( ( nEventType >= 208 ) && ( nEventType < 224 ) ) { // Channel Pressure (After-touch) msg.m_nChannel = nEventType - 208; msg.m_type = MidiMessage::CHANNEL_PRESSURE; } else if ( ( nEventType >= 224 ) && ( nEventType < 240 ) ) { // Pitch Wheel Change msg.m_nChannel = nEventType - 224; msg.m_type = MidiMessage::PITCH_WHEEL; } else if ( ( nEventType >= 240 ) && ( nEventType < 256 ) ) { // System Exclusive msg.m_type = MidiMessage::SYSEX; for(int i = 0; i< packet->length;i++){ msg.m_sysexData.push_back(packet->data[i]); } instance->handleMidiMessage( msg ); packet = MIDIPacketNext( packet ); return; } else { ___ERRORLOG( QString( "Unhandled midi message type: %1" ).arg( nEventType ) ); ___INFOLOG( "MIDI msg: " ); // instance->errorLog( "Unhandled midi message type: " + to_string( nEventType ) ); // instance->infoLog( "MIDI msg: " ); } msg.m_nData1 = packet->data[1]; msg.m_nData2 = packet->data[2]; instance->handleMidiMessage( msg ); packet = MIDIPacketNext( packet ); } }
void Note::set_key_octave( const QString& str ) { int l = str.length(); QString s_key = str.left( l-1 ); QString s_oct = str.mid( l-1, l ); if ( s_key.endsWith( "-" ) ) { s_key.replace( "-", "" ); s_oct.insert( 0, "-" ); } __octave = ( Octave )s_oct.toInt(); for( int i=KEY_MIN; i<=KEY_MAX; i++ ) { if( __key_str[i]==s_key ){ __key = ( Key )i; return; } } ___ERRORLOG( "Unhandled key: " + s_key ); }