diff options
| author | Gary Scavone <gary@music.mcgill.ca> | 2013-10-11 14:49:11 +0200 |
|---|---|---|
| committer | Stephen Sinclair <sinclair@music.mcgill.ca> | 2013-10-11 14:49:11 +0200 |
| commit | 5f15183a557fc1d38da0eebd8bef1f860d394a66 (patch) | |
| tree | eac2cfa36ea6582680eb949a51345028df50467e /tests/sysextest.cpp | |
| parent | 1541e77944f030ef90dbebc6d94d6a4005f3200b (diff) | |
Version 2.0.0
Diffstat (limited to 'tests/sysextest.cpp')
| -rw-r--r-- | tests/sysextest.cpp | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/tests/sysextest.cpp b/tests/sysextest.cpp index 89ddf7d..a11ec16 100644 --- a/tests/sysextest.cpp +++ b/tests/sysextest.cpp @@ -31,12 +31,20 @@ void usage( void ) { // It returns false if there are no ports available. bool chooseMidiPort( RtMidi *rtmidi ); +void mycallback( double deltatime, std::vector< unsigned char > *message, void *userData ) +{ + unsigned int nBytes = message->size(); + for ( unsigned int i=0; i<nBytes; i++ ) + std::cout << "Byte " << i << " = " << (int)message->at(i) << ", "; + if ( nBytes > 0 ) + std::cout << "stamp = " << deltatime << std::endl; +} + int main( int argc, char *argv[] ) { RtMidiOut *midiout = 0; RtMidiIn *midiin = 0; std::vector<unsigned char> message; - double stamp; unsigned int i, nBytes; // Minimal command-line check. @@ -66,21 +74,24 @@ int main( int argc, char *argv[] ) goto cleanup; } + midiin->setCallback( &mycallback ); + + message.push_back( 0xF6 ); + midiout->sendMessage( &message ); + SLEEP( 500 ); // pause a little + // Create a long sysex messages of numbered bytes and send it out. + for ( int n=0; n<2; n++ ) { + message.clear(); message.push_back( 240 ); for ( i=0; i<nBytes; i++ ) message.push_back( i % 128 ); message.push_back( 247 ); midiout->sendMessage( &message ); - SLEEP( 50 ); // pause a little + SLEEP( 500 ); // pause a little - // Look for one message (hopefully the previously sent sysex if the - // ports were connected together) and print out the values. - stamp = midiin->getMessage( &message ); - nBytes = message.size(); - for ( i=0; i<nBytes; i++ ) - std::cout << "Byte " << i << " = " << (int)message[i] << std::endl; +} // Clean up cleanup: |
