Detecting Pitches in music with R

In a previous post, I described a method to detect a chord using a Fourier transform in Java/Scala. I’ve re-implemented the same in R, detailed below. This will generate an audio file containing the C-Major chord: library(sound) c<-261.63 e<-164.81 g<-196 len<-1 cData<-Sine(c,len) eData<-Sine(e,len) gData<-Sine(g,len) audio<-normalize(cData+eData+gData) saveSample(audio, “out\\ceg.wav”, overwrite=TRUE) And a series of helper functions: magnitude<-function(x) …