mirror of
https://github.com/thestk/stk
synced 2026-04-20 14:36:55 +00:00
Version 4.3.1
This commit is contained in:
committed by
Stephen Sinclair
parent
27d9b79dc7
commit
d199342e86
70
projects/examples/midiprobe.cpp
Normal file
70
projects/examples/midiprobe.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
// midiprobe.cpp
|
||||
//
|
||||
// Simple program to check MIDI inputs and outputs.
|
||||
//
|
||||
// by Gary Scavone, 2003-2004.
|
||||
|
||||
#include <iostream>
|
||||
#include "RtMidi.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
RtMidiIn *midiin = 0;
|
||||
RtMidiOut *midiout = 0;
|
||||
|
||||
// RtMidiIn constructor
|
||||
try {
|
||||
midiin = new RtMidiIn();
|
||||
}
|
||||
catch ( RtError &error ) {
|
||||
error.printMessage();
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
// Check inputs.
|
||||
unsigned int nPorts = midiin->getPortCount();
|
||||
std::cout << "\nThere are " << nPorts << " MIDI input sources available.\n";
|
||||
std::string portName;
|
||||
unsigned int i;
|
||||
for ( i=0; i<nPorts; i++ ) {
|
||||
try {
|
||||
portName = midiin->getPortName(i);
|
||||
}
|
||||
catch ( RtError &error ) {
|
||||
error.printMessage();
|
||||
goto cleanup;
|
||||
}
|
||||
std::cout << " Input Port #" << i+1 << ": " << portName << '\n';
|
||||
}
|
||||
|
||||
// RtMidiOut constructor
|
||||
try {
|
||||
midiout = new RtMidiOut();
|
||||
}
|
||||
catch ( RtError &error ) {
|
||||
error.printMessage();
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
// Check outputs.
|
||||
nPorts = midiout->getPortCount();
|
||||
std::cout << "\nThere are " << nPorts << " MIDI output ports available.\n";
|
||||
for ( i=0; i<nPorts; i++ ) {
|
||||
try {
|
||||
portName = midiout->getPortName(i);
|
||||
}
|
||||
catch ( RtError &error ) {
|
||||
error.printMessage();
|
||||
goto cleanup;
|
||||
}
|
||||
std::cout << " Output Port #" << i+1 << ": " << portName << '\n';
|
||||
}
|
||||
std::cout << '\n';
|
||||
|
||||
// Clean up
|
||||
cleanup:
|
||||
delete midiin;
|
||||
delete midiout;
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user