modToWave {ProTrackR} | R Documentation |
Convert a PTModule object into an audio Wave object
Description
Converts a PTModule
object into a tuneR::Wave
object, which can be played, further analysed, modified and saved.
Usage
## S4 method for signature 'PTModule'
modToWave(
mod,
video = c("PAL", "NTSC"),
target.rate = 44100,
target.bit = 16,
stereo.separation = 1,
low.pass.filter = TRUE,
tracks = 1:4,
mix = TRUE,
...
)
Arguments
mod |
An object of class |
video |
The video mode of a Commodore Amiga affects timing routines and
the playback sample rate. This mode can be specified with this argument and
is represented by a |
target.rate |
A positive |
target.bit |
Number of bits for the target |
stereo.separation |
A |
low.pass.filter |
A |
tracks |
Either |
mix |
A logical value indicating whether the 4 Amiga channels should
be mixed to the 2 (stereo) output channels. When set to |
... |
Additional arguments that are passed to |
Details
Before the PTModule
object can be converted into a
tuneR::Wave
object, the rows of the
PTPattern
objects in the module need to be put
in the right order. This method does that by calling
playingtable
.
Once the rows of the pattern tables are in the right order, all selected
PTTrack
objects of the module are looped by this function
and the routines described below are applied to each track.
On the Commodore Amiga the chip responsible for audio output (Paula),
the audio playback of samples can be controlled by the user in two ways:
the playback rate of the sample can be changed by specifying 'period'
values (see e.g. periodToSampleRate
) and specifying a
volume which is linearly scaled between 0 (silent) and 64 (maximum).
So, for each track, the correct period and volume values are determined based on the note, effect command and sample information in the module.
Then, the PTSample
objects are resampled, using the
period values and volume values as determined in the previous step.
Next audio filters are applied to mimic original Commodore Amiga sound. Finaly, the wave data for each separate track is mixed to one (mono) or two (stereo) of the output channels.
Converting ProTracker modules into wave objects can be time consuming. The time required to convert an object obviously depends on your machine's capacities and the length of the module but also the complexity of the module. To speed up the conversion you could reduce the target sample rate or turn off the low pass filter. On modern machines, the time required for conversion should generally be less than the playback time of the module.
You can save the resulting tuneR::Wave
object by calling
tuneR::writeWave
.
Value
A tuneR::Wave
object, generated from the
mod
object is returned. A tuneR::WaveMC
object is returned when
the mix
argument is set to FALSE
.
Note
As audio can be mixed with this package at frequencies much greater than the Commodore Amiga's audio output rate, some aliasing of the sound could occur. This results in high frequency audio, that would not be produced on an Amiga. The current version of this package does not filter out these artefacts. This should not be a problem if you're not concerned with producing an accurate Amiga timbre.
Author(s)
Pepijn de Vries
See Also
Other module.operations:
PTModule-class
,
appendPattern()
,
clearSamples()
,
clearSong()
,
deletePattern()
,
fix.PTModule()
,
moduleSize()
,
patternLength()
,
patternOrderLength()
,
patternOrder()
,
playMod()
,
playingtable()
,
rawToPTModule()
,
read.module()
,
trackerFlag()
,
write.module()
Examples
## Not run:
data(mod.intro)
wav <- modToWave(mod.intro)
## End(Not run)