mirror of
https://github.com/cookiengineer/audacity
synced 2025-11-24 06:10:09 +01:00
autotools
dox2-src
help
images
include
lib-src
FileDialog
expat
ffmpeg
id3lib
lame
lib-widget-extra
libflac
libid3tag
libmad
libnyquist
libogg
libresample
libsamplerate
libscorealign
libsndfile
libsoxr
libvamp
libvorbis
lv2
mod-null
mod-nyq-bench
mod-script-pipe
mod-track-panel
portaudio-v19
portburn
portmidi
portmixer
portsmf
apps
allegroconvert.cpp
allegroconvert.vcproj
allegroplay.cpp
midicode.h
seq2midi.cpp
seq2midi.h
autotools
portsmf.xcodeproj
portsmf_test
Makefile.am
Makefile.in
README.txt
algrd_internal.h
algsmfrd_internal.h
allegro.cpp
allegro.h
allegro.htm
allegrord.cpp
allegroserial.cpp
allegrosmfrd.cpp
allegrosmfwr.cpp
allegrowr.cpp
autotools-fix-make-dist.patch
autotools.patch
changelog.txt
configure
configure.ac
license.txt
mfmidi.cpp
mfmidi.h
notes.txt
portSMF-uninstalled.pc.in
portSMF.pc.in
portsmf-VC8.sln
portsmf-VC8.vcproj
portsmf.sln
portsmf.suo
portsmf.vcproj
strparse.cpp
strparse.h
todo.txt
trace.cpp
trace.h
sbsms
soundtouch
taglib
twolame
Makefile.am
Makefile.in
audacity-patches.txt
dist-libsoxr.mk
dist-libvamp.mk
dist-portaudio.mk
locale
m4
mac
nyquist
plug-ins
presets
qa
scripts
src
tests
win
.gitignore
.travis.yml
ABOUT-NLS
LICENSE.txt
Makefile.am
Makefile.in
README.txt
audacity.dox
branches.txt
configure
configure.ac
po
todo.txt
90 lines
2.2 KiB
C++
Executable File
90 lines
2.2 KiB
C++
Executable File
|
|
//#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;
|
|
}
|