record {audio}R Documentation

Record audio


record record audio using the current audio device


record(where, rate, channels) 



object to record into or the number of samples to record


sample rate. If ommitted it will be taken from the where object or default to 44100


number of channels to record. If ommitted it will be taken from the where object or default to 2. Note that most devices only support 1 (mono) or 2 (stereo).


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 ([length(x)])) plot(x, type='l', ylim=c(-1, 1))
# play the recorded audio

[Package audio version 0.1-6 Index]