[id] = soundfx.Process(src, dst[, fx])
src. The source sample(s) won't be modified directly. Instead, this function will
create a new sample using the identifier specified by dst. If you pass Nil in
dst, soundfx.Process() will automatically choose an available identifier
and return it to you. The source and destination samples mustn't be the same.
The src argument can either be the identifier of a sample or it can be a table
containing a number of samples. If src is a table, it must contain a subtable
for each sample that you want to pass to soundfx.Process(). The subtable can
contain the following fields:
ID
Volume#SOUNDFX_MIX mode. In that case, it allows you to fine-tune
the volume of the individual samples to be mixed together. This tag defaults to
1.0 which means that no changes to the volume will be made.
When passing multiple samples to soundfx.Process(), you can use the Mode table
tag to specify how the samples should be processed. By default, #MODE_JOIN is
used which means that the samples will be processed one after the other so that
once soundfx.Process() has finished, all samples will have been joined together.
Alternatively, you can also use #MODE_MIX which means that the samples will be
mixed together. Finally, there's also #MODE_MERGE and #MODE_MULTIPLY. See below
for details.
Note that when passing multiple samples to soundfx.Process(), all samples must
use the same sampling rate. When using #MODE_JOIN (the default), the samples
must also use the same channel layout.
The effect(s) that should be applied to the sample must be specified in the
fx table argument. This must be set to a table of tables, i.e. a table containing
an arbitrary number of subtables, each containing a single effect specification
that should be applied to the sample. The effects are applied to the sample in
the order they appear in the fx.
The subtables containing the effect specification must start with the name
of the effect followed by the individual effect parameters. These differ from
effect to effect. Please see the individual effect descriptions in the following
chapters to find out about mandatory and optional effect parameters. Also see
the chapter on effect parameters to learn about how
the effect syntax is constructed. Also note that some effects like synth
are generative which means that they produce their own audio instead of processing
given audio data. To use such generative effects you need to use soundfx.Generate()
instead of soundfx.Process().
Additionally, the fx table also allows you to specify some other options
that shall be passed to the sound processor. The following options are
currently recognized:
Mode
#SOUNDFX_JOIN
#SOUNDFX_MIX
#SOUNDFX_MERGE
#SOUNDFX_MULTIPLY
The default mode is #SOUNDFX_JOIN.
Frequency
Bits
Channels
Verbosity
0
1
2
3
4 and above
By default, messages are printed to the standard output but you can also
intercept them by installing a callback function using the Callback tag
(see below).
Callback
Action#SOUNDFX_STATUS if the callback has been run to
inform you about a status update or it can be #SOUNDFX_OUTPUT if the callback
has been run because a message should be output.
ProcessedAction is #SOUNDFX_STATUS.
TotalAction is #SOUNDFX_STATUS.
OutputAction is #SOUNDFX_OUTPUT.
UserDataUserData tag (see below) to specify data that should be passed to the
callback, this field will be initialized to contain this user data. Otherwise
this field won't be set.
UserDataCallback tag to a callback function, you can use this
tag to specify user data that should be passed to your callback function whenever
it is run. The user data you specify here will be passed in the UserData
element of the table argument that is passed to the callback function.
SoftwareTrue, the destination sample will be created as a
software sample. See the Hollywood manual for more information on the
difference between software and hardware samples. Defaults to False.
UseTempFileTrue.
Otherwise everything will be done in memory. Setting this to True can be
useful when dealing with large samples on low-memory systems. Defaults to
False.
Note that the fx table can also be omitted. In that case, no effects are
applied and the source sample is simply copied to the destination one, or,
if multiple samples are specified, the source samples are concatenated to
form the destination sample.
Nil for auto id selectionNil as argument 2 (see above)
soundfx.Process(1, 2, {{"tempo", "0.8"}})
The code above reduces the tempo of sample 1 to 80% of its original playback
speed and stores the result in sample 2.
soundfx.Process(1, 2, {{"phaser"}, {"vol", "0.5"}})
The code above first applies the phaser effect to sample 1 and then reduces the
volume to 50%. The result will be stored in sample 2.
soundfx.Process(1, 2, {{"rate", "48k"}}, {Frequency = 48000})
The code above resamples the audio data of sample 1 to 48000hz and stores the result
in sample 2. Note that we must pass the new frequency in the table which is passed as the
4th parameter. Passing the 4th parameter is only necessary for effects which
modify the sample resolution (i.e. bit depth, frequency, channel layout). See above
for more information.
soundfx.Process({{ID = 1}, {ID = 2}}, 3)
The code above will concatenate samples 1 and 2 and store the result in sample 3.
soundfx.Process({{ID = 1, Volume = 0.5}, {ID = 2}}, 3, {Mode =
#SOUNDFX_MIX})
The code above will mix samples 1 and 2 and store the result in sample 3. The
volume of sample 1 will be reduced by 50% before mixing.