May 13, 2006

PLOTMIDI V2

#configurable
x=read.csv("in2.csv");
timebase=384;
tempo=789494;

#do not change unless you know what you are doing
grid=150;
tones_start=27;
tones=c("HighQ","Slap","ScratchPush","ScratchPull","Sticks",
"SquareClick","MetronomeClick","MetronomeBell","KickDrum2",
"KickDrum1","SideKick","SnareDrum1","HandClap","SnareDrum2",
"LowTom2","ClosedHiHat","LowTom1","PedalHiHat","MidTom2",
"OpenHiHat","MidTom1","HighTom2","CrashCymbal1","HighTom1",
"RideCymbal1","ChineseCymbal","RideBell","Tambourine","SplashCymbal",
"CowBell","CrashCymbal2","VibraSlap","RideCymbal2","HighBongo",
"LowBongo","MuteHighConga","OpenHighConga","LowConga",
"HighTimbale","LowTimbale","HighAgogo","LowAgogo",
"Cabasa","Maracas","ShortHiWhistle","LongLowWhistle",
"ShortGuiro","LongGuiro","Claves","HighWoodBlock",
"LowWoodBlock","MuteCuica","OpenCuica","MuteTriangle",
"OpenTriangle","Shaker","JingleBell","Castanets","MuteSudro","OpenSudro")


tick=tempo/timebase;
x$time=x$time*tick/1000000;
xmax=max(x$time);
ymin=0;

postscript("drum.eps", horizontal=FALSE, onefile=FALSE,paper="special",height=10,width=14);

tone=rep(0,128);
f=factor(x$tone);
ymax=length(levels(f))*grid;
i=0;
plot(0,0,xlim=c(-10,xmax),ylim=c(ymin,ymax),xlab="",ylab="");
for (ii in levels(f)){
t=x$time[x$tone==ii];
v=x$velocity[x$tone==ii];
lines(t,i*grid+v,type="s"); text(-5,i*grid+grid/2,tones[as.numeric(ii)-tones_start+1],cex=1.0);
i=i+1;
}

dev.off()

No comments:

Post a Comment