Is it possible to code music in R and play it back? (Mac OS X) -


i wonder if there way write script in r create music. coding program (supercollider or, less coding still, pure data), want know if there way generate sound in r.

actually, know how can play birthday music using r?, nice. want chords , multi instrumental composition. possible?

is there simpler way play music in r happy birthday link?

you can create music in r programming using tuner library

first need create simple sine waves each note , concatenate notes vector.

now tune ready, can edit sound using different sound processing techniques timbre, filtering etc.

example create simple a4 note:

library(tuner)        #import tuner library setwavplayer("audacious") f=440                 #frequency of a4 note sr=8000  bits=16 secs=2                #length of note set 2 amp=1 t=seq(0, secs, 1/sr) y= amp*sin(2*pi*f*t)  #make sinewave above attributes s=floor(2^(bits-2)*y) #floor make integer value u=wave(s, samp.rate=sr, bit=bits)  #make wave structure  play(u) 

to concatenate 2 notes x , y, use vector notation:

z=c(x,y) w= wave(z, samp.rate=sr, bit-bits) 

to play 2 notes simultaneously (play chords instance)

z=x+y  w= wave(z, samp.rate=sr, bit-bits) 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -