-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Device list never changes #4
Comments
Portmidi itself doesn't do this. I wrote a simple test program in C and verified that if I get all the devices periodically, the list does not change even when I detach MIDI devices/apps. I've copied the test program below in case anybody is interested. I'm closing this ticket. #include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include "portmidi.h"
void list(const char *title, const PmDeviceInfo *infos[], int num_devices) {
printf("%s:\n", title);
for (int i = 0; i < num_devices; ++i)
if (infos[i] != 0)
printf(" %s%s\n", infos[i]->name, infos[i]->opened ? " (open)" : "");
}
void list_all_devices() {
int num_devices = Pm_CountDevices();
const PmDeviceInfo *inputs[num_devices], *outputs[num_devices];
for (int i = 0; i < num_devices; ++i) {
const PmDeviceInfo *info = Pm_GetDeviceInfo(i);
inputs[i] = info->input ? info : 0;
outputs[i] = info->output ? info : 0;
}
list("Inputs", inputs, num_devices);
list("Outputs", outputs, num_devices);
}
int main(int argc, char **argv) {
for (;;) {
printf("\n\n\n");
list_all_devices();
sleep(5);
}
exit(0);
} |
Hi @jimm, thanks for pointing that out. I was having a look at this, and couldn't find any caching points, or similar issues. I might look into the Portmidi source code, to see if there is any way to refresh that list. |
Calling for (int i = 0; i < 5; ++i) {
printf("\n\n\n");
Pm_Initialize();
list_all_devices();
Pm_Terminate();
sleep(5);
} Here is the output, as I quit removed first SimpleSynth then MidiPipe:
So it looks like the count was updated the last time for some reason. Looking briefly at the portmidi code, it looks like the global pm_descriptor_index never gets reset to 0 in the code. I wonder if your C interface code could do that before calling Pm_Initialize. Also, when I added the MIDI apps back during a run, the count never got higher so I didn't see the newly added MIDI ports. I don't have time to poke around any more right now. |
I had the same issue today, especially relevant while working with LiveView + PortMIDI (see slides of a talk I gave recently for more context). If any of you found a proper work-around for this, I'm interested! |
From the PortMidi doc, sadly:
|
PortMidi.devices
never changes its return value while the app is running. If I attach/detach new MIDI devices or open MIDI apps that open MIDI input/output ports, callingPortMidi.devices
does not reflect the new list of available devices.The text was updated successfully, but these errors were encountered: