record | R Documentation |
record
record audio using the current audio device
record(where, rate, channels)
where |
object to record into or the number of samples to record |
rate |
sample rate. If ommitted it will be taken from the |
channels |
number of channels to record. If ommitted it will be taken from the |
The record
function creates an audio instance of the current
audio driver to start audio recording. The recording is performed
asynchronously and the function returns immediately after the
recording is started.
where
can either be a numeric vector of the storage mode
‘double’ and length greater than 1 or a numberic vector of length
one specifying the number of samples to record. The the former case
the audio data is recorded directly to the vector, in the latter
case a new object (initialized with NA
) is created internally
(and thus only accessible using a$data
where a
is the
audio instance).
The recording is automatically stopped after the where
object
has been completely filled. Nonetheless pause
can be
used to stop the recoding at any time.
Returns an audio instance object which can be used to control the recording subsequently.
x <- rep(NA_real_, 16000)
# start recording into x
record(x, 8000, 1)
# monitor the recording progress
par(ask=FALSE) # for continuous plotting
while (is.na(x[length(x)])) plot(x, type='l', ylim=c(-1, 1))
# play the recorded audio
play(x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.