mirror of
https://github.com/cookiengineer/audacity
synced 2025-11-26 07:10:09 +01:00
Converted CRLF to LF.
This commit is contained in:
@@ -1,89 +1,89 @@
|
||||
|
||||
//#include "stdlib.h"
|
||||
//#include "stdio.h"
|
||||
//#include "memory.h"
|
||||
//#include "assert.h"
|
||||
#include <fstream>
|
||||
#include "allegro.h"
|
||||
#include "mfmidi.h"
|
||||
#include "portmidi.h"
|
||||
#include "seq2midi.h"
|
||||
//#include "string.h"
|
||||
//#include "strparse.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#include "crtdbg.h" // for memory allocation debugging
|
||||
#endif
|
||||
|
||||
void midi_fail(char *msg)
|
||||
{
|
||||
printf("Failure: %s\n", msg);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
void *midi_alloc(size_t s) { return malloc(s); }
|
||||
void midi_free(void *a) { free(a); }
|
||||
|
||||
|
||||
void print_help()
|
||||
{
|
||||
printf("Usage: allegroplay [-m] [-a] <filename> [-n]\n");
|
||||
printf(" use -m for midifile, -a for allegro file.\n");
|
||||
printf(" .mid extension implies -m, .gro implies -a\n");
|
||||
printf(" use -n for non-interactive use (no prompts)\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc < 2) {
|
||||
print_help();
|
||||
}
|
||||
char *filename = NULL;
|
||||
bool midifile = false;
|
||||
bool allegrofile = false;
|
||||
bool interactive = true;
|
||||
int i = 1; // scan the command line
|
||||
while (i < argc) {
|
||||
if (argv[i][0] == '-') {
|
||||
if (argv[1][1] == 'm') midifile = true;
|
||||
else if (argv[i][1] == 'a') allegrofile = true;
|
||||
else if (argv[i][1] == 'n') interactive = false;
|
||||
} else {
|
||||
filename = argv[i];
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (!filename) {
|
||||
print_help();
|
||||
}
|
||||
|
||||
if (!midifile && !allegrofile) {
|
||||
int len = strlen(filename);
|
||||
if (len < 4) print_help(); // no extension, need -m or -a
|
||||
char *ext = filename + len - 4;
|
||||
if (strcmp(ext, ".mid") == 0) midifile = true;
|
||||
else if (strcmp(ext, ".gro") == 0) allegrofile = true;
|
||||
else print_help();
|
||||
}
|
||||
Alg_seq seq(filename, midifile);
|
||||
|
||||
int events = 0;
|
||||
for (i = 0; i < seq.tracks(); i++) {
|
||||
events += seq.track(i)->length();
|
||||
}
|
||||
if (interactive) {
|
||||
printf("%d tracks, %d events\n", seq.tracks(), events);
|
||||
}
|
||||
/* PLAY THE FILE VIA MIDI: */
|
||||
if (interactive) {
|
||||
printf("type return to play midi file: ");
|
||||
char input[80];
|
||||
fgets(input, 80, stdin);
|
||||
}
|
||||
seq_play(seq);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//#include "stdlib.h"
|
||||
//#include "stdio.h"
|
||||
//#include "memory.h"
|
||||
//#include "assert.h"
|
||||
#include <fstream>
|
||||
#include "allegro.h"
|
||||
#include "mfmidi.h"
|
||||
#include "portmidi.h"
|
||||
#include "seq2midi.h"
|
||||
//#include "string.h"
|
||||
//#include "strparse.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#include "crtdbg.h" // for memory allocation debugging
|
||||
#endif
|
||||
|
||||
void midi_fail(char *msg)
|
||||
{
|
||||
printf("Failure: %s\n", msg);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
void *midi_alloc(size_t s) { return malloc(s); }
|
||||
void midi_free(void *a) { free(a); }
|
||||
|
||||
|
||||
void print_help()
|
||||
{
|
||||
printf("Usage: allegroplay [-m] [-a] <filename> [-n]\n");
|
||||
printf(" use -m for midifile, -a for allegro file.\n");
|
||||
printf(" .mid extension implies -m, .gro implies -a\n");
|
||||
printf(" use -n for non-interactive use (no prompts)\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc < 2) {
|
||||
print_help();
|
||||
}
|
||||
char *filename = NULL;
|
||||
bool midifile = false;
|
||||
bool allegrofile = false;
|
||||
bool interactive = true;
|
||||
int i = 1; // scan the command line
|
||||
while (i < argc) {
|
||||
if (argv[i][0] == '-') {
|
||||
if (argv[1][1] == 'm') midifile = true;
|
||||
else if (argv[i][1] == 'a') allegrofile = true;
|
||||
else if (argv[i][1] == 'n') interactive = false;
|
||||
} else {
|
||||
filename = argv[i];
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (!filename) {
|
||||
print_help();
|
||||
}
|
||||
|
||||
if (!midifile && !allegrofile) {
|
||||
int len = strlen(filename);
|
||||
if (len < 4) print_help(); // no extension, need -m or -a
|
||||
char *ext = filename + len - 4;
|
||||
if (strcmp(ext, ".mid") == 0) midifile = true;
|
||||
else if (strcmp(ext, ".gro") == 0) allegrofile = true;
|
||||
else print_help();
|
||||
}
|
||||
Alg_seq seq(filename, midifile);
|
||||
|
||||
int events = 0;
|
||||
for (i = 0; i < seq.tracks(); i++) {
|
||||
events += seq.track(i)->length();
|
||||
}
|
||||
if (interactive) {
|
||||
printf("%d tracks, %d events\n", seq.tracks(), events);
|
||||
}
|
||||
/* PLAY THE FILE VIA MIDI: */
|
||||
if (interactive) {
|
||||
printf("type return to play midi file: ");
|
||||
char input[80];
|
||||
fgets(input, 80, stdin);
|
||||
}
|
||||
seq_play(seq);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,62 +1,62 @@
|
||||
/************************************************************************
|
||||
*
|
||||
* Midi codes
|
||||
* Copyright 1989 Carnegie Mellon University
|
||||
*
|
||||
*************************************************************************
|
||||
* Change Log
|
||||
* Date | Change
|
||||
*-----------+------------------------------------------------------------
|
||||
* 11-Mar-94 | PLu : Port to IRI
|
||||
************************************************************************/
|
||||
|
||||
#define MIDI_DATA(d) (0x7f & (d))
|
||||
#define MIDI_CHANNEL(c) (0x0f & ((c) - 1))
|
||||
#define MIDI_PORT(c) (((c) - 1) >> 4)
|
||||
#define MIDI_PROGRAM(p) MIDI_DATA((p) - 1)
|
||||
|
||||
#define MIDI_STATUS_BIT 0x80
|
||||
#define MIDI_COMMON 0x70
|
||||
#define MIDI_CODE_MASK 0xf0
|
||||
#define MIDI_CHN_MASK 0x0f
|
||||
#define MIDI_REALTIME 0xf8
|
||||
#define MIDI_CHAN_MODE 0xfa
|
||||
|
||||
#define MIDI_OFF_NOTE 0x80
|
||||
#define MIDI_ON_NOTE 0x90
|
||||
#define MIDI_POLY_TOUCH 0xa0
|
||||
#define MIDI_CTRL 0xb0
|
||||
#define MIDI_CH_PROGRAM 0xc0
|
||||
#define MIDI_TOUCH 0xd0
|
||||
#define MIDI_BEND 0xe0
|
||||
|
||||
#ifdef UNIX_IRIX_MIDIFNS
|
||||
#define CMT_MIDI_SYSEX 0xf0
|
||||
#define CMT_MIDI_EOX 0xf7
|
||||
#else
|
||||
#define MIDI_SYSEX 0xf0
|
||||
#define MIDI_EOX 0xf7
|
||||
#endif
|
||||
#define MIDI_Q_FRAME 0xf1
|
||||
#define MIDI_SONG_POINTER 0xf2
|
||||
#define MIDI_SONG_SELECT 0xf3
|
||||
#define MIDI_F4 0xf4
|
||||
#define MIDI_F5 0xf5
|
||||
#define MIDI_TUNE_REQ 0xf6
|
||||
#define MIDI_TIME_CLOCK 0xf8
|
||||
#define MIDI_F9 0xf9
|
||||
#define MIDI_START 0xfa
|
||||
#define MIDI_CONTINUE 0xfb
|
||||
#define MIDI_STOP 0xfc
|
||||
#define MIDI_FD 0xfd
|
||||
#define MIDI_ACTIVE_SENSING 0xfe
|
||||
#define MIDI_SYS_RESET 0xff
|
||||
|
||||
#define MIDI_LOCAL 0x7a
|
||||
#define MIDI_LOCAL_OFF 0x00
|
||||
#define MIDI_LOCAL_ON 0x7f
|
||||
#define MIDI_ALL_OFF 0x7b
|
||||
#define MIDI_OMNI_OFF 0x7c
|
||||
#define MIDI_OMNI_ON 0x7d
|
||||
#define MIDI_MONO_ON 0x7e
|
||||
#define MIDI_POLY_ON 0x7f
|
||||
/************************************************************************
|
||||
*
|
||||
* Midi codes
|
||||
* Copyright 1989 Carnegie Mellon University
|
||||
*
|
||||
*************************************************************************
|
||||
* Change Log
|
||||
* Date | Change
|
||||
*-----------+------------------------------------------------------------
|
||||
* 11-Mar-94 | PLu : Port to IRI
|
||||
************************************************************************/
|
||||
|
||||
#define MIDI_DATA(d) (0x7f & (d))
|
||||
#define MIDI_CHANNEL(c) (0x0f & ((c) - 1))
|
||||
#define MIDI_PORT(c) (((c) - 1) >> 4)
|
||||
#define MIDI_PROGRAM(p) MIDI_DATA((p) - 1)
|
||||
|
||||
#define MIDI_STATUS_BIT 0x80
|
||||
#define MIDI_COMMON 0x70
|
||||
#define MIDI_CODE_MASK 0xf0
|
||||
#define MIDI_CHN_MASK 0x0f
|
||||
#define MIDI_REALTIME 0xf8
|
||||
#define MIDI_CHAN_MODE 0xfa
|
||||
|
||||
#define MIDI_OFF_NOTE 0x80
|
||||
#define MIDI_ON_NOTE 0x90
|
||||
#define MIDI_POLY_TOUCH 0xa0
|
||||
#define MIDI_CTRL 0xb0
|
||||
#define MIDI_CH_PROGRAM 0xc0
|
||||
#define MIDI_TOUCH 0xd0
|
||||
#define MIDI_BEND 0xe0
|
||||
|
||||
#ifdef UNIX_IRIX_MIDIFNS
|
||||
#define CMT_MIDI_SYSEX 0xf0
|
||||
#define CMT_MIDI_EOX 0xf7
|
||||
#else
|
||||
#define MIDI_SYSEX 0xf0
|
||||
#define MIDI_EOX 0xf7
|
||||
#endif
|
||||
#define MIDI_Q_FRAME 0xf1
|
||||
#define MIDI_SONG_POINTER 0xf2
|
||||
#define MIDI_SONG_SELECT 0xf3
|
||||
#define MIDI_F4 0xf4
|
||||
#define MIDI_F5 0xf5
|
||||
#define MIDI_TUNE_REQ 0xf6
|
||||
#define MIDI_TIME_CLOCK 0xf8
|
||||
#define MIDI_F9 0xf9
|
||||
#define MIDI_START 0xfa
|
||||
#define MIDI_CONTINUE 0xfb
|
||||
#define MIDI_STOP 0xfc
|
||||
#define MIDI_FD 0xfd
|
||||
#define MIDI_ACTIVE_SENSING 0xfe
|
||||
#define MIDI_SYS_RESET 0xff
|
||||
|
||||
#define MIDI_LOCAL 0x7a
|
||||
#define MIDI_LOCAL_OFF 0x00
|
||||
#define MIDI_LOCAL_ON 0x7f
|
||||
#define MIDI_ALL_OFF 0x7b
|
||||
#define MIDI_OMNI_OFF 0x7c
|
||||
#define MIDI_OMNI_ON 0x7d
|
||||
#define MIDI_MONO_ON 0x7e
|
||||
#define MIDI_POLY_ON 0x7f
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// play a sequence to a midi stream
|
||||
void seq2midi(Alg_seq &seq, PortMidiStream *midi);
|
||||
|
||||
// open a stream, play a sequence, close the stream
|
||||
void seq_play(Alg_seq &seq);
|
||||
// play a sequence to a midi stream
|
||||
void seq2midi(Alg_seq &seq, PortMidiStream *midi);
|
||||
|
||||
// open a stream, play a sequence, close the stream
|
||||
void seq_play(Alg_seq &seq);
|
||||
|
||||
Reference in New Issue
Block a user