Skip to content

Commit

Permalink
fix midi end-of-track event which was happening too soon
Browse files Browse the repository at this point in the history
  • Loading branch information
conanite committed Mar 6, 2010
1 parent c70fbb0 commit 0a5288b
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 36 deletions.
10 changes: 6 additions & 4 deletions src/arc/lib/bag-of-tricks.arc
Expand Up @@ -228,10 +228,12 @@
(load it))
(err:string "Didn't find " arc-lib))))

(mac requires (func lib)
`(def ,func args
(require-lib ',lib)
(apply ,func args)))
(mac requires (funcs lib)
(if (acons funcs)
`(do ,@(map [list 'requires _ lib] funcs))
`(def ,funcs args
(require-lib ',lib)
(apply ,funcs args))))

(mac require-by-name (path . funcs)
`(do
Expand Down
11 changes: 5 additions & 6 deletions src/arc/lib/midi/midi-writer.arc
Expand Up @@ -39,9 +39,9 @@
(acc (if (> event.4 127) 127 event.4))
event.0))

(let track-footer (list 0 255 47 0)
(let track-footer (list 130 0 255 47 0)
(def write-midi-track (str byte-list)
(writebs (to-4-byte-word (+ 4 (len byte-list))) str)
(writebs (to-4-byte-word (+ 5 (len byte-list))) str)
(writebs byte-list str)
(writebs track-footer str)))

Expand All @@ -54,12 +54,11 @@
77 84 114 107) ; "MTrk"
(def write-midi-file (music str)
(each b midi-type-0-header (writeb b str))
(let events (only-notes music)
(with (events (only-notes music) tick 0)
(write-midi-track str
(accum bytes
(let tick 0
(each event events
(= tick (accum-midi-event event tick bytes)))))))))
(each event events
(= tick (accum-midi-event event tick bytes))))))))

(def write-midi-to (name music)
(w/outfile f name
Expand Down
2 changes: 1 addition & 1 deletion src/arc/lib/midi/rondo.arc
@@ -1,4 +1,4 @@
; W.A.Mozart, KV331 (Rondo a la turca)
; W.A.Mozart KV331 "Rondo a la turca"

(require-lib 'lib/midi/midi)

Expand Down
12 changes: 11 additions & 1 deletion src/arc/rainbow/midi/midi.arc
Expand Up @@ -10,7 +10,7 @@
(defmidi note-on (channels ch note-number volume)
(channels.ch 'noteOn note-number (if (> volume 127) 127 volume))
(pr "."))
(defmidi note-off (channels ch note-number)
(defmidi note-off (channels ch note-number velocity-ignored)
(channels.ch 'noteOff note-number))
(defmidi instrument (channels ch bank program)
(channels.ch 'programChange bank program))
Expand Down Expand Up @@ -48,3 +48,13 @@
((,b3 100 8))
((,c4 100 8))))))))


(def prelude ()
(require-lib 'lib/midi/prelude)
(= tick-size 0.2)
(play-sequence (make-music 0 prelude-measures)))

(def rondo ()
(require-lib 'lib/midi/rondo)
(= tick-size 0.11)
(play-sequence rondo-music))
7 changes: 0 additions & 7 deletions src/arc/rainbow/midi/prelude.arc

This file was deleted.

6 changes: 0 additions & 6 deletions src/arc/rainbow/midi/rondo.arc

This file was deleted.

2 changes: 1 addition & 1 deletion src/arc/rainbow/rainbow-libs.arc
Expand Up @@ -19,5 +19,5 @@
;(run-all-tests)

(require-by-name rainbow/ welder fsb tetris mines)
(require-by-name rainbow/midi/ rondo prelude)
(requires (rondo prelude) rainbow/midi/midi)
(requires start-spiral-app rainbow/spiral)
20 changes: 10 additions & 10 deletions src/java/rainbow/Console.java
Expand Up @@ -62,16 +62,16 @@ public static void main(String args[]) throws ParseException, IOException {

private static void showHelp() {
System.out.print("" +
"Launch the Rainbow Arc Interpreter " +
"\n " +
"\n rainbow [options] " +
"\n " +
"\n where options include " +
"\n --help show this help " +
"\n -f file ... load and interpret file " +
"\n -e expr ... evaluate expr " +
"\n -q quit after -e or -f, don't enter the REPL " +
"\n --no-libs don't load any arc libraries " +
"Launch the Rainbow Arc Interpreter " +
"\n " +
"\n rainbow [options] " +
"\n " +
"\n where options include " +
"\n --help show this help " +
"\n -f file ... load and interpret file " +
"\n -e expr ... evaluate expr " +
"\n -q don't enter the REPL (quit if no threads started) " +
"\n --no-libs don't load any arc libraries " +
"\n -args xyz (if specified must be last) set symbol *argv* to xyz" +
"\n");
}
Expand Down

0 comments on commit 0a5288b

Please sign in to comment.