Sweep [Home] [Tutorials] Hosted at SourceForge

Developing Sweep Plugins

PreviousContentsNext

Applying filters

Two convenience routines exist for creating plugins which only modify audio data. Note that where possible it is preferable to use the LADSPA API instead for developing such plugins. See Appendix B for more information about building LADSPA plugins for use with Sweep.

Filter plugins must only modify the audio data corresponding to selected regions of a sample. The functions provided to perform filter operations remember only information in the selected regions for the purposes of undoing and redoing. Thus any modifications done outside the selected regions will be lost after an undo.

As the selection information consists of a linked list of selected regions (see section 2.3) it is necessary for a filter plugin to somehow iterate over the selection and operate only on these regions. The SweepFilterRegion mechanism handles this iteration for you, whereas the SweepFilter mechanism allows for more general filters for which you must provide the iteration over the selection regions.

To make use of the SweepFilterRegion mechanism define a function of type SweepFilterRegion, which has the following prototype:

typedef void (*SweepFilterRegion) (gpointer data, sw_format * format, sw_framecount_t nr_frames, sw_param_set pset, gpointer custom_data);

A SweepFilterRegion function takes a pointer 'data' to a block of audio data, an (sw_format *) describing the format of the data, and a count of the number of frames to process from that point onwards. It also accepts a parameter set and some custom data.

To perform a FilterRegion operation, use the following function:

sw_op_instance * perform_filter_region_op (sw_sample * sample, char * desc, SweepFilterRegion func, sw_param_set pset, gpointer custom_data); see eg. plugins/reverse/reverse.c for an example of a FilterRegion The LADSPA meta-plugin is implemented as a FilterRegion.

If the processing involved cannot be done independently for each selection region, it is necessary to use a SweepFilter function. Note that the plugin must then perform the iteration over the selection regions itself. These functions have the following prototype:

typedef sw_sounddata * (*SweepFilter) (sw_sounddata * sounddata, sw_param_set pset, gpointer custom_data); To perform a Filter operation, use the following function:

sw_op_instance * perform_filter_op (sw_sample * sample, char * desc, SweepFilter func, sw_param_set pset, gpointer custom_data);

For example, the Normalise plugin (plugins/normalise/normalise.c) is implemened as a Filter. This is necessary because it must first find the greatest data value in any of the selected regions, and then in a second pass amplify each region by an amount calculated.

PreviousContentsNext

Copyright © 2000 Conrad Parker.