adding midicomp for midi<-->plain text conversion

This commit is contained in:
Alexander Weinhold 2012-09-01 16:20:14 +02:00
parent ec7e4375c3
commit 2514a62bc8
14 changed files with 3582 additions and 1 deletions

4
.gitignore vendored
View File

@ -1,3 +1,5 @@
/Java/MoppyDesk/nbproject/private/
/Java/MoppyDesk/build/
/Java/MoppyDesk/dist/
/Java/MoppyDesk/dist/
midicomp
*.o

View File

@ -0,0 +1,30 @@
# $Id: makefile.unx,v 1.3 1991/11/15 19:31:00 piet Rel $
CFLAGS = -O
# If you have an old version of flex that defines yyleng
# as a macro rather than a variable, uncomment the following line:
# CFLAGS = -O -DNO_YYLENG_VAR
SRCS = midicomp.c t2mf.fl t2mflex.c yyread.c
EXECS = midicomp
all: $(EXECS)
midicomp: midicomp.h midicomp.o t2mf.h t2mflex.o
$(CC) midicomp.o t2mflex.o -o midicomp
t2mflex.c: t2mf.fl
flex -i -s -Ce t2mf.fl
mv lex.yy.c t2mflex.c
t2mflex.o: t2mflex.c t2mf.h
clean:
rm -f *.o midicomp
install:
cp midicomp /usr/bin ; mv midicomp midicom.exe
dist:
tar czf midicomp-$$(cat VERSION).tar.gz ./ --exclude=*.html --exclude=*.tar.gz

177
tools/midicomp-0.0.4/Readme Normal file
View File

@ -0,0 +1,177 @@
midicomp v0.0.2 20070722 markc@renta.net
A program to manipulate SMF (Standard MIDI File) files. midicomp will
both read and write SMF files in 0 or format 1 and also read and write
it's own plain text format. This means a SMF file can be turned into
easily parseble text, edited with any text editor or filtered through
any script language, and "recompiled" back into a binary SMF file.
Originally based on mf2t/t2fm by Piet van Oostrum and others. It should
build on any linux simply by typing "make" in the source directory.
Changes:
v0.0.2 20070722 Fixed gcc4+ compiler bug and exit warnings
v0.0.1 20031129 Initial release, combined mf2t+t2fm, added getopt args
Command line argument usage:
-d --debug send any debug output to stderr
-v --verbose output in columns with notes on
-c --compile compile ascii input into SMF
-n --note note on/off value as note|octave
-t --time use absolute time instead of ticks
-fN --fold=N fold sysex data at N columns
To translate a SMF file to plain ascii format:
midicomp some.mid # to view as plain text
midicomp some.mid > some.asc # to create a text version
To translate a plain ascii formatted file to SMF:
midicomp -c some.asc some.mid # input and output filenames
midicomp -c some.mid < some.asc # input from stdin with one arg
midicomp some.mid | somefilter | midicomp -c some2.mid
Format of the textfile:
File header: Mfile <format> <ntrks> <division>
Start of track: MTrk
End of track: TrkEnd
Note On: On <ch> <note> <vol>
Note Off: Off <ch> <note> <vol>
Poly Pressure: PoPr[PolyPr] <ch> <note> <val>
Channel Pressure: ChPr[ChanPr] <ch> <val>
Controller parameter: Par[Param] <ch> <con> <val>
Pitch bend: Pb <ch> <val>
Program change: PrCh[ProgCh] <ch> <prog>
Sysex message: SysEx <hex>
Arbutrary midi bytes: Arb <hex>
Sequence nr: Seqnr <num>
Key signature: KeySig <num> <manor>
Tempo: Tempo <num>
Time signature: TimeSig <num>/<num> <num> <num>
SMPTE event: SMPTE <num> <num> <num> <num> <num>
Meta text events: Meta <texttype> <string>
Meta end of track: Meta TrkEnd
Sequencer specific: SeqSpec <type> <hex>
Misc meta events: Meta <type> <hex>
The <> have the following meaning:
<ch> ch=<num>
<note> n=<noteval> [note=<noteval>]
<vol> v=<num> [vol=<num>]
<val> v=<num> [val=<num>]
<con> c=<num> [con=<num>]
<prog> p=<num> [prog=<num>]
<manor> minor or major
<noteval> either a <num> or A-G optionally followed by #,
followed by <num> without intermediate spaces.
<texttype> Text Copyright SeqName TrkName InstrName Lyric Marker Cue
<type> a hex number of the form 0xab
<hex> a sequence of 2-digit hex numbers (without 0x)
separated by space
<string> a string between double quotes (like "text").
Misc notes:
Channel numbers are 1-based, all other numbers are as they appear in the
midifile.
<division> is either a positive number (giving the time resolution in
clicks per quarter note) or a negative number followed by a positive
number (giving SMPTE timing).
<format> <ntrks> <num> are decimal numbers.
The <num> in the Pb is the real value (two midibytes combined)
In Tempo it is a long (32 bits) value. Others are in the interval 0-127
The SysEx sequence contains the leading F0 and the trailing F7.
In a string certain characters are escaped:
" and \ are escaped with a \
a zero byte is written as \0
CR and LF are written as \r and \n respectively
other non-printable characters are written as \x<2 hex digits>
When -f is given long strings and long hex sequences are folded by inserting
\<newline><tab>. If in a string the next character would be a space or
tab it will be escaped by \
midicomp will accept all formats that mf2t can produce, plus a number of
others. Input is case insensitive (except in strings) and extra tabs and
spaces are allowed. Newlines are required but empty lines are allowed.
Comment starts with # at the beginning of a lexical item and continues
to the end of the line. The only other places where a # is legal are
insides strings and as a sharp symbol in a symbolic note.
In symbolic notes + and # are allowed for sharp, b and - for flat.
In bar:beat:click time the : may also be /
On input a string may also contain \t for a tab, and in a folded
string any whitespace at the beginning of a continuation line is skipped.
Hex sequences may be input without intervening spaces if each byte is
given as exactly 2 hex digits.
Hex sequences may be given where a string is required and vice versa.
Hex numbers of the form 0xaaa and decimal numbers are equivalent.
Also allowed as numbers are "bank numbers" of the form '123. In fact
this is equivalent to the octal number 012 (subtract 1 from each
digit, digits 1-8 allowed). The letters a-h may also be used for 1-8.
The input is checked for correctness but not extensively. An
errormessage will generally imply that the resulting midifile is illegal.
channel number can be recognized by the regular expression /ch=/.
note numbers by /n=/ or /note=/, program numbers by /p=/ or /prog=/.
Meta events by /^Meta/ or /^SeqSpec/.
Text events by /"/, continued lines by /\\$/, continuation lines by /$\t/
(that was a TAB character).
In awk each parameter is a field, in perl you can use split to get the
parameters (except for strings).
The following perl script changes note off messages to note on with
vol=0, deletes controller 3 changes, makes some note reassignments on
channel 10, and changes the channel numbers from channel 1 depending
on the track number.
------------------------------- test.pl -------------------------------
%drum = (62, 36, 63, 47, 65, 61, 67, 40, 68, 54);
while (<>) {
next if /c=3/;
s/Off(.*)v=[0-9]*/On\1v=0/;
if (/ch=10/ && /n=([0-9]*)/ && $drum{$1}) {
s/n=$1/"n=".$drum{$1}/e;
}
if (/^MTrk/) {++$trknr ; print "track $trknr\n";}
if ($trknr > 2) { s/ch=1\b/ch=3/; }
else { s/ch=1\b/ch=4/; }
print || die "Error: $!\n";
}
------------------------------------------------------------------------
and this is the corresponding awk script.
------------------------------- test.awk -------------------------------
BEGIN { drum[62] = 36; drum[63] = 47; drum[65] = 61; \
drum[67] = 40; drum[68] = 54 }
/c=3/ { next }
($2 == "Off") { $2 = "On"; $5 = "v=0" }
/ch=10/ { n = substr($4, 3); if (n in drum) $4 = "n=" drum[n] }
/^MTrk/ { trknr++ }
/ch=1 / { if (trknr > 2) { $3 = "ch=2" } else { $3 = "ch=3" } }
{ print }
------------------------------------------------------------------------

View File

@ -0,0 +1 @@
0.0.2

View File

@ -0,0 +1,39 @@
MFile 1 1 384
MTrk
0 Meta SeqName "Track 1"
0 On ch=1 n=48 v=70
0 Tempo 500000
0 TimeSig 4/4 32 99
96 On ch=1 n=48 v=0
96 On ch=1 n=50 v=70
192 On ch=1 n=50 v=0
192 On ch=1 n=52 v=70
288 On ch=1 n=52 v=0
288 On ch=1 n=53 v=70
384 On ch=1 n=53 v=0
384 On ch=1 n=55 v=70
480 On ch=1 n=55 v=0
480 On ch=1 n=57 v=70
576 On ch=1 n=57 v=0
576 On ch=1 n=59 v=70
672 On ch=1 n=59 v=0
672 On ch=1 n=60 v=70
768 On ch=1 n=60 v=0
768 On ch=1 n=62 v=70
864 On ch=1 n=62 v=0
864 On ch=1 n=60 v=70
960 On ch=1 n=60 v=0
960 On ch=1 n=59 v=70
1056 On ch=1 n=59 v=0
1056 On ch=1 n=57 v=70
1152 On ch=1 n=57 v=0
1152 On ch=1 n=55 v=70
1248 On ch=1 n=55 v=0
1248 On ch=1 n=53 v=70
1344 On ch=1 n=53 v=0
1344 On ch=1 n=52 v=70
1440 On ch=1 n=52 v=0
1440 On ch=1 n=50 v=70
1536 On ch=1 n=50 v=0
1536 Meta TrkEnd
TrkEnd

View File

@ -0,0 +1,39 @@
MFile 1 1 384
MTrk
000:00:000 Meta SeqName "Track 1"
000:00:000 On ch=1 note=c4 vol=70
000:00:000 Tempo 500000
000:00:000 TimeSig 4/4 32 99
000:00:096 On ch=1 note=c4 vol=0
000:00:096 On ch=1 note=d4 vol=70
000:00:192 On ch=1 note=d4 vol=0
000:00:192 On ch=1 note=e4 vol=70
000:00:288 On ch=1 note=e4 vol=0
000:00:288 On ch=1 note=f4 vol=70
000:01:000 On ch=1 note=f4 vol=0
000:01:000 On ch=1 note=g4 vol=70
000:01:096 On ch=1 note=g4 vol=0
000:01:096 On ch=1 note=a4 vol=70
000:01:192 On ch=1 note=a4 vol=0
000:01:192 On ch=1 note=b4 vol=70
000:01:288 On ch=1 note=b4 vol=0
000:01:288 On ch=1 note=c5 vol=70
000:02:000 On ch=1 note=c5 vol=0
000:02:000 On ch=1 note=d5 vol=70
000:02:096 On ch=1 note=d5 vol=0
000:02:096 On ch=1 note=c5 vol=70
000:02:192 On ch=1 note=c5 vol=0
000:02:192 On ch=1 note=b4 vol=70
000:02:288 On ch=1 note=b4 vol=0
000:02:288 On ch=1 note=a4 vol=70
000:03:000 On ch=1 note=a4 vol=0
000:03:000 On ch=1 note=g4 vol=70
000:03:096 On ch=1 note=g4 vol=0
000:03:096 On ch=1 note=f4 vol=70
000:03:192 On ch=1 note=f4 vol=0
000:03:192 On ch=1 note=e4 vol=70
000:03:288 On ch=1 note=e4 vol=0
000:03:288 On ch=1 note=d4 vol=70
001:00:000 On ch=1 note=d4 vol=0
001:00:000 Meta TrkEnd
TrkEnd

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,252 @@
/*
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version. This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details. You should have received a copy of the GNU General Public License
along with this program; if not, write to the...
Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston,
MA 02111-1307 USA
*/
#define MThd 0x4d546864L
#define MTrk 0x4d54726bL
#define MTHD 256
#define MTRK 257
#define TRKEND 258
#define ON note_on
#define OFF note_off
#define POPR poly_aftertouch
#define PAR control_change
#define PB pitch_wheel
#define PRCH program_chng
#define CHPR channel_aftertouch
#define SYSEX system_exclusive
#define ARB 259
#define MINOR 260
#define MAJOR 261
#define CH 262
#define NOTE 263
#define VAL 264
#define CON 265
#define PROG 266
#define INT 267
#define STRING 268
#define STRESC 269
#define ERR 270
#define NOTEVAL 271
#define EOL 272
#define META 273
#define SEQSPEC (META+1+sequencer_specific)
#define TEXT (META+1+text_event)
#define COPYRIGHT (META+1+copyright_notice)
#define SEQNAME (META+1+sequence_name)
#define INSTRNAME (META+1+instrument_name)
#define LYRIC (META+1+lyric)
#define MARKER (META+1+marker)
#define CUE (META+1+cue_point)
#define SEQNR (META+1+sequence_number)
#define KEYSIG (META+1+key_signature)
#define TEMPO (META+1+set_tempo)
#define TIMESIG (META+1+time_signature)
#define SMPTE (META+1+smpte_offset)
#define note_off 0x80
#define note_on 0x90
#define poly_aftertouch 0xa0
#define control_change 0xb0
#define program_chng 0xc0
#define channel_aftertouch 0xd0
#define pitch_wheel 0xe0
#define system_exclusive 0xf0
#define delay_packet (1111)
#define damper_pedal 0x40
#define portamento 0x41
#define sostenuto 0x42
#define soft_pedal 0x43
#define general_4 0x44
#define hold_2 0x45
#define general_5 0x50
#define general_6 0x51
#define general_7 0x52
#define general_8 0x53
#define tremolo_depth 0x5c
#define chorus_depth 0x5d
#define detune 0x5e
#define phaser_depth 0x5f
#define data_inc 0x60
#define data_dec 0x61
#define non_reg_lsb 0x62
#define non_reg_msb 0x63
#define reg_lsb 0x64
#define reg_msb 0x65
#define meta_event 0xFF
#define sequence_number 0x00
#define text_event 0x01
#define copyright_notice 0x02
#define sequence_name 0x03
#define instrument_name 0x04
#define lyric 0x05
#define marker 0x06
#define cue_point 0x07
#define channel_prefix 0x20
#define end_of_track 0x2f
#define set_tempo 0x51
#define smpte_offset 0x54
#define time_signature 0x58
#define key_signature 0x59
#define sequencer_specific 0x7f
#define Seq_Circuits (0x01) /* Sequential Circuits Inc. */
#define Big_Briar (0x02) /* Big Briar Inc. */
#define Octave (0x03) /* Octave/Plateau */
#define Moog (0x04) /* Moog Music */
#define Passport (0x05) /* Passport Designs */
#define Lexicon (0x06) /* Lexicon */
#define Tempi (0x20) /* Bon Tempi */
#define Siel (0x21) /* S.I.E.L. */
#define Kawai (0x41)
#define Roland (0x42)
#define Korg (0x42)
#define Yamaha (0x43)
#define lowerbyte(x) ((unsigned char)(x & 0xff))
#define upperbyte(x) ((unsigned char)((x & 0xff00)>>8))
#define NULLFUNC 0
#define MSGINCREMENT 128
#ifdef NO_YYLENG_VAR
#define yyleng yylength
#endif
static FILE *F;
static char *Msgbuff = NULL;
static int Msgsize = 0;
static int Msgindex = 0;
static int TrkNr;
static int TrksToDo = 1;
static int Measure, M0, Beat, Clicks;
static long T0;
static int fold = 0;
static int notes = 0;
static int times = 0;
static char *Onmsg = "On ch=%d n=%s v=%d\n";
static char *Offmsg = "Off ch=%d n=%s v=%d\n";
static char *PoPrmsg = "PoPr ch=%d n=%s v=%d\n";
static char *Parmsg = "Par ch=%d c=%d v=%d\n";
static char *Pbmsg = "Pb ch=%d v=%d\n";
static char *PrChmsg = "PrCh ch=%d p=%d\n";
static char *ChPrmsg = "ChPr ch=%d v=%d\n";
static jmp_buf erjump;
static int err_cont = 0;
static int TrkNr;
static int Format, Ntrks;
static int Measure, M0, Beat, Clicks;
static long T0;
static char* buffer = 0;
static int buflen,bufsiz= 0;
extern long yyval;
extern int yyleng;
extern int lineno;
extern char *yytext;
extern int do_hex;
extern int eol_seen;
extern FILE *yyin;
static int mywritetrack();
static void checkchan();
static void checknote();
static void checkval();
static void splitval();
static void get16val();
static void checkcon();
static void checkprog();
static void checkeol();
static void gethex();
int (*Mf_getc)() = NULLFUNC;
int (*Mf_error)() = NULLFUNC;
int (*Mf_header)() = NULLFUNC;
int (*Mf_starttrack)() = NULLFUNC;
int (*Mf_endtrack)() = NULLFUNC;
int (*Mf_on)() = NULLFUNC;
int (*Mf_off)() = NULLFUNC;
int (*Mf_pressure)() = NULLFUNC;
int (*Mf_parameter)() = NULLFUNC;
int (*Mf_pitchbend)() = NULLFUNC;
int (*Mf_program)() = NULLFUNC;
int (*Mf_chanpressure)() = NULLFUNC;
int (*Mf_sysex)() = NULLFUNC;
int (*Mf_arbitrary)() = NULLFUNC;
int (*Mf_metamisc)() = NULLFUNC;
int (*Mf_seqnum)() = NULLFUNC;
int (*Mf_eot)() = NULLFUNC;
int (*Mf_smpte)() = NULLFUNC;
int (*Mf_tempo)() = NULLFUNC;
int (*Mf_timesig)() = NULLFUNC;
int (*Mf_keysig)() = NULLFUNC;
int (*Mf_sqspecific)() = NULLFUNC;
int (*Mf_text)() = NULLFUNC;
static readtrack();
static badbyte();
static metaevent();
static sysex();
static chanmessage();
static msginit();
static msgleng();
static msgadd();
static biggermsg();
float mf_ticks2sec();
unsigned long mf_sec2ticks(float,int,unsigned int);
void mfwrite();
int (*Mf_putc)() = NULLFUNC;
int (*Mf_wtrack)() = NULLFUNC;
int (*Mf_wtempotrack)() = NULLFUNC;
int Mf_nomerge = 0;
long Mf_currtime = 0L;
static long Mf_toberead = 0L;
static long Mf_numbyteswritten = 0L;
static long readvarinum();
static long read32bit();
static long to32bit();
static int read16bit();
static int to16bit();
static char *msg();
static void readheader();
static int verbose_flag;
static int dbg=0;
char data[5];
int chan;
int Mf_RunStat = 0;
static int laststat;
static int lastmeta;
int verbose = 0;
int filegetc();
int fileputc();
void WriteVarLen();
int eputc(unsigned char);

View File

@ -0,0 +1,121 @@
/* $Id: midifile.h,v 1.3 1991/11/03 21:50:50 piet Rel $ */
static readtrack();
static badbyte();
static metaevent();
static sysex();
static chanmessage();
static msginit();
static msgleng();
static msgadd();
static biggermsg();
/* definitions for MIDI file parsing code */
extern int (*Mf_getc)();
extern int (*Mf_header)();
extern int (*Mf_starttrack)();
extern int (*Mf_endtrack)();
extern int (*Mf_on)();
extern int (*Mf_off)();
extern int (*Mf_pressure)();
extern int (*Mf_parameter)();
extern int (*Mf_pitchbend)();
extern int (*Mf_program)();
extern int (*Mf_chanpressure)();
extern int (*Mf_sysex)();
extern int (*Mf_metamisc)();
extern int (*Mf_sqspecific)();
extern int (*Mf_seqnum)();
extern int (*Mf_text)();
extern int (*Mf_eot)();
extern int (*Mf_timesig)();
extern int (*Mf_smpte)();
extern int (*Mf_tempo)();
extern int (*Mf_keysig)();
extern int (*Mf_arbitrary)();
extern int (*Mf_error)();
extern long Mf_currtime;
extern int Mf_nomerge;
/* definitions for MIDI file writing code */
extern int (*Mf_putc)();
extern int (*Mf_wtrack)();
extern int (*Mf_wtempotrack)();
float mf_ticks2sec();
unsigned long mf_sec2ticks();
void mfwrite();
/* MIDI status commands most significant bit is 1 */
#define note_off 0x80
#define note_on 0x90
#define poly_aftertouch 0xa0
#define control_change 0xb0
#define program_chng 0xc0
#define channel_aftertouch 0xd0
#define pitch_wheel 0xe0
#define system_exclusive 0xf0
#define delay_packet (1111)
/* 7 bit controllers */
#define damper_pedal 0x40
#define portamento 0x41
#define sostenuto 0x42
#define soft_pedal 0x43
#define general_4 0x44
#define hold_2 0x45
#define general_5 0x50
#define general_6 0x51
#define general_7 0x52
#define general_8 0x53
#define tremolo_depth 0x5c
#define chorus_depth 0x5d
#define detune 0x5e
#define phaser_depth 0x5f
/* parameter values */
#define data_inc 0x60
#define data_dec 0x61
/* parameter selection */
#define non_reg_lsb 0x62
#define non_reg_msb 0x63
#define reg_lsb 0x64
#define reg_msb 0x65
/* Standard MIDI Files meta event definitions */
#define meta_event 0xFF
#define sequence_number 0x00
#define text_event 0x01
#define copyright_notice 0x02
#define sequence_name 0x03
#define instrument_name 0x04
#define lyric 0x05
#define marker 0x06
#define cue_point 0x07
#define channel_prefix 0x20
#define end_of_track 0x2f
#define set_tempo 0x51
#define smpte_offset 0x54
#define time_signature 0x58
#define key_signature 0x59
#define sequencer_specific 0x7f
/* Manufacturer's ID number */
#define Seq_Circuits (0x01) /* Sequential Circuits Inc. */
#define Big_Briar (0x02) /* Big Briar Inc. */
#define Octave (0x03) /* Octave/Plateau */
#define Moog (0x04) /* Moog Music */
#define Passport (0x05) /* Passport Designs */
#define Lexicon (0x06) /* Lexicon */
#define Tempi (0x20) /* Bon Tempi */
#define Siel (0x21) /* S.I.E.L. */
#define Kawai (0x41)
#define Roland (0x42)
#define Korg (0x42)
#define Yamaha (0x43)
/* miscellaneous definitions */
#define MThd 0x4d546864L
#define MTrk 0x4d54726bL
#define lowerbyte(x) ((unsigned char)(x & 0xff))
#define upperbyte(x) ((unsigned char)((x & 0xff00)>>8))

View File

@ -0,0 +1,98 @@
/* $Id: t2mf.fl,v 1.3 1991/11/15 19:31:00 piet Rel $ */
%{
#include "t2mf.h"
#ifdef NO_YYLENG_VAR
int yylength;
#define YY_USER_ACTION yylength = yyleng
#endif
int do_hex = 0;
int eol_seen = 0;
int lineno = 1;
long yyval;
long bankno();
%}
Hex [0-9a-f]
%x QUOTE
%x HEX
%%
if (do_hex) {
BEGIN(HEX);
do_hex = 0;
}
eol_seen = 0;
<INITIAL,HEX>[ \t\r] /* skip whitespace */;
<INITIAL,HEX>"#".*\n /* skip comment */ lineno++;
MFile return MTHD;
MTrk return MTRK;
TrkEnd return TRKEND;
On return ON;
Off return OFF;
Po(ly)?Pr return POPR;
Par(am)? return PAR;
Pb return PB;
Pr(og)?Ch return PRCH;
Ch(an)?Pr return CHPR;
SysEx return SYSEX;
Meta return META;
SeqSpec return SEQSPEC;
Text return TEXT;
Copyright return COPYRIGHT;
TrkName|SeqName return SEQNAME;
InstrName return INSTRNAME;
Lyric return LYRIC;
Marker return MARKER;
Cue return CUE;
SeqNr return SEQNR;
KeySig return KEYSIG;
Tempo return TEMPO;
TimeSig return TIMESIG;
SMPTE return SMPTE;
Arb return ARB;
[:/] return '/';
minor return MINOR;
major return MAJOR;
ch= return CH;
n(ote)?= return NOTE;
v([oa]l)?= return VAL;
c(on)?= return CON;
p(rog)?= return PROG;
[-+]?[0-9]+ sscanf (yytext, "%ld", &yyval); return INT;
0x{Hex}+ sscanf (yytext+2, "%lx", &yyval); return INT;
\$[A-H1-8]+ yyval = bankno (yytext+1, yyleng-1); return INT;
<HEX>{Hex}{Hex}? sscanf (yytext, "%lx", &yyval); return INT;
[a-g][#b+-]?[0-9]+ return NOTEVAL;
<INITIAL,HEX>\" BEGIN (QUOTE);
<QUOTE>[^\\"\n]* yymore();
<QUOTE>\" BEGIN (0); return STRING;
<QUOTE>\\(.|\n) yymore();
<QUOTE>\n { error ("unterminated string");
lineno++; eol_seen++; BEGIN(0); return EOL;
}
<QUOTE><<EOF>> error ("EOF in string"); return EOF;
<INITIAL,HEX>\\[ \t\r]*\n lineno++;
<INITIAL,HEX>\n lineno++; eol_seen++; BEGIN(0); return EOL;
<HEX>[g-z][a-z]+ BEGIN (0); return ERR;
<HEX>. BEGIN (0); return ERR;
[a-z]+ return ERR;
. return ERR;
<<EOF>> return EOF;
%%

View File

@ -0,0 +1,48 @@
/* $Id: t2mf.h,v 1.2 1991/11/03 21:50:50 piet Rel $ */
#include "midifile.h"
#include <stdlib.h>
#define MTHD 256
#define MTRK 257
#define TRKEND 258
#define ON note_on
#define OFF note_off
#define POPR poly_aftertouch
#define PAR control_change
#define PB pitch_wheel
#define PRCH program_chng
#define CHPR channel_aftertouch
#define SYSEX system_exclusive
#define ARB 259
#define MINOR 260
#define MAJOR 261
#define CH 262
#define NOTE 263
#define VAL 264
#define CON 265
#define PROG 266
#define INT 267
#define STRING 268
#define STRESC 269
#define ERR 270
#define NOTEVAL 271
#define EOL 272
#define META 273
#define SEQSPEC (META+1+sequencer_specific)
#define TEXT (META+1+text_event)
#define COPYRIGHT (META+1+copyright_notice)
#define SEQNAME (META+1+sequence_name)
#define INSTRNAME (META+1+instrument_name)
#define LYRIC (META+1+lyric)
#define MARKER (META+1+marker)
#define CUE (META+1+cue_point)
#define SEQNR (META+1+sequence_number)
#define KEYSIG (META+1+key_signature)
#define TEMPO (META+1+set_tempo)
#define TIMESIG (META+1+time_signature)
#define SMPTE (META+1+smpte_offset)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,39 @@
/* $Id: yyread.c,v 1.2 1991/11/03 21:53:20 piet Rel $ */
/* sozobon version */
#include <memory.h>
#include <string.h>
/*
* read, ignoring CR's
*
* ++jrb
*/
int _yyread(fd, buf, size)
int fd; char *buf; int size;
{
int count = read(fd, buf, size);
int done = 0, i;
if(count <= 0)
return count;
do{
for(i = done; i < (done+count); i++)
{
if(buf[i] == '\r')
{
if(i < done + count - 1)
bcopy(&buf[i+1], &buf[i], (count -1 - (i - done)));
count -= 1;
}
}
done += count;
if(done == size)
return done;
count = read(fd, &buf[done], (size - done));
} while(count > 0);
return done;
}