| 1 | /* |
| 2 | * |
| 3 | * Copyright (C) 1999-2003 Steve Ratcliffe |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License version 2 as |
| 7 | * published by the Free Software Foundation. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | */ |
| 15 | |
| 16 | |
| 17 | #include "glib.h"cxx . . $ `<file>/src/glib.h`/ |
| 18 | #include "elements.h"cxx . . $ `<file>/src/elements.h`/ |
| 19 | #include "except.h"cxx . . $ `<file>/src/except.h`/ |
| 20 | #include "intl.h"cxx . . $ `<file>/src/intl.h`/ |
| 21 | |
| 22 | #if HAVE_ALSA_ASOUNDLIB_Hcxx . . $ `<built-in>:434:9`! |
| 23 | #include <alsa/asoundlib.h> |
| 24 | #else |
| 25 | #include <sys/asoundlib.h> |
| 26 | #endif |
| 27 | |
| 28 | #include <stdio.h> |
| 29 | #include "seqlib.h"cxx . . $ `<file>/src/seqlib.h`/ |
| 30 | #include "md.h"cxx . . $ `<file>/src/md.h`/ |
| 31 | #include "midi.h"cxx . . $ `<file>/src/midi.h`/ |
| 32 | #include <stdlib.h> |
| 33 | #include <unistd.h> |
| 34 | #include <getopt.h> |
| 35 | #include <string.h> |
| 36 | #include <errno.h> |
| 37 | #include <signal.h> |
| 38 | |
| 39 | /* |
| 40 | * Play a midi file |
| 41 | * pmidi [-p client:port,... ] [-l] [-d delay] file ... |
| 42 | * |
| 43 | * -p client:port - A alsa client and port number to send midi to |
| 44 | * -l - List possible output ports that could be used |
| 45 | * -d delay - Delay after song ends (default 2 sec) |
| 46 | * -v - Print version and exit |
| 47 | */ |
| 48 | |
| 49 | |
| 50 | /* Options for the command */ |
| 51 | #define HAS_ARGcxx . . $ `src/pmidi.c:51:9`! 1 |
| 52 | static struct optioncxx . . $ option# long_optscxx . . $ long_opts.[] = { |
| 53 | {"port", HAS_ARGcxx . . $ `src/pmidi.c:51:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 'p'}, |
| 54 | {"list", 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 'l'}, |
| 55 | {"delay", HAS_ARGcxx . . $ `src/pmidi.c:51:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 'd'}, |
| 56 | {"version", 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 'v'}, |
| 57 | {0, 0, 0, 0}, |
| 58 | }; |
| 59 | |
| 60 | /* Delay at the end of a song */ |
| 61 | static int delaycxx . . $ delay. = 2; |
| 62 | |
| 63 | /* Pointer to root context */ |
| 64 | seq_context_tcxx . . $ seq_context_t# *g_ctxpcxx . . $ g_ctxp.; |
| 65 | |
| 66 | /* Number of elements in an array */ |
| 67 | #define NELEMcxx . . $ `src/pmidi.c:67:9`!(a) ( sizeof(a)/sizeof((a)[0]) ) |
| 68 | |
| 69 | #define ADDR_PARTScxx . . $ `src/pmidi.c:69:9`! 4 /* Number of part in a port description addr 1:2:3:4 */ |
| 70 | #define SEPcxx . . $ `src/pmidi.c:70:9`! ", \t" /* Separators for port description */ |
| 71 | |
| 72 | static seq_context_tcxx . . $ seq_context_t# *openportscxx . . $ openports(12c82364b08d2ff9).(char *portdesc); |
| 73 | static void playfilecxx . . $ playfile(8d57acc3f9f7192d).(seq_context_tcxx . . $ seq_context_t# *ctxp, char *filename); |
| 74 | static void showlistcxx . . $ showlist(d878ad36e69247c7).(); |
| 75 | static void showusagecxx . . $ showusage(d878ad36e69247c7).(); |
| 76 | static void playcxx . . $ play(1d7217e49abd411b).(void *arg, struct elementcxx . . $ element# *el); |
| 77 | static void no_errors_pleasecxx . . $ no_errors_please(588371637176764f).(const char *file, int line, const char *function, int err, const char *fmt, ...); |
| 78 | static void set_signal_handlercxx . . $ set_signal_handler(e410d57486f0cd63).(seq_context_tcxx . . $ seq_context_t# *ctxp); |
| 79 | static void signal_handlercxx . . $ signal_handler(d4f767463ce0a6b3).(int sig); |
| 80 | static void showversioncxx . . $ showversion(49f6e7a06ebc5aa8).(void); |
| 81 | |
| 82 | /* |
| 83 | * Play a midi file |
| 84 | * pmidi [-p client:port ...] [-l] [-d delay] file ... |
| 85 | * |
| 86 | * -p, --port=client:port - An ALSA client and port number to use |
| 87 | * -l, --list - List possible output ports that could be used |
| 88 | * -d, --delay=SECS - Delay after song ends (default 2 sec) |
| 89 | * -v, --version - Show version number |
| 90 | * Arguments: |
| 91 | * argc - arg count |
| 92 | * argv - arg vector |
| 93 | */ |
| 94 | int |
| 95 | maincxx . . $ main(afcd3168fc1188a4).(int argc, char **argv) |
| 96 | { |
| 97 | char opts[NELEMcxx . . $ `src/pmidi.c:67:9`!(long_opts) * 2 + 1]; |
| 98 | char *portdesc; |
| 99 | seq_context_tcxx . . $ seq_context_t# *ctxp; |
| 100 | char *cp; |
| 101 | int c; |
| 102 | struct optioncxx . . $ option# *op; |
| 103 | |
| 104 | /* Build up the short option string */ |
| 105 | cp = opts; |
| 106 | for (op = long_optscxx . . $ long_opts.; op < &long_optscxx . . $ long_opts.[NELEMcxx . . $ `src/pmidi.c:67:9`!(long_opts)]; op++) { |
| 107 | *cp++ = op->valcxx . . $ option#val.; |
| 108 | if (op->has_argcxx . . $ option#has_arg.) |
| 109 | *cp++ = ':'; |
| 110 | } |
| 111 | |
| 112 | /* Libaries shouldn't print errors by default! */ |
| 113 | snd_lib_error_set_handlercxx . . $ snd_lib_error_set_handler(c1eaf0cc6e7f597e).(no_errors_pleasecxx . . $ no_errors_please(588371637176764f).); |
| 114 | |
| 115 | portdesc = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 116 | |
| 117 | /* Deal with the options */ |
| 118 | for (;;) { |
| 119 | c = getopt_longcxx . . $ getopt_long(41f665c090816971).(argc, argv, opts, long_optscxx . . $ long_opts., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 120 | if (c == -1) |
| 121 | break; |
| 122 | |
| 123 | switch(c) { |
| 124 | case 'p': |
| 125 | portdesc = optargcxx . . $ optarg.; |
| 126 | break; |
| 127 | case 'd': |
| 128 | delaycxx . . $ delay. = atoicxx . . $ atoi(5c4306d8553b3696).(optargcxx . . $ optarg.); |
| 129 | break; |
| 130 | case 'l': |
| 131 | showlistcxx . . $ showlist(d878ad36e69247c7).(); |
| 132 | exitcxx . . $ exit(3ca292c338df9bb3).(0); |
| 133 | break; |
| 134 | case 'v': |
| 135 | showversioncxx . . $ showversion(49f6e7a06ebc5aa8).(); |
| 136 | exitcxx . . $ exit(3ca292c338df9bb3).(0); |
| 137 | case '?': |
| 138 | showusagecxx . . $ showusage(d878ad36e69247c7).(); |
| 139 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | if (portdesc == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || portdesc[0] == '\0') { |
| 144 | portdesc = getenvcxx . . $ getenv(a8b8e32347182212).("ALSA_OUTPUT_PORTS"); |
| 145 | /* Try the old name for the environment variable */ |
| 146 | if (portdesc == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 147 | portdesc = getenvcxx . . $ getenv(a8b8e32347182212).("ALSA_OUT_PORT"); |
| 148 | if (portdesc == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 149 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "No client/port specified.\n" |
| 150 | "You must supply one with the -p option or with the\n" |
| 151 | "environment variable ALSA_OUTPUT_PORTS\n" |
| 152 | ); |
| 153 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | ctxp = openportscxx . . $ openports(12c82364b08d2ff9).(portdesc); |
| 158 | if (ctxp == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 159 | return 1; |
| 160 | |
| 161 | /* Set signal handler */ |
| 162 | set_signal_handlercxx . . $ set_signal_handler(e410d57486f0cd63).(ctxp); |
| 163 | |
| 164 | /* Now play all the files */ |
| 165 | for (; optindcxx . . $ optind. < argc; optindcxx . . $ optind.++) |
| 166 | playfilecxx . . $ playfile(8d57acc3f9f7192d).(ctxp, argv[optindcxx . . $ optind.]); |
| 167 | |
| 168 | seq_free_contextcxx . . $ seq_free_context(e410d57486f0cd63).(ctxp); |
| 169 | |
| 170 | /* Restore signal handler */ |
| 171 | signalcxx . . $ signal(c2d516773f91faf8).(SIGINTcxx . . $ `<external>/11773118241360591791/signum-generic.h:48:9`!, SIG_DFLcxx . . $ `<external>/11773118241360591791/signum-generic.h:29:9`!); |
| 172 | |
| 173 | return 0; |
| 174 | } |
| 175 | |
| 176 | /* |
| 177 | * Read a list of client/port specifications and return an |
| 178 | * array of snd_seq_addr_t that describes them. |
| 179 | * |
| 180 | * Arguments: |
| 181 | * portdesc - |
| 182 | */ |
| 183 | static seq_context_tcxx . . $ seq_context_t# * |
| 184 | openportscxx . . $ openports(12c82364b08d2ff9).(char *portdesc) |
| 185 | { |
| 186 | char *astr; |
| 187 | char *cp; |
| 188 | seq_context_tcxx . . $ seq_context_t# *ctxp; |
| 189 | snd_seq_addr_tcxx . . $ snd_seq_addr_t# *addr; |
| 190 | snd_seq_addr_tcxx . . $ snd_seq_addr_t# *ap; |
| 191 | int a[ADDR_PARTScxx . . $ `src/pmidi.c:69:9`!]; |
| 192 | int count, naddr; |
| 193 | int i; |
| 194 | |
| 195 | if (portdesc == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 196 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 197 | |
| 198 | ctxp = seq_create_contextcxx . . $ seq_create_context(41f2338c700f0527).(); |
| 199 | |
| 200 | addr = g_newcxx . . $ `src/glib.h:310:11`!(snd_seq_addr_t, strlen(portdesc)); |
| 201 | |
| 202 | naddr = 0; |
| 203 | ap = addr; |
| 204 | |
| 205 | for (astr = strtokcxx . . $ strtok(b7b3a83273496486).(portdesc, SEPcxx . . $ `src/pmidi.c:70:9`!); astr; astr = strtokcxx . . $ strtok(b7b3a83273496486).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, SEPcxx . . $ `src/pmidi.c:70:9`!)) { |
| 206 | for (cp = astr, count = 0; cp && *cp; cp++) { |
| 207 | if (count < ADDR_PARTScxx . . $ `src/pmidi.c:69:9`!) |
| 208 | a[count++] = atoicxx . . $ atoi(5c4306d8553b3696).(cp); |
| 209 | cp = strchrcxx . . $ strchr(2050848944e00d54).(cp, ':'); |
| 210 | if (cp == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 211 | break; |
| 212 | } |
| 213 | |
| 214 | switch (count) { |
| 215 | case 2: |
| 216 | ap->clientcxx . . $ snd_seq_addr#client. = a[0]; |
| 217 | ap->portcxx . . $ snd_seq_addr#port. = a[1]; |
| 218 | break; |
| 219 | default: |
| 220 | printfcxx . . $ printf(581fddd72a8db8fc).("Addresses in %d parts not supported yet\n", count); |
| 221 | break; |
| 222 | } |
| 223 | ap++; |
| 224 | naddr++; |
| 225 | } |
| 226 | |
| 227 | count = 0; |
| 228 | for (i = 0; i < naddr; i++) { |
| 229 | int err; |
| 230 | |
| 231 | err = seq_connect_addcxx . . $ seq_connect_add(68dd04cef335395).(ctxp, addr[i].clientcxx . . $ snd_seq_addr#client., addr[i].portcxx . . $ snd_seq_addr#port.); |
| 232 | if (err < 0) { |
| 233 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, _cxx . . $ `src/intl.h:25:9`!("Could not connect to port %d:%d\n"), |
| 234 | addr[i].clientcxx . . $ snd_seq_addr#client., addr[i].portcxx . . $ snd_seq_addr#port.); |
| 235 | } else |
| 236 | count++; |
| 237 | } |
| 238 | |
| 239 | g_freecxx . . $ `src/glib.h:1302:9`!(addr); |
| 240 | |
| 241 | if (count == 0) { |
| 242 | seq_free_contextcxx . . $ seq_free_context(e410d57486f0cd63).(ctxp); |
| 243 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 244 | } |
| 245 | |
| 246 | return ctxp; |
| 247 | } |
| 248 | |
| 249 | /* |
| 250 | * Play a single file. |
| 251 | * Arguments: |
| 252 | * ctxp - |
| 253 | * filename - |
| 254 | */ |
| 255 | static void |
| 256 | playfilecxx . . $ playfile(8d57acc3f9f7192d).(seq_context_tcxx . . $ seq_context_t# *ctxp, char *filename) |
| 257 | { |
| 258 | struct rootElementcxx . . $ rootElement# *root; |
| 259 | struct sequenceStatecxx . . $ sequenceState# *seq; |
| 260 | struct elementcxx . . $ element# *el; |
| 261 | unsigned long end; |
| 262 | snd_seq_event_tcxx . . $ snd_seq_event_t# *ep; |
| 263 | |
| 264 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(filename, "-") == 0) |
| 265 | root = midi_readcxx . . $ midi_read(9201eb812a2a11b2).(stdincxx . . $ `<external>/232824719582829767/stdio.h:153:9`!); |
| 266 | else |
| 267 | root = midi_read_filecxx . . $ midi_read_file(b4c60c77fa660fcd).(filename); |
| 268 | if (!root) |
| 269 | return; |
| 270 | |
| 271 | /* Loop through all the elements in the song and play them */ |
| 272 | seq = md_sequence_initcxx . . $ md_sequence_init(7a1012fd3b1c8308).(root); |
| 273 | while ((el = md_sequence_nextcxx . . $ md_sequence_next(6d4a417716755e0b).(seq)) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 274 | playcxx . . $ play(1d7217e49abd411b).(ctxp, el); |
| 275 | } |
| 276 | |
| 277 | |
| 278 | /* Get the end time for the tracks and echo an event to |
| 279 | * wake us up at that time |
| 280 | */ |
| 281 | end = md_sequence_end_timecxx . . $ md_sequence_end_time(c476a0bb7caa0ca8).(seq); |
| 282 | seq_midi_echocxx . . $ seq_midi_echo(57fef5ba8926da1a).(ctxp, end); |
| 283 | |
| 284 | #ifdef USE_DRAINcxx . . $ `<built-in>:421:9`! |
| 285 | snd_seq_drain_outputcxx . . $ snd_seq_drain_output(13c0955b497a8b28).(seq_handlecxx . . $ seq_handle(43ef867995de2152).(ctxp)); |
| 286 | #else |
| 287 | snd_seq_flush_output(seq_handle(ctxp)); |
| 288 | #endif |
| 289 | |
| 290 | /* Wait for all the events to be played */ |
| 291 | snd_seq_event_inputcxx . . $ snd_seq_event_input(21311b482d7c966a).(seq_handlecxx . . $ seq_handle(43ef867995de2152).(ctxp), &ep); |
| 292 | |
| 293 | /* Wait some extra time to allow for note to decay etc */ |
| 294 | sleepcxx . . $ sleep(2141b656ce2cc063).(delaycxx . . $ delay.); |
| 295 | seq_stop_timercxx . . $ seq_stop_timer(e410d57486f0cd63).(ctxp); |
| 296 | |
| 297 | md_freecxx . . $ md_free(c289bede69bef025).(MD_ELEMENTcxx . . $ `src/elements.h:33:9`!(root)); |
| 298 | } |
| 299 | |
| 300 | /* |
| 301 | * Show a list of possible output ports that midi could be sent |
| 302 | * to. |
| 303 | */ |
| 304 | static void |
| 305 | showlistcxx . . $ showlist(d878ad36e69247c7).() |
| 306 | { |
| 307 | snd_seq_client_info_tcxx . . $ snd_seq_client_info_t# *cinfo; |
| 308 | snd_seq_port_info_tcxx . . $ snd_seq_port_info_t# *pinfo; |
| 309 | int client; |
| 310 | int err; |
| 311 | snd_seq_tcxx . . $ snd_seq_t# *handle; |
| 312 | |
| 313 | err = snd_seq_opencxx . . $ snd_seq_open(b4c7df1da4c88f65).(&handle, "hw", SND_SEQ_OPEN_DUPLEXcxx . . $ `<external>/4963296836554771614/seq.h:60:9`!, 0); |
| 314 | if (err < 0) |
| 315 | exceptcxx . . $ except(af5967826b8ba103).(ioErrorcxx . . $ ioError., _cxx . . $ `src/intl.h:25:9`!("Could not open sequencer %s"), snd_strerrorcxx . . $ snd_strerror(f7ae7e56280f18ae).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 316 | |
| 317 | #ifdef USE_DRAINcxx . . $ `<built-in>:421:9`! |
| 318 | /* |
| 319 | * NOTE: This is here so that it will give an error if the wrong |
| 320 | * version of alsa is used with USE_DRAIN set. An incompatible change |
| 321 | * was made to ALSA on 29 Sep 2000 so that after that date you should |
| 322 | * define USE_DRAIN. |
| 323 | * |
| 324 | * Unfortunately with USE_DRAIN defined with an earlier version of alsa |
| 325 | * it will appear to compile fine but simply not work properly. This |
| 326 | * unneeded call will give an error in this case. |
| 327 | * |
| 328 | * IF you see an error about this line, comment out the line beginning |
| 329 | * with USE_DRAIN in the make.conf file or compile with: |
| 330 | * make USE_DRAIN='' |
| 331 | */ |
| 332 | snd_seq_drop_outputcxx . . $ snd_seq_drop_output(13c0955b497a8b28).(handle); |
| 333 | #endif |
| 334 | |
| 335 | snd_seq_client_info_allocacxx . . $ `<external>/4963296836554771614/seq.h:148:9`!(&cinfo); |
| 336 | snd_seq_client_info_set_clientcxx . . $ snd_seq_client_info_set_client(db2bab9dc0ee441).(cinfo, -1); |
| 337 | printfcxx . . $ printf(581fddd72a8db8fc).(_cxx . . $ `src/intl.h:25:9`!(" Port %-30.30s %s\n"), _cxx . . $ `src/intl.h:25:9`!("Client name"), _cxx . . $ `src/intl.h:25:9`!("Port name")); |
| 338 | |
| 339 | while (snd_seq_query_next_clientcxx . . $ snd_seq_query_next_client(ffffd5e0fbe977cd).(handle, cinfo) >= 0) { |
| 340 | client = snd_seq_client_info_get_clientcxx . . $ snd_seq_client_info_get_client(780e688588cd6fa7).(cinfo); |
| 341 | snd_seq_port_info_allocacxx . . $ `<external>/4963296836554771614/seq.h:304:9`!(&pinfo); |
| 342 | snd_seq_port_info_set_clientcxx . . $ snd_seq_port_info_set_client(390739811a59ed8a).(pinfo, client); |
| 343 | |
| 344 | snd_seq_port_info_set_portcxx . . $ snd_seq_port_info_set_port(390739811a59ed8a).(pinfo, -1); |
| 345 | while (snd_seq_query_next_portcxx . . $ snd_seq_query_next_port(e5a3a153e50c93f9).(handle, pinfo) >= 0) { |
| 346 | int cap; |
| 347 | |
| 348 | cap = (SND_SEQ_PORT_CAP_SUBS_WRITEcxx . . $ `<external>/4963296836554771614/seq.h:252:9`!|SND_SEQ_PORT_CAP_WRITEcxx . . $ `<external>/4963296836554771614/seq.h:244:9`!); |
| 349 | if ((snd_seq_port_info_get_capabilitycxx . . $ snd_seq_port_info_get_capability(6f685c642bf5a77a).(pinfo) & cap) == cap) { |
| 350 | printfcxx . . $ printf(581fddd72a8db8fc).("%3d:%-3d %-30.30s %s\n", |
| 351 | snd_seq_port_info_get_clientcxx . . $ snd_seq_port_info_get_client(8ec1ab37020ba619).(pinfo), |
| 352 | snd_seq_port_info_get_portcxx . . $ snd_seq_port_info_get_port(8ec1ab37020ba619).(pinfo), |
| 353 | snd_seq_client_info_get_namecxx . . $ snd_seq_client_info_get_name(284e8cd442e228f6).(cinfo), |
| 354 | snd_seq_port_info_get_namecxx . . $ snd_seq_port_info_get_name(b0e200cfdaf4d0a4).(pinfo) |
| 355 | ); |
| 356 | } |
| 357 | } |
| 358 | } |
| 359 | } |
| 360 | |
| 361 | /* |
| 362 | * Show a usage message |
| 363 | */ |
| 364 | static void |
| 365 | showusagecxx . . $ showusage(d878ad36e69247c7).() |
| 366 | { |
| 367 | char **cpp; |
| 368 | static char *msg[] = { |
| 369 | N_cxx . . $ `src/intl.h:26:9`!("Usage: pmidi [-p client:port ...] [-l] [-d delay] file ..."), |
| 370 | "", |
| 371 | N_cxx . . $ `src/intl.h:26:9`!(" -p client:port - A alsa client and port number to send midi to"), |
| 372 | N_cxx . . $ `src/intl.h:26:9`!(" -l - List possible output ports that could be used"), |
| 373 | N_cxx . . $ `src/intl.h:26:9`!(" -d delay - Delay after song ends (default 2 sec)"), |
| 374 | N_cxx . . $ `src/intl.h:26:9`!(" -v - Print version and exit"), |
| 375 | }; |
| 376 | |
| 377 | for (cpp = msg; cpp < msg+NELEMcxx . . $ `src/pmidi.c:67:9`!(msg); cpp++) { |
| 378 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s\n", _cxx . . $ `src/intl.h:25:9`!(*cpp)); |
| 379 | } |
| 380 | } |
| 381 | |
| 382 | static void |
| 383 | showversioncxx . . $ showversion(49f6e7a06ebc5aa8).() |
| 384 | { |
| 385 | printfcxx . . $ printf(581fddd72a8db8fc).("pmidi-%s\n", VERSIONcxx . . $ `<built-in>:419:9`!); |
| 386 | } |
| 387 | |
| 388 | static void |
| 389 | playcxx . . $ play(1d7217e49abd411b).(void *arg, struct elementcxx . . $ element# *el) |
| 390 | { |
| 391 | seq_context_tcxx . . $ seq_context_t# *ctxp = arg; |
| 392 | snd_seq_event_tcxx . . $ snd_seq_event_t# ev; |
| 393 | |
| 394 | seq_midi_event_initcxx . . $ seq_midi_event_init(1825f7fe94d84599).(ctxp, &ev, el->element_timecxx . . $ element#element_time., el->device_channelcxx . . $ element#device_channel.); |
| 395 | switch (el->typecxx . . $ element#type.) { |
| 396 | case MD_TYPE_ROOTcxx . . $ `src/elements.h:235:9`!: |
| 397 | seq_init_tempocxx . . $ seq_init_tempo(601f68a32ffec70f).(ctxp, MD_ROOTcxx . . $ `src/elements.h:51:9`!(el)->time_basecxx . . $ rootElement#time_base., 120, 1); |
| 398 | seq_start_timercxx . . $ seq_start_timer(e410d57486f0cd63).(ctxp); |
| 399 | break; |
| 400 | case MD_TYPE_NOTEcxx . . $ `src/elements.h:242:9`!: |
| 401 | seq_midi_notecxx . . $ seq_midi_note(115fea43cce26738).(ctxp, &ev, el->device_channelcxx . . $ element#device_channel., MD_NOTEcxx . . $ `src/elements.h:77:9`!(el)->notecxx . . $ noteElement#note., MD_NOTEcxx . . $ `src/elements.h:77:9`!(el)->velcxx . . $ noteElement#vel., |
| 402 | MD_NOTEcxx . . $ `src/elements.h:77:9`!(el)->lengthcxx . . $ noteElement#length.); |
| 403 | break; |
| 404 | case MD_TYPE_CONTROLcxx . . $ `src/elements.h:253:9`!: |
| 405 | seq_midi_controlcxx . . $ seq_midi_control(d8303e21ad8a41d2).(ctxp, &ev, el->device_channelcxx . . $ element#device_channel., MD_CONTROLcxx . . $ `src/elements.h:94:9`!(el)->controlcxx . . $ controlElement#control., |
| 406 | MD_CONTROLcxx . . $ `src/elements.h:94:9`!(el)->valuecxx . . $ controlElement#value.); |
| 407 | break; |
| 408 | case MD_TYPE_PROGRAMcxx . . $ `src/elements.h:239:9`!: |
| 409 | seq_midi_programcxx . . $ seq_midi_program(d76d217fb6600c83).(ctxp, &ev, el->device_channelcxx . . $ element#device_channel., MD_PROGRAMcxx . . $ `src/elements.h:102:9`!(el)->programcxx . . $ programElement#program.); |
| 410 | break; |
| 411 | case MD_TYPE_TEMPOcxx . . $ `src/elements.h:245:9`!: |
| 412 | seq_midi_tempocxx . . $ seq_midi_tempo(602bf0815d67e961).(ctxp, &ev, MD_TEMPOcxx . . $ `src/elements.h:179:9`!(el)->micro_tempocxx . . $ tempoElement#micro_tempo.); |
| 413 | break; |
| 414 | case MD_TYPE_PITCHcxx . . $ `src/elements.h:238:9`!: |
| 415 | seq_midi_pitchbendcxx . . $ seq_midi_pitchbend(d76d217fb6600c83).(ctxp, &ev, el->device_channelcxx . . $ element#device_channel., MD_PITCHcxx . . $ `src/elements.h:127:9`!(el)->pitchcxx . . $ pitchElement#pitch.); |
| 416 | break; |
| 417 | case MD_TYPE_PRESSUREcxx . . $ `src/elements.h:241:9`!: |
| 418 | seq_midi_chanpresscxx . . $ seq_midi_chanpress(d76d217fb6600c83).(ctxp, &ev, el->device_channelcxx . . $ element#device_channel., MD_PRESSUREcxx . . $ `src/elements.h:119:9`!(el)->velocitycxx . . $ pressureElement#velocity.); |
| 419 | break; |
| 420 | case MD_TYPE_KEYTOUCHcxx . . $ `src/elements.h:236:9`!: |
| 421 | seq_midi_keypresscxx . . $ seq_midi_keypress(d8303e21ad8a41d2).(ctxp, &ev, el->device_channelcxx . . $ element#device_channel., MD_KEYTOUCHcxx . . $ `src/elements.h:111:9`!(el)->notecxx . . $ keytouchElement#note., |
| 422 | MD_KEYTOUCHcxx . . $ `src/elements.h:111:9`!(el)->velocitycxx . . $ keytouchElement#velocity.); |
| 423 | break; |
| 424 | case MD_TYPE_SYSEXcxx . . $ `src/elements.h:247:9`!: |
| 425 | seq_midi_sysexcxx . . $ seq_midi_sysex(445d99f52c9088c3).(ctxp, &ev, MD_SYSEXcxx . . $ `src/elements.h:137:9`!(el)->statuscxx . . $ sysexElement#status., MD_SYSEXcxx . . $ `src/elements.h:137:9`!(el)->datacxx . . $ sysexElement#data., |
| 426 | MD_SYSEXcxx . . $ `src/elements.h:137:9`!(el)->lengthcxx . . $ sysexElement#length.); |
| 427 | break; |
| 428 | case MD_TYPE_TEXTcxx . . $ `src/elements.h:237:9`!: |
| 429 | case MD_TYPE_KEYSIGcxx . . $ `src/elements.h:249:9`!: |
| 430 | case MD_TYPE_TIMESIGcxx . . $ `src/elements.h:250:9`!: |
| 431 | case MD_TYPE_SMPTEOFFSETcxx . . $ `src/elements.h:244:9`!: |
| 432 | /* Ones that have no sequencer action */ |
| 433 | break; |
| 434 | default: |
| 435 | printfcxx . . $ printf(581fddd72a8db8fc).("WARNING: play: not implemented yet %d\n", el->typecxx . . $ element#type.); |
| 436 | break; |
| 437 | } |
| 438 | } |
| 439 | |
| 440 | /** |
| 441 | * alsa-lib has taken to printing errors on system call failures, even |
| 442 | * though such failed calls are part of normal operation. So we have to |
| 443 | * install our own handler to shut it up and prevent it messing up the list |
| 444 | * output. |
| 445 | * |
| 446 | * Possibly not needed any more Dec 2003. |
| 447 | */ |
| 448 | static void |
| 449 | no_errors_pleasecxx . . $ no_errors_please(588371637176764f).(const char *file, int line, |
| 450 | const char *function, int err, const char *fmt, ...) |
| 451 | { |
| 452 | } |
| 453 | |
| 454 | static void |
| 455 | set_signal_handlercxx . . $ set_signal_handler(e410d57486f0cd63).(seq_context_tcxx . . $ seq_context_t# *ctxp) |
| 456 | { |
| 457 | struct sigactioncxx . . $ sigaction# *sap = calloccxx . . $ calloc(63a7bf2941bfcd7a).(1, sizeof(struct sigactioncxx . . $ sigaction#)); |
| 458 | |
| 459 | g_ctxpcxx . . $ g_ctxp. = ctxp; |
| 460 | |
| 461 | sap->sa_handlercxx . . $ `<external>/16635209305659446502/sigaction.h:39:10`! = signal_handlercxx . . $ signal_handler(d4f767463ce0a6b3).; |
| 462 | sigactioncxx . . $ sigaction(53aba09fe16b06c7).(SIGINTcxx . . $ `<external>/11773118241360591791/signum-generic.h:48:9`!, sap, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 463 | } |
| 464 | |
| 465 | /* signal handler */ |
| 466 | static void |
| 467 | signal_handlercxx . . $ signal_handler(d4f767463ce0a6b3).(int sig) |
| 468 | { |
| 469 | /* Close device */ |
| 470 | if (g_ctxpcxx . . $ g_ctxp.) { |
| 471 | seq_free_contextcxx . . $ seq_free_context(e410d57486f0cd63).(g_ctxpcxx . . $ g_ctxp.); |
| 472 | } |
| 473 | |
| 474 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 475 | } |