Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Matt Kane
committed
Oct 11, 2010
1 parent
1172630
commit 30a5b8b
Showing
3 changed files
with
130 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
BandInfo { | ||
var <>left, <>right; // floats | ||
*new { | ||
left = right = 0.0; | ||
^super.new | ||
} | ||
} | ||
|
||
BeatInfo { | ||
var <>bands; | ||
*new { | ||
arg size; | ||
^super.newCopyArgs(Array.new(size)); | ||
} | ||
} | ||
|
||
|
||
|
||
RSChannels[slot] { | ||
var <channels; | ||
*newWithFilename { | ||
arg filename; | ||
j = this.new; | ||
j.read(filename) | ||
} | ||
|
||
read { | ||
arg filename; | ||
var file = File.open(filename, "rb"); | ||
if ( !file.isOpen, { Error("couldn't open file" + filename + "!").throw } ); | ||
var nextChar = file.getChar(); | ||
var bandcount = ""; | ||
while ( { nextChar != $| && nextChar != nil }, { bandcount = bandcount ++ nextChar; nextChar = file.getChar() } ); | ||
if (nextChar == nil, { Error("premature eof in" + filename).throw }); | ||
bandcount = bandcount.asInteger; | ||
var done = false; | ||
nextChar = file.getChar(); | ||
var beats; | ||
while ( { done == false }, { | ||
var inputname; | ||
while ( { nextChar != $| && nextChar != nil }, { inputname = inputname ++ nextChar; nextChar = file.getChar() } ); | ||
if (nextChar == nil, { Error("premature eof in" + filename).throw }); | ||
nextChar = file.getChar(); | ||
var beatcount = ""; | ||
while ( { nextChar != $| && nextChar != nil }, { beatcount = beatcount ++ nextChar; nextChar = file.getChar() } ); | ||
if (nextChar == nil, { Error("premature eof in" + filename).throw }); | ||
beatcount = beatcount.asInteger; | ||
beats = Array.new(beatcount) | ||
beatcount.do({ | ||
arg beat; | ||
beats[beat] = BeatInfo.new(bandcount); | ||
bandcount.do({ | ||
arg band; | ||
beats[beat].bands[band] = BandInfo.new(); | ||
beats[beat].bands[band].left = file.getDouble(); | ||
beats[beat].bands[band].right = file.getDouble(); | ||
}); | ||
}); | ||
nextChar = file.getChar(); | ||
if ( nextChar == nil, {done = true}); | ||
}); | ||
^beats; | ||
} | ||
|
Oops, something went wrong.