| |
# MIDI Mixup
#
# Read 3 MIDI files, and use the pitches from the first one, the channels
# from the second one, and the durations from the third one.
function mixup(fname1,fname2,fname3) {
f1 = readmf(fname1)
f2 = readmf(fname2)
f3 = readmf(fname3)
f1.length = latest(f1)
f2.length = latest(f2)
f3.length = latest(f3)
p = mixitup(f1,f2,f3)
writemf(p,"www.mid")
writelines(p,"www.lines")
}
function mixitup(f1,f2,f3) {
f1 = onlynotes(f1)
f2 = onlynotes(f2)
f3 = onlynotes(f3)
s1 = sizeof(f1)
s2 = sizeof(f2)
s3 = sizeof(f3)
nnotes = s1
if ( s2 < nnotes )
nnotes = s2
if ( s3 < nnotes )
nnotes = s3
r = ''
for ( n=0; n<nnotes; n++ ) {
nt = 'a'
nt.pitch = (f1%n).pitch
# we use the time and channel from the second midi file
nt.time = (f2%n).time
nt.chan = (f2%n).chan
nt.duration = (f3%n).duration
r |= nt
}
return(r)
}
|