summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGary Scavone <gary@music.mcgill.ca>2013-10-11 14:49:11 +0200
committerStephen Sinclair <sinclair@music.mcgill.ca>2013-10-11 14:49:11 +0200
commit5f15183a557fc1d38da0eebd8bef1f860d394a66 (patch)
treeeac2cfa36ea6582680eb949a51345028df50467e /tests
parent1541e77944f030ef90dbebc6d94d6a4005f3200b (diff)
Version 2.0.0
Diffstat (limited to 'tests')
-rw-r--r--tests/midiprobe.cpp23
-rw-r--r--tests/sysextest.cpp27
2 files changed, 41 insertions, 9 deletions
diff --git a/tests/midiprobe.cpp b/tests/midiprobe.cpp
index e9ba757..7a7452e 100644
--- a/tests/midiprobe.cpp
+++ b/tests/midiprobe.cpp
@@ -2,14 +2,31 @@
//
// Simple program to check MIDI inputs and outputs.
//
-// by Gary Scavone, 2003-2004.
+// by Gary Scavone, 2003-2012.
#include <iostream>
#include <cstdlib>
+#include <map>
#include "RtMidi.h"
int main()
{
+ // Create an api map.
+ std::map<int, std::string> apiMap;
+ apiMap[RtMidi::MACOSX_CORE] = "OS-X CoreMidi";
+ apiMap[RtMidi::WINDOWS_MM] = "Windows MultiMedia";
+ apiMap[RtMidi::WINDOWS_KS] = "Windows Kernel Straming";
+ apiMap[RtMidi::UNIX_JACK] = "Jack Client";
+ apiMap[RtMidi::LINUX_ALSA] = "Linux ALSA";
+ apiMap[RtMidi::RTMIDI_DUMMY] = "RtMidi Dummy";
+
+ std::vector< RtMidi::Api > apis;
+ RtMidi :: getCompiledApi( apis );
+
+ std::cout << "\nCompiled APIs:\n";
+ for ( unsigned int i=0; i<apis.size(); i++ )
+ std::cout << " " << apiMap[ apis[i] ] << std::endl;
+
RtMidiIn *midiin = 0;
RtMidiOut *midiout = 0;
@@ -18,6 +35,8 @@ int main()
// RtMidiIn constructor ... exception possible
midiin = new RtMidiIn();
+ std::cout << "\nCurrent input API: " << apiMap[ midiin->getCurrentApi() ] << std::endl;
+
// Check inputs.
unsigned int nPorts = midiin->getPortCount();
std::cout << "\nThere are " << nPorts << " MIDI input sources available.\n";
@@ -30,6 +49,8 @@ int main()
// RtMidiOut constructor ... exception possible
midiout = new RtMidiOut();
+ std::cout << "\nCurrent output API: " << apiMap[ midiout->getCurrentApi() ] << std::endl;
+
// Check outputs.
nPorts = midiout->getPortCount();
std::cout << "\nThere are " << nPorts << " MIDI output ports available.\n";
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: