summaryrefslogtreecommitdiff
path: root/example3.c
diff options
context:
space:
mode:
Diffstat (limited to 'example3.c')
-rw-r--r--example3.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/example3.c b/example3.c
new file mode 100644
index 0000000..9dea995
--- /dev/null
+++ b/example3.c
@@ -0,0 +1,53 @@
1#include <stdio.h>
2#include <stdlib.h>
3#include <string.h>
4
5#include "portmidi/pm_common/portmidi.h"
6
7#define NUM_INPUTS 16
8
9int main() {
10 PmError err;
11 PmStream *stream;
12 PmEvent events[128];
13 int i, num_events;
14
15 // Initialize PortMIDI
16 err = Pm_Initialize();
17 if (err != pmNoError) {
18 fprintf(stderr, "Error initializing PortMIDI: %s\n", Pm_GetErrorText(err));
19 exit(1);
20 }
21
22 /* // Open a MIDI input device */
23 /* stream = Pm_OpenInput(&err, NULL, NULL, NUM_INPUTS, NULL, 0); */
24 /* if (err != pmNoError) { */
25 /* fprintf(stderr, "Error opening MIDI input device: %s\n", Pm_GetErrorText(err)); */
26 /* Pm_Terminate(); */
27 /* exit(1); */
28 /* } */
29
30 /* // Read MIDI messages from the input device */
31 /* while (1) { */
32 /* num_events = Pm_Read(stream, events, 128); */
33 /* if (num_events > 0) { */
34 /* for (i = 0; i < num_events; i++) { */
35 /* if (events[i].message & 0xff00) { */
36 /* // This is a status message (note on, note off, etc.) */
37 /* printf("Message: 0x%02x\n", events[i].message); */
38 /* /1* printf("Status: 0x%02x, Data 1: 0x%02x, Data 2: 0x%02x\n", *1/ */
39 /* /1* events[i].message & 0xf0, events[i].message[0], events[i].message[1]); *1/ */
40 /* } */
41 /* } */
42 /* } */
43 /* } */
44
45 /* // Close the MIDI input device */
46 /* Pm_Close(stream); */
47
48 // Terminate PortMIDI
49 Pm_Terminate();
50
51 return 0;
52}
53