
# converts a mat file to event.frame
mat2eventFrame=function(data.mat)
{
  data.mat=data.frame(data.mat[[1]])
  colnames(data.mat)=c("track.number", "channel.number", "note.number", "velocity",
                        "start.time", "end.time", "message.number.note.on", "message.number.note.off")
  return(data.mat)
  
}

# rule the loudness of notes
noteLoudness=function(WAVE,Laut)
{
 m=max(max(WAVE@left),abs(min(WAVE@left)))
 faktor=Laut/m
 WAVE@left=WAVE@left*faktor
 return(WAVE)
}


# cut the notes of wind instrument
chi=function(x,n,w)
{
 ww=1/w
 y=(((x)^(n/2-1))^ww * (exp(-(x*ww)/2)))/ ( 2^(n*ww/2)* (gamma(n/2))^ww)
 return(y)
}

# sum of two amplitude vectors
plus=function(v1,v2)
{
 if(is.null(v1) == TRUE)
  v3=v2 
 else{
  v3=NULL 
  v3=v1+v2
 }
 return(v3)
}

