Changeset 9ddbf3e in buchla-emu
- Timestamp:
- 02/24/2018 06:51:40 PM (7 years ago)
- Branches:
- master
- Children:
- 2cd18e3
- Parents:
- 77d8df8
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
.cproject
r77d8df8 r9ddbf3e 25 25 </tool> 26 26 <tool id="cdt.managedbuild.tool.gnu.c.compiler.base.862022870" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.base"> 27 <option id="gnu.c.compiler.option.include.paths.2032588655" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">27 <option id="gnu.c.compiler.option.include.paths.2032588655" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath"> 28 28 <listOptionValue builtIn="false" value=""${workspace_loc:/buchla-emu/cpu}""/> 29 29 <listOptionValue builtIn="false" value=""${workspace_loc:/buchla-emu/emu}""/> 30 30 <listOptionValue builtIn="false" value=""${workspace_loc:/buchla-emu/build}""/> 31 31 <listOptionValue builtIn="false" value="/opt/sdl2/include"/> 32 <listOptionValue builtIn="false" value="/opt/rtmidi/include"/> 32 33 </option> 33 34 <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1138147073" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> -
.settings/language.settings.xml
r77d8df8 r9ddbf3e 6 6 <provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/> 7 7 <provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/> 8 <provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash=" -521499554224989883" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">8 <provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="882153106844088736" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true"> 9 9 <language-scope id="org.eclipse.cdt.core.gcc"/> 10 10 <language-scope id="org.eclipse.cdt.core.g++"/> -
Makefile
r77d8df8 r9ddbf3e 59 59 -framework AudioToolbox \ 60 60 -framework Carbon \ 61 -framework CoreMIDI \62 61 -framework CoreAudio \ 63 62 -framework CoreFoundation \ 64 63 -framework CoreGraphics \ 64 -framework CoreMIDI \ 65 65 -framework CoreVideo \ 66 66 -framework ForceFeedback \ … … 70 70 else 71 71 FLAGS_EMU += -D EMU_WIN 72 FLAGS_LNK := $(FLAGS) -Wall -Wextra -static -static-libstdc++72 FLAGS_LNK := $(FLAGS) -Wall -Wextra -static 73 73 LIBS := -l mingw32 \ 74 74 $(SDL2_LIB)/libSDL2.a \ -
emu/all.h
r77d8df8 r9ddbf3e 30 30 #include <SDL2/SDL_net.h> 31 31 #include <SDL2/SDL_ttf.h> 32 33 // work around RtMidi's C++-isms 34 35 #pragma GCC diagnostic push 36 #pragma GCC diagnostic ignored "-Wstrict-prototypes" 37 38 typedef struct RtMidiWrapper RtMidiWrapper; 39 40 #include <rtmidi/rtmidi_c.h> 41 42 #pragma GCC diagnostic pop 32 43 33 44 #define inf(...) SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__); … … 65 76 extern const char *font; 66 77 78 extern int32_t mid_port; 79 67 80 extern SDL_atomic_t run; 68 81 … … 70 83 extern uint32_t ser_win; 71 84 extern uint32_t lcd_win; 72 73 extern uint32_t mid_port;74 85 75 86 extern void sdl_init(void); -
emu/main.c
r77d8df8 r9ddbf3e 43 43 const char *font = "ttf/vera-sans-mono.ttf"; 44 44 45 int32_t mid_port = -1; 46 45 47 SDL_atomic_t run; 46 48 47 uint32_t mid_port = 0;48 49 49 static void usage(FILE *fh) 50 50 { 51 fprintf(fh, "usage: buchla [-h] [-v comp [-v comp [...]]] [-b bios] [-d disk] [-f font] [-m midiport] \n"); 52 fprintf(fh, "where comp is one of: "); 51 fprintf(fh, "usage: buchla [-h] [-v comp [-v comp [...]]] [-b bios] [-d disk] [-f font] [-m port]\n"); 52 fprintf(fh, "with\n"); 53 fprintf(fh, " comp - one of: "); 53 54 54 55 for (int32_t i = 0; i < ARRAY_COUNT(verb_flags); ++i) { … … 57 58 58 59 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"); 60 fprintf(fh, " bios - BIOS ROM file (default: bios.abs)\n"); 61 fprintf(fh, " disk - disk image file (default: buchla.disk)\n"); 62 fprintf(fh, " font - console and LCD font (default: ttf/vera-sans-mono.ttf)\n"); 63 fprintf(fh, " port - number of the desired MIDI port (default: 0)\n"); 64 fprintf(fh, " \"list\" instead of a port number lists available ports\n"); 61 65 } 62 66 … … 145 149 mid_list(); 146 150 exit(0); 147 continue; 148 } 149 150 // TODO: Assign midi port number 151 mid_port = (uint32_t) atoi(argv[i]); 151 } 152 153 char *end; 154 int64_t tmp = strtol(argv[i], &end, 10); 155 156 if (*end != 0 || tmp < 0 || tmp > 15) { 157 usage(stderr); 158 fprintf(stderr, "invalid argument to -m: %s\n", argv[i]); 159 exit(1); 160 } 161 162 mid_port = (int32_t)tmp; 152 163 continue; 153 164 } -
emu/mid.c
r77d8df8 r9ddbf3e 1 1 /* 2 * Copyright (C) 2017 The Contributors2 * Copyright (C) 2017-2018 The Contributors 3 3 * 4 4 * This program is free software: you can redistribute it and/or modify … … 17 17 18 18 #include <all.h> 19 #include <rtmidi/rtmidi_c.h>20 19 21 20 #define ver(...) _ver(mid_verbose, 0, __VA_ARGS__) 22 21 #define ver2(...) _ver(mid_verbose, 1, __VA_ARGS__) 23 22 #define ver3(...) _ver(mid_verbose, 2, __VA_ARGS__) 23 24 int32_t mid_verbose = 0; 24 25 25 26 #define REG_IER_ISR 0 … … 45 46 }; 46 47 47 int32_t mid_verbose = 0; 48 49 struct RtMidiWrapper* mid_in; 48 static struct RtMidiWrapper *mid_in = NULL; 50 49 51 50 static void xmit(int32_t un) … … 74 73 } 75 74 76 static void out_lk(int32_t un, uint8_t c) 77 { 75 static void out(int32_t un, uint8_t c) 76 { 77 if (SDL_LockMutex(cpu_mutex) < 0) { 78 fail("SDL_LockMutex() failed: %s", SDL_GetError()); 79 } 80 78 81 int32_t i = state[un].buf_hd; 79 82 ver2("mid out %d %d 0x%02x", state[un].buf_tl, i, c); … … 90 93 xmit(un); 91 94 } 92 }93 94 static void out(int32_t un, uint8_t c)95 {96 if (SDL_LockMutex(cpu_mutex) < 0) {97 fail("SDL_LockMutex() failed: %s", SDL_GetError());98 }99 100 out_lk(un, c);101 95 102 96 if (SDL_UnlockMutex(cpu_mutex) < 0) { … … 105 99 } 106 100 107 static void mid_callback(double timeStamp, const unsigned char* message, size_t size, void *userData) { 108 (void) size; 109 (void) userData; 110 111 ver2("Timestamp %f\n", timeStamp); 112 113 for (uint8_t i = 0; i < sizeof(message); i++) { 114 ver2("Message %i %u", i, (uint8_t) message[i]); 115 out(0, message[i]); 101 static void callback(double time, const uint8_t *midi, void *data) 102 { 103 (void)data; 104 105 int32_t len; 106 107 switch (midi[0] & 0xf0) { 108 case 0x80: // note on 109 case 0x90: // note off 110 case 0xa0: // polyphonic key pressure 111 case 0xb0: // control change 112 case 0xe0: // pitch bend change 113 len = 3; 114 break; 115 116 case 0xc0: // program change 117 case 0xd0: // channel pressure 118 len = 2; 119 break; 120 121 case 0xf0: 122 switch (midi[0]) { 123 case 0xf0: // system exclusive 124 case 0xf4: // undefined 125 case 0xf5: // undefined 126 case 0xf7: // end of exclusive 127 case 0xf9: // undefined 128 case 0xfd: // undefined 129 len = -1; 130 break; 131 132 case 0xf1: // MIDI time code quarter frame 133 case 0xf3: // song select 134 len = 2; 135 break; 136 137 case 0xf2: // song position pointer 138 len = 3; 139 break; 140 141 case 0xf6: // tune request 142 case 0xf8: // timing clock 143 case 0xfa: // start 144 case 0xfb: // continue 145 case 0xfc: // stop 146 case 0xfe: // active sensing 147 case 0xff: // reset 148 len = 1; 149 break; 150 } 151 152 break; 153 } 154 155 ver2("time %f", time); 156 157 for (int32_t i = 0; i < len; ++i) { 158 ver2("midi[%d] 0x%02x", i, midi[i]); 159 out(0, midi[i]); 116 160 } 117 161 } … … 121 165 ver("mid init"); 122 166 167 if (mid_port < 0) { 168 ver("no MIDI requested"); 169 return; 170 } 171 123 172 mid_in = rtmidi_in_create_default(); 124 ver2("%p", mid_in->ptr); 125 // check if null 126 127 uint32_t portcount = rtmidi_get_port_count(mid_in); 128 if (portcount == 0) { 173 174 if (!mid_in->ok) { 175 fail("rtmidi_in_create_default() failed: %s", mid_in->msg); 176 } 177 178 int32_t n_ports = (int32_t)rtmidi_get_port_count(mid_in); 179 180 if (n_ports == 0) { 181 inf("no MIDI ports\n"); 182 rtmidi_in_free(mid_in); 129 183 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"); 184 return; 185 } 186 187 if (mid_port >= n_ports) { 188 fail("invalid MIDI port %d selected (%d available)", mid_port, n_ports); 189 } 190 191 const char *name = rtmidi_get_port_name(mid_in, (uint32_t)mid_port); 192 rtmidi_open_port(mid_in, (uint32_t)mid_port, name); 193 194 if (!mid_in->ok) { 195 fail("error while opening MIDI port %d (%s): %s", mid_port, name, mid_in->msg); 196 } 197 198 inf("using MIDI port %d (%s)", mid_port, name); 199 200 rtmidi_in_set_callback(mid_in, callback, mid_in->data); 201 202 if (!mid_in->ok) { 203 fail("rtmidi_in_set_callback() failed: %s", mid_in->msg); 152 204 } 153 205 } … … 155 207 void mid_quit(void) 156 208 { 157 if(mid_in) {158 rtmidi_close_port(mid_in);159 rtmidi_in_free(mid_in);160 }161 162 209 ver("mid quit"); 210 211 if (mid_in == NULL) { 212 return; 213 } 214 215 rtmidi_close_port(mid_in); 216 rtmidi_in_free(mid_in); 163 217 } 164 218 … … 237 291 } 238 292 239 void mid_list(void) { 293 void mid_list(void) 294 { 240 295 mid_in = rtmidi_in_create_default(); 241 296 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)); 297 if (!mid_in->ok) { 298 fprintf(stderr, "rtmidi_in_create_default() failed: %s\n", mid_in->msg); 299 return; 300 } 301 302 uint32_t n_ports = rtmidi_get_port_count(mid_in); 303 304 if (n_ports == 0) { 305 fprintf(stdout, "no available MIDI ports\n"); 306 } 307 else { 308 for (uint32_t i = 0; i < n_ports; i++) { 309 fprintf(stdout, "port %u: %s\n", i, rtmidi_get_port_name(mid_in, i)); 310 } 254 311 } 255 312 -
readme.txt
r77d8df8 r9ddbf3e 93 93 make 94 94 make install 95 96 # Build and install rtmidi97 95 96 # Build and install RtMidi 97 98 98 tar zxvf rtmidi-3.0.0.tar.gz 99 99 cd rtmidi-3.0.0 100 100 mkdir build 101 101 cd build 102 102 103 103 ../configure --prefix=/opt/rtmidi 104 104 105 105 make 106 106 make install … … 116 116 117 117 * We use "--prefix=/opt/sdl2-win" instead of "--prefix=/opt/sdl2", 118 so that the Windows versions of the libraries go to a different 119 directory. That's where our Makefile expects to find them when 120 cross-building. 118 so that the Windows versions of the SDL2 libraries go to a 119 different directory. That's where our Makefile expects to find 120 them when cross-building. 121 122 Analogously, we use "--prefix=/opt/rtmidi-win" when building 123 RtMidi. 121 124 122 125 * We additionally specify "--host=x86_64-w64-mingw32" to enable
Note:
See TracChangeset
for help on using the changeset viewer.