Skip to contents


SonicScrewdriveR introduces several tools for working with audio data, such as the TaggedWave and TaggedWaveMC formats. Inside SonicScrewdriveR the Tagged and non-Tagged versions of Wave-like objects can be used interchangeably, however this is not necessarily true for functions from other packages.

This guide is aimed both at end users and package developers who want to convert their code to work with SonicScrewdriveR.

TaggedWave and TaggedWaveMC

# Generate a `Wave` and `TaggedWave` sine
w <- tuneR::sine(440)
tw <- tagWave(w)

If we try to use a function that expects a Wave object with a TaggedWave object, we will get an error.

# This will fail
#> Error in seewave::oscillo(tw): argument "f" is missing, with no default

As an end user you can use the untagWave function to convert a TaggedWave object to a Wave object.

# This will work

The untagWave function can also be used to ‘untag’ a TaggedWaveMC object.

To fix this in your own function or package you can make use of inherits() rather than alternative methods.

# Methods that fail
is(w, "Wave")
class(w) == "Wave"

# Method that works
inherits(w, "Wave")

As TaggedWave inherits from Wave it can be treated like a Wave in your code.

The same technique can be used for TaggedWaveMC objects with inherits(w, "WaveMC").

Adding a process to a Tagged Wave-like object

If you want to add a process to a TaggedWave object you can use the addProcess method. This can either be called by the end user, or by functions that are aware of the Tagged versions.

# End user using non-Tagged aware function
addProcess(tw, "seewave::oscillo")

# Inside a Tagged aware function
  process = "mypkg::functionToCountChannels",
  output = list(channels = 2)