I guess you use these two different packages:
tuneR
to import your wave fileaudio
for its playback functions
Unfortunately these packages each have their own object classes: Wave
class in tuneR
and audioSample
class in audio
. If you want to use the playback functions of audio
you first need an object of class audioSample
. You can get this by importing your wave file with audio's own import function
mywav <- load.wave("myaudiosample.wav")
but since tuneR
can also import mp3 files and has more import options it may be necessary to create your own audioSample
object manually from a Wave
object. A simple mono file for example could be converted the following way:
myWave <- readWave("myaudiosample.wav")
mywav <- audioSample(myWave@left, myWave@samp.rate, myWave@bit)
You can then use the playback functions from audio
. Just make sure to call audio::play()
, it might be masked by tuneR
a <- audio::play(mywav)
pause(a)
resume(a)