mirror of
https://github.com/microtherion/VocalEasel.git
synced 2024-12-22 19:23:59 +00:00
Allow input on command line
This commit is contained in:
parent
0755217a57
commit
37954c7b4f
|
@ -61,17 +61,17 @@ KEY = [[ 0, 1],
|
||||||
[ 3,-1], [-2,-1], [ 5,-1], [ 0,-1], [-5,-1], [ 2,-1],
|
[ 3,-1], [-2,-1], [ 5,-1], [ 0,-1], [-5,-1], [ 2,-1],
|
||||||
[ 4,-1], [ 6,-1], [ 3,-1], [ 5,-1], [ 7,-1]]
|
[ 4,-1], [ 6,-1], [ 3,-1], [ 5,-1], [ 7,-1]]
|
||||||
|
|
||||||
$stdin.read(1) # Skip 1 Byte
|
INFILE.read(1) # Skip 1 Byte
|
||||||
titleLen = $stdin.read(1)[0]
|
titleLen = INFILE.read(1)[0]
|
||||||
OUTPUT['title'] = $stdin.read(titleLen)
|
OUTPUT['title'] = INFILE.read(titleLen)
|
||||||
|
|
||||||
$stdin.read(2) # Skip 2 Bytes
|
INFILE.read(2) # Skip 2 Bytes
|
||||||
gr = $stdin.read(1)[0]-1
|
gr = INFILE.read(1)[0]-1
|
||||||
groove = GROOVE[gr] || ['Swing']
|
groove = GROOVE[gr] || ['Swing']
|
||||||
key = KEY[$stdin.read(1)[0]]
|
key = KEY[INFILE.read(1)[0]]
|
||||||
PROP['key'] = key[0]
|
PROP['key'] = key[0]
|
||||||
PROP['mode'] = key[1]
|
PROP['mode'] = key[1]
|
||||||
OUTPUT['tempo'] = $stdin.read(1)[0]
|
OUTPUT['tempo'] = INFILE.read(1)[0]
|
||||||
|
|
||||||
#
|
#
|
||||||
# Style map - not processed yet
|
# Style map - not processed yet
|
||||||
|
@ -79,12 +79,12 @@ OUTPUT['tempo'] = $stdin.read(1)[0]
|
||||||
STYLES = []
|
STYLES = []
|
||||||
i=0
|
i=0
|
||||||
while i < 256
|
while i < 256
|
||||||
st = $stdin.read(1)[0]
|
st = INFILE.read(1)[0]
|
||||||
if st > 0
|
if st > 0
|
||||||
STYLES[i-1] = st
|
STYLES[i-1] = st
|
||||||
i += 1
|
i += 1
|
||||||
else
|
else
|
||||||
i += $stdin.read(1)[0]
|
i += INFILE.read(1)[0]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -282,12 +282,12 @@ EXT = [
|
||||||
STEPS = []
|
STEPS = []
|
||||||
i = 0
|
i = 0
|
||||||
while i < 1020
|
while i < 1020
|
||||||
ex = $stdin.read(1)[0]
|
ex = INFILE.read(1)[0]
|
||||||
if ex > 0
|
if ex > 0
|
||||||
STEPS[i] = EXT[ex]
|
STEPS[i] = EXT[ex]
|
||||||
i += 1
|
i += 1
|
||||||
else
|
else
|
||||||
i += $stdin.read(1)[0]
|
i += INFILE.read(1)[0]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -297,7 +297,7 @@ CHORDS = []
|
||||||
ROOTS = []
|
ROOTS = []
|
||||||
i = 0
|
i = 0
|
||||||
while i < 1021
|
while i < 1021
|
||||||
cr = $stdin.read(1)[0]
|
cr = INFILE.read(1)[0]
|
||||||
if cr > 0
|
if cr > 0
|
||||||
CHORDS[i] = PITCHES[cr % 18]
|
CHORDS[i] = PITCHES[cr % 18]
|
||||||
if cr > 18
|
if cr > 18
|
||||||
|
@ -305,15 +305,15 @@ while i < 1021
|
||||||
end
|
end
|
||||||
i += 1
|
i += 1
|
||||||
else
|
else
|
||||||
i += $stdin.read(1)[0]
|
i += INFILE.read(1)[0]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
$stdin.read(1) # Start measure
|
INFILE.read(1) # Start measure
|
||||||
numMeasures = $stdin.read(1)[0]
|
numMeasures = INFILE.read(1)[0]
|
||||||
numRepeats = $stdin.read(1)[0]
|
numRepeats = INFILE.read(1)[0]
|
||||||
|
|
||||||
biab = $stdin.read
|
biab = INFILE.read
|
||||||
|
|
||||||
styleFile = nil
|
styleFile = nil
|
||||||
if biab =~ /B.(.{1,8})\.STY/m
|
if biab =~ /B.(.{1,8})\.STY/m
|
||||||
|
|
|
@ -14,7 +14,7 @@ OUTPUT = {'measures' => []}
|
||||||
# Lex
|
# Lex
|
||||||
#
|
#
|
||||||
tokens = []
|
tokens = []
|
||||||
$stdin.each do |line|
|
INFILE.each do |line|
|
||||||
line.chomp!.sub!(/%.*/, "")
|
line.chomp!.sub!(/%.*/, "")
|
||||||
line.scan(%r$\G\s*(\{|\}|\(|\)|\||=|~|<<|>>|--|#'|#\(|##t|##f|\\\w+|\".*?\"|\w[-+\w\d.',:*/]+|.)$) do |token|
|
line.scan(%r$\G\s*(\{|\}|\(|\)|\||=|~|<<|>>|--|#'|#\(|##t|##f|\\\w+|\".*?\"|\w[-+\w\d.',:*/]+|.)$) do |token|
|
||||||
tokens.push(token[0])
|
tokens.push(token[0])
|
||||||
|
|
|
@ -444,7 +444,7 @@ class MusicXMLListener
|
||||||
end
|
end
|
||||||
|
|
||||||
listener = MusicXMLListener.new
|
listener = MusicXMLListener.new
|
||||||
REXML::Document.parse_stream($stdin, listener)
|
REXML::Document.parse_stream(INFILE, listener)
|
||||||
writePlist($stdout, OUTPUT)
|
writePlist($stdout, OUTPUT)
|
||||||
|
|
||||||
# Local Variables:
|
# Local Variables:
|
||||||
|
|
|
@ -7,7 +7,7 @@ require File.dirname($0)+'/plistReader'
|
||||||
require File.dirname($0)+'/vl'
|
require File.dirname($0)+'/vl'
|
||||||
require 'rexml/document'
|
require 'rexml/document'
|
||||||
|
|
||||||
INPUT = readPlist($stdin)
|
INPUT = readPlist(INFILE)
|
||||||
|
|
||||||
$USE_FLATS = false
|
$USE_FLATS = false
|
||||||
$DIVISIONS = 3
|
$DIVISIONS = 3
|
||||||
|
|
|
@ -112,7 +112,7 @@ class VL
|
||||||
@denom /= g
|
@denom /= g
|
||||||
end
|
end
|
||||||
|
|
||||||
def -()
|
def -@()
|
||||||
return Fract.new(-@num, @denom)
|
return Fract.new(-@num, @denom)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -129,3 +129,9 @@ class VL
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if ARGV.size > 0
|
||||||
|
INFILE = File.new(ARGV[0], "r")
|
||||||
|
else
|
||||||
|
INFILE = $stdin
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user