Skip to content

Instantly share code, notes, and snippets.

View simonrolph's full-sized avatar

Simon Rolph simonrolph

View GitHub Profile
@statisfactions
statisfactions / midifunctions.R
Created February 26, 2012 04:19
hack functions to generate MIDI output from R using midicv and play using timidity, with usage example at end
midi <- function(title="R-created Midi", bpm=120){
## Creates empty "midi" object that tracks can be inserted into
options(scipen=7) ## avoids writing anything here in scientific notation
## Create new data.frame and add headers
newdf <- data.frame(matrix(nrow=7,ncol=7))
names(newdf) <- c("tracknum", "time", "type","channel", "note", "velocity", "tempoonly")
newdf[1,] <- c(0,0, "Header", 1, 1, 480, NA)
newdf[2,] <- c(1,0, "Start_track", NA, NA, NA, NA)