Changeset 77d8df8 in buchla-emu
- Timestamp:
- 01/05/2018 04:35:58 PM (7 years ago)
- Branches:
- master
- Children:
- 9ddbf3e
- Parents:
- 379ffd9
- Location:
- emu
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
emu/all.h
r379ffd9 r77d8df8 71 71 extern uint32_t lcd_win; 72 72 73 extern uint32_t mid_port; 74 73 75 extern void sdl_init(void); 74 76 extern void sdl_quit(void); … … 137 139 extern uint32_t mid_read(uint32_t off, int32_t sz); 138 140 extern void mid_write(uint32_t off, int32_t sz, uint32_t val); 141 extern void mid_list(void); 139 142 140 143 extern void fdd_init(void); -
emu/main.c
r379ffd9 r77d8df8 45 45 SDL_atomic_t run; 46 46 47 uint32_t mid_port = 0; 48 47 49 static void usage(FILE *fh) 48 50 { 49 fprintf(fh, "usage: buchla [-h] [-v comp [-v comp [...]]] [-b bios] [-d disk] [-f font] \n");51 fprintf(fh, "usage: buchla [-h] [-v comp [-v comp [...]]] [-b bios] [-d disk] [-f font] [-m midiport] \n"); 50 52 fprintf(fh, "where comp is one of: "); 51 53 … … 55 57 56 58 fprintf(fh, "all\n"); 59 fprintf(fh, "and midiport is the number of the desired MIDI port\n"); 60 fprintf(fh, "list all available MIDI ports with: buchla [-m list]\n"); 57 61 } 58 62 … … 130 134 continue; 131 135 } 136 137 if (strcmp(argv[i], "-m") == 0) { 138 if (++i == argc) { 139 usage(stderr); 140 fprintf(stderr, "missing argument to -m\n"); 141 exit(1); 142 } 143 144 if (strcmp(argv[i], "list") == 0) { 145 mid_list(); 146 exit(0); 147 continue; 148 } 149 150 // TODO: Assign midi port number 151 mid_port = (uint32_t) atoi(argv[i]); 152 continue; 153 } 132 154 } 133 155 } -
emu/mid.c
r379ffd9 r77d8df8 47 47 int32_t mid_verbose = 0; 48 48 49 struct RtMidiWrapper* mid iin;49 struct RtMidiWrapper* mid_in; 50 50 51 51 static void xmit(int32_t un) … … 105 105 } 106 106 107 static void mid i_callback(double timeStamp, const unsigned char* message, size_t size, void *userData) {107 static void mid_callback(double timeStamp, const unsigned char* message, size_t size, void *userData) { 108 108 (void) size; 109 109 (void) userData; … … 121 121 ver("mid init"); 122 122 123 mid iin = rtmidi_in_create_default();124 ver2("%p", mid iin->ptr);123 mid_in = rtmidi_in_create_default(); 124 ver2("%p", mid_in->ptr); 125 125 // check if null 126 uint32_t portcount = rtmidi_get_port_count(midiin); 127 ver2("%d", midiin->ok); 128 126 127 uint32_t portcount = rtmidi_get_port_count(mid_in); 129 128 if (portcount == 0) { 130 midiin = NULL; 131 ver2("no midi ports\n"); 132 return; 133 } 134 135 for (uint32_t i = 0; i < portcount; i++) { 136 ver2("Port %d: %s", i, rtmidi_get_port_name(midiin, i)); 137 } 138 139 rtmidi_open_port(midiin, 0, rtmidi_get_port_name(midiin, 0)); 140 if(!midiin->ok) { 141 fail("Failed to open Midi port"); 142 } 143 144 rtmidi_in_set_callback(midiin, midi_callback, midiin->data); 145 if(!midiin->ok) { 146 fail("Failed to set Midi Callback"); 129 mid_in = NULL; 130 ver2("No MIDI ports\n"); 131 return; 132 } 133 134 if (mid_port > portcount) { 135 mid_in = NULL; 136 ver2("Selected MIDI port larger than number of midi ports"); 137 return; 138 } 139 140 rtmidi_open_port(mid_in, mid_port, rtmidi_get_port_name(mid_in, mid_port)); 141 142 if(mid_in->ok == 0) { 143 fail("Failed to open MIDI port"); 144 } 145 146 ver2("Using MIDI port %u", mid_port); 147 148 rtmidi_in_set_callback(mid_in, mid_callback, mid_in->data); 149 150 if(mid_in->ok == 0) { 151 fail("Failed to set MIDI Callback"); 147 152 } 148 153 } … … 150 155 void mid_quit(void) 151 156 { 152 if(mid iin) {153 rtmidi_close_port(mid iin);154 rtmidi_in_free(mid iin);157 if(mid_in) { 158 rtmidi_close_port(mid_in); 159 rtmidi_in_free(mid_in); 155 160 } 156 161 … … 231 236 } 232 237 } 238 239 void mid_list(void) { 240 mid_in = rtmidi_in_create_default(); 241 242 uint32_t portcount = rtmidi_get_port_count(mid_in); 243 244 if (portcount == 0) { 245 mid_in = NULL; 246 ver2("no MIDI ports\n"); 247 return; 248 } 249 250 fprintf(stdout, "the following MIDI ports are available:\n"); 251 252 for (uint32_t i = 0; i < portcount; i++) { 253 fprintf(stdout, "port %d: %s\n", i, rtmidi_get_port_name(mid_in, i)); 254 } 255 256 rtmidi_in_free(mid_in); 257 }
Note:
See TracChangeset
for help on using the changeset viewer.