1

I have this problem: i want to create a midi synthesizer in C,linux. Since I don't have a USB midi keyboard, I thought about using a virtual midi divice like VMPK. I found this code in a book that also explained how to use the portmidi library:

#include <stdio.h>
#include <portmidi.h>
#include <porttime.h>

int main() {
int cnt,i,dev;
PmError retval;
const PmDeviceInfo *info;
PmEvent msg[32];
PortMidiStream *mstream;
Pm_Initialize();
cnt = Pm_CountDevices();
if(cnt) {
          for(i=0; i < cnt; i++){
              info = Pm_GetDeviceInfo(i);
              if(info->input)
              printf("%d: %s \n", i, info->name);
          }
          printf("choose device: ");
          scanf("%d", &dev);
          Pt_Start(1, NULL, NULL);
          retval = Pm_OpenInput(&mstream, dev, NULL, 512L, NULL,NULL);
          if(retval != pmNoError)
          printf("error: %s \n", Pm_GetErrorText(retval));
          else {
                 while(Pt_Time(NULL) < 60000){
                 if(Pm_Poll(mstream)) {
                     cnt = Pm_Read(mstream, msg, 32);
                     for(i=0; i<cnt; i++) {
                          printf("status:%d, byte1=%d, "
                          "byte2=%d, time=%.3f\n",
                          Pm_MessageStatus(msg[i].message),
                          Pm_MessageData1(msg[i].message),
                          Pm_MessageData2(msg[i].message),
                          msg[i].timestamp/1000.);
                   }
               }
            }
        }
       Pm_Close(mstream); 
   }
}

  else printf("No MIDI devices found\n");
 Pm_Terminate();
 return 0;
}

In short, once the program connects with a MIDI input device, it listens for 60 all the messages that come from them, (Printing the status byte and the two data bytes, as a midi protocol)

When I launch VMPK, it appears that the program reveals VMPK as midi input, under the name "out" Program output I also checked the "JACK audio connection" program to verify that VMPK was revealed as a MIDI input device JACK audio output

I don't understand why when I press a key from the VMPK keyboard, I don't receive any messages from the program ...

I tried to change the VMPK configuration, but I didn't get any changes.

VMPK configuration menu

Maybe I'm doing something wrong in the VMPK configuration.

Any help is welcome.

I thank you in advance for your availability

KemKing
  • 11
  • 3

1 Answers1

0

ok, I found the problem. As I said, I set VMPK badly. If you set it this way, you can detect MIDI inputs VMPK setup

This is the output of programm: enter image description here

KemKing
  • 11
  • 3