soundgen (version 1.5.0)

playme: Play audio

Description

Plays an audio file (wav or mp3) or a numeric vector. This is a simple wrapper for the functionality provided by play. Recommended players on Linux: "play" from the "vox" library (default), "aplay".

Usage

playme(sound, samplingRate = 16000, player = NULL, from = NULL,
  to = NULL)

Arguments

sound

numeric vector or path to wav/mp3 file

samplingRate

sampling rate (only needed if sound is a vector)

player

the name of player to use, eg "aplay", "play", "vlc", etc. In case of errors, try setting another default player for play

from, to

play a selected time range (s)

...

additional parameters passed to play

Examples

Run this code
# NOT RUN {
# Play an audio file:
# playme('pathToMyAudio/audio.wav')

# Create and play a numeric vector:
f0_Hz = 440
sound = sin(2 * pi * f0_Hz * (1:16000) / 16000)
# playme(sound, 16000)
# playme(sound, 16000, from = .1, to = .5)  # play from 100 to 500 ms

# In case of errors, look into tuneR::play(). For ex., you might need to
# specify which player to use:
# playme(sound, 16000, player = 'aplay')

# To avoid doing it all the time, set the default player:
tuneR::setWavPlayer('aplay')
# playme(sound, 16000)  # should work without specifying the player
# }

Run the code above in your browser using DataLab