[Rd] R sings

Erich Neuwirth erich.neuwirth@univie.ac.at
Fri, 29 Dec 2000 19:45:16 +0100


i have created a package which allows R to play sounds
the package is available from
http://sunsite.univie.ac.at/~neuwirth/Rcsound/
both as zipped binary for windows and as installable tar.gz

preequisite:
you have to install csound on yout machine.
the necessary links are at http://www.csound.org

csound is a very portable program for creating sounds,
and using it as out sound creation tool we remain portable.

i am interested in getting feedback.

btw:
csound is NOT easy to use.
but for the purposes of our package,
it is only necessary to install it.

my package is vert preliminary,
so i would like feedback.

here is the README


-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


This is a VERY preliminary version of an R package
for playing sounds.

To install, unzip the complete archive in the library directory of R.

The presequesites:
You have to install CSOUND,
a very powerful sound generation program.
Information is avalaible at http://www.csound.org
You also can find most version on
http://sunsite.univie.ac.at/pub/sound/csound/

You have to find the command line parameters
needed to run csound on your platform.
You need at least verson 4.0,
current version at design time of this package is 4.08.
our package has been tested with 
"Canonical" Csound on Linux
and DirectCsound on Win32.

option$csound.debug
and
option$csound.plain 
have to contain the command line needed to run
csound in normal mode and in debugging mode
(debugging mode means you want to see a window with csound's messages)
The package as is is configured for windows,
a comment contains the command line for Linux.

At the moment, we have only 2 instruments,
instrument 1 is a sine wave,
and
instrument 11 is a simple plucked string.

currently, the library contains 4 functions

csndPlayMono
csndPlayStereo
csndCorrphone
csndFourierTones

all these function play sequences of notes with given frequencies,
starting times, durations, and volume levels.

Basic interface functions:

csndPlayMono (instr=NULL, start=NULL, dur=NULL, vol=NULL, freq=NULL,
  file=NULL, debug.csound=FALSE)

csndPlayStereo(instr=NULL, start=NULL, dur=NULL, vol=NULL, freq=NULL,
pos = 0, 
  file=NULL, debug.csound=FALSE)

instr	instrument number
start   vector of starting times for single notes 
dur     vector of duration of single notes
vol	vector of volume of single notes
freq    vector of volume of single notes
pos     vector of positions of notes (extreme values -1 left channel, 1
right channel)
file    name of temporary file to be used as input for csound
debug.csound
	if TRUE csound window will remain visible


Attempt at "statistical" sound functions

csndCorrphone(instr, freq1, freq2, dur, vol=8000,
  file=NULL, debug.csound=FALSE)

instr	instrument number
freq1,freq2
	vector of frequencies to be played simultaneously on left and right
channel.
dur	should be a single value, used for duraion of all notes

csndFourierTones(fourcoeffs, freq=264, dur=1, vol=8000,
  file=NULL, debug.csound=FALSE)

fourcoeffs	matrix, each row is interpreted as fourier coefficients,
		and the correspronding tone is played for each row
freq		frequency of the tones (should be equal for all tones)
dur		duration in seconds
vol		volume for tones




Here are some example to try:

csndPlayMono(11,c(0:12),1,8000,264*2^(c(0:12)/12))
csndPlayStereo(11,c(0:12),1,8000,264*2^(c(0:12)/12),c(-6:6)/6)

r<-0.9
x1<-rnorm(10)
x2<-rnorm(10)
x3<-r*x1+sqrt(1-r^2)*x2
f1<-264+50*x1
f3<-264+50*x3
csndCorrphone(11,f1,f3,1)

fmat<-rbind(1/1:20,rep(c(1,0),10)*1/1:20,(1/(1:20))^2*rep(c(1,-1),10))
csndFourierTones(fmat,dur=2)







--
Erich Neuwirth, Computer Supported Didactics Working Group
Visit our SunSITE at http://sunsite.univie.ac.at
Phone: +43-1-4277-38624 Fax: +43-1-4277-9386
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._