Skip to content

Instantly share code, notes, and snippets.

@Pokechu22
Created July 17, 2017 19:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pokechu22/19cb535340ffb3b2feea474ac8799fe1 to your computer and use it in GitHub Desktop.
Save Pokechu22/19cb535340ffb3b2feea474ac8799fe1 to your computer and use it in GitHub Desktop.
Portmidi test program that works
#include "portmidi.h"
#include <iostream>
void writeDevice(PmDeviceID id) {
std::cout << "Device #" << id << ":\n";
const PmDeviceInfo* device = Pm_GetDeviceInfo(id);
std::cout << "\tstructVersion: " << device->structVersion << "\n";
std::cout << "\tinterf: " << device->interf << "\n";
std::cout << "\tname: " << device->name << "\n";
std::cout << "\tinput: " << device->input << "\n";
std::cout << "\toutput: " << device->output << "\n";
std::cout << "\topened: " << device->opened << "\n";
std::cout << std::endl;
}
int main() {
Pm_Initialize();
int numDev = Pm_CountDevices();
std::cout << "There are " << numDev << " devices" << std::endl;
for (int i = 0; i < numDev; i++) {
writeDevice(i);
}
std::cout << "Default in: " << Pm_GetDefaultInputDeviceID() << "\n";
std::cout << "Default out: " << Pm_GetDefaultOutputDeviceID() << std::endl;
Pm_Terminate();
return 0;
}
@Pokechu22
Copy link
Author

Output on my pi:

There are 4 devices
Device #0:
        structVersion: 1994328172
        interf: ALSA
        name: Midi Through Port-0
        input: 0
        output: 1
        opened: 0

Device #1:
        structVersion: 0
        interf: ALSA
        name: Midi Through Port-0
        input: 1
        output: 0
        opened: 0

Device #2:
        structVersion: 0
        interf: ALSA
        name: TiMidity (BK) port 0
        input: 0
        output: 1
        opened: 0

Device #3:
        structVersion: 0
        interf: ALSA
        name: TiMidity (freepats) port 0
        input: 0
        output: 1
        opened: 0

Default in: 1
Default out: 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment