mirror of
https://github.com/microtherion/VocalEasel.git
synced 2024-12-22 19:23:59 +00:00
More BIAB fixes
This commit is contained in:
parent
2d90e4ac2d
commit
ed7870b336
|
@ -2,7 +2,7 @@
|
||||||
#
|
#
|
||||||
# VLBIABType.reader - Import Band-in-a-Box files
|
# VLBIABType.reader - Import Band-in-a-Box files
|
||||||
#
|
#
|
||||||
# Reverse engineering by Alf Warnock & Alain Brenzikofer
|
# Based on reverse engineering work by Alf Warnock & Alain Brenzikofer
|
||||||
#
|
#
|
||||||
|
|
||||||
DEBUG = false
|
DEBUG = false
|
||||||
|
@ -317,17 +317,19 @@ numRepeats = $stdin.read(1)[0]
|
||||||
biab = $stdin.read
|
biab = $stdin.read
|
||||||
|
|
||||||
styleFile = nil
|
styleFile = nil
|
||||||
if biab =~ /B.(.{1,8})\.STY/
|
if biab =~ /B.(.{1,8})\.STY/m
|
||||||
styleFile = $1
|
styleFile = $1
|
||||||
end
|
end
|
||||||
noteCount = 0
|
noteCount = 0
|
||||||
if biab =~ /\x00\xFF\x00(?:\x0D|\x0E)(..)/
|
if biab =~ /\x00\xFF\x00(?:\x0D|\x0E|\x0F)(..)/m
|
||||||
noteCount = $1.unpack('v')[0]
|
noteCount = $1.unpack('v')[0]
|
||||||
end
|
end
|
||||||
|
|
||||||
styleFile = File.basename(styleFile, '.STY')
|
if styleFile
|
||||||
puts "Style #{styleFile}" if DEBUG
|
styleFile = File.basename(styleFile, '.STY')
|
||||||
groove = STY_GROOVE[styleFile] || groove
|
puts "Style #{styleFile}" if DEBUG
|
||||||
|
groove = STY_GROOVE[styleFile] || groove
|
||||||
|
end
|
||||||
OUTPUT['groove'] = groove[0] || 'Swing'
|
OUTPUT['groove'] = groove[0] || 'Swing'
|
||||||
if groove.size > 1
|
if groove.size > 1
|
||||||
PROP['timeNum'] = groove[1]
|
PROP['timeNum'] = groove[1]
|
||||||
|
@ -336,9 +338,11 @@ end
|
||||||
|
|
||||||
RAWNOTES = []
|
RAWNOTES = []
|
||||||
ONSETS = [0,0,0,0,0,0,0,0,0,0,0,0]
|
ONSETS = [0,0,0,0,0,0,0,0,0,0,0,0]
|
||||||
if biab.sub!(/.*?\xA0\xB0\xC1/, '')
|
if biab.sub!(/^.*?\xA0\xB0\xC1/m, '')
|
||||||
|
noteCount = biab.length / 12 if noteCount == 0
|
||||||
(0...noteCount).each do |i|
|
(0...noteCount).each do |i|
|
||||||
onset, channel, pitch, velocity, duration = biab[i*12, 12].unpack('VCCCxV')
|
onset, channel, pitch, velocity, duration = biab[i*12, 12].unpack('VCCCxV')
|
||||||
|
break if channel==0
|
||||||
puts "O #{onset}; C #{channel}; P #{pitch}; V #{velocity}; D #{duration}" if DEBUG
|
puts "O #{onset}; C #{channel}; P #{pitch}; V #{velocity}; D #{duration}" if DEBUG
|
||||||
if channel==176 or channel==179
|
if channel==176 or channel==179
|
||||||
pitch = VL::NoPitch
|
pitch = VL::NoPitch
|
||||||
|
@ -376,6 +380,7 @@ nextMeas = 0
|
||||||
melo = nil
|
melo = nil
|
||||||
lastNote = nil
|
lastNote = nil
|
||||||
lastOnset = 0
|
lastOnset = 0
|
||||||
|
maxMeas = 0
|
||||||
while RAWNOTES.size > 0 || CHORDS.size > 0
|
while RAWNOTES.size > 0 || CHORDS.size > 0
|
||||||
if note = RAWNOTES.shift
|
if note = RAWNOTES.shift
|
||||||
if note[0] > nextMeas
|
if note[0] > nextMeas
|
||||||
|
@ -409,6 +414,9 @@ while RAWNOTES.size > 0 || CHORDS.size > 0
|
||||||
lastOnset = note[0]
|
lastOnset = note[0]
|
||||||
lastNote = {'pitch' => note[1], 'tied' => note[2] ? VL::TiedWithPrev : 0}
|
lastNote = {'pitch' => note[1], 'tied' => note[2] ? VL::TiedWithPrev : 0}
|
||||||
melo.push(lastNote)
|
melo.push(lastNote)
|
||||||
|
if note[1] != VL::NoPitch
|
||||||
|
maxMeas = measNo-1
|
||||||
|
end
|
||||||
else
|
else
|
||||||
if lastNote
|
if lastNote
|
||||||
lastDur = VL::Fract.new(nextMeas-lastOnset, 48)
|
lastDur = VL::Fract.new(nextMeas-lastOnset, 48)
|
||||||
|
@ -427,7 +435,13 @@ while RAWNOTES.size > 0 || CHORDS.size > 0
|
||||||
end
|
end
|
||||||
if measNo > 2 && CHORDS.size > 0 && !meas['chords']
|
if measNo > 2 && CHORDS.size > 0 && !meas['chords']
|
||||||
meas['chords'] = chords = []
|
meas['chords'] = chords = []
|
||||||
|
time = VL::Fract.new(PROP['timeNum'], PROP['timeDenom'])
|
||||||
(0..3).each do |i|
|
(0..3).each do |i|
|
||||||
|
if i==2 && time > VL::Fract.new(4,4)
|
||||||
|
extra = time - VL::Fract.new(4,4)
|
||||||
|
chords.push({'pitch' => VL::NoPitch,
|
||||||
|
'durNum' => extra.num, 'durDenom' => extra.denom})
|
||||||
|
end
|
||||||
pitch = CHORDS.shift
|
pitch = CHORDS.shift
|
||||||
steps = STEPS.shift
|
steps = STEPS.shift
|
||||||
root = ROOTS.shift
|
root = ROOTS.shift
|
||||||
|
@ -436,13 +450,11 @@ while RAWNOTES.size > 0 || CHORDS.size > 0
|
||||||
root ||= VL::NoPitch
|
root ||= VL::NoPitch
|
||||||
chords.push({'pitch' => pitch, 'steps' => steps, 'root' => root,
|
chords.push({'pitch' => pitch, 'steps' => steps, 'root' => root,
|
||||||
'durNum' => 1, 'durDenom' => 4})
|
'durNum' => 1, 'durDenom' => 4})
|
||||||
|
if pitch != VL::NoPitch
|
||||||
|
maxMeas = measNo-1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
time = VL::Fract.new(PROP['timeNum'], PROP['timeDenom'])
|
if time < VL::Fract.new(3,4)
|
||||||
if time > VL::Fract.new(4,4)
|
|
||||||
extra = time - VL::Fract.new(4,4)
|
|
||||||
chords.push({'pitch' => VL::NoPitch,
|
|
||||||
'durNum' => time.num, 'durDenom' => time.denom})
|
|
||||||
elsif time < VL::Fract.new(3,4)
|
|
||||||
chords.pop
|
chords.pop
|
||||||
chords.pop
|
chords.pop
|
||||||
elsif time < VL::Fract.new(4,4)
|
elsif time < VL::Fract.new(4,4)
|
||||||
|
@ -451,6 +463,7 @@ while RAWNOTES.size > 0 || CHORDS.size > 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
MEAS[maxMeas+1..-1] = nil
|
||||||
adjust = 0
|
adjust = 0
|
||||||
if MEAS.size > 1 && MEAS[0]['melody'].size == 1 &&
|
if MEAS.size > 1 && MEAS[0]['melody'].size == 1 &&
|
||||||
MEAS[0]['melody'][0]['pitch'] == VL::NoPitch
|
MEAS[0]['melody'][0]['pitch'] == VL::NoPitch
|
||||||
|
|
Loading…
Reference in New Issue
Block a user