Om  1.0.0
A universal framework for multimedia simulation
Classes | Public Member Functions | Static Public Attributes | List of all members
om::sound::filters::PitchShifter Class Reference

A class that shifts the pitch of input audio up or down by a number of semitones. More...

#include <omSoundPitchShifter.h>

Inheritance diagram for om::sound::filters::PitchShifter:
om::sound::filters::SoundFilter

Public Member Functions

 PitchShifter ()
 Create a new pitch shifter with no pitch shift. More...
 
 PitchShifter (Float newSemitoneShift)
 Create a new pitch shifter which shifts the input audio by the specified number of semitones. More...
 
Float getShift () const
 Return the current pitch shift amount expressed as a frequency multiplier. More...
 
void setShift (Float newShift)
 Set the pitch shift amount, expressed as a frequency multiplier. More...
 
Float getSemitoneShift () const
 Return the current pitch shift amount in signed semitones. More...
 
void setSemitoneShift (Float newSemitones)
 Set the current pitch shift amount in signed semitones. More...
 
Float getBufferLength () const
 Return the length in seconds of the FFT buffer used when doing pitch shifting. More...
 
void setBufferLength (Float newBufferLength)
 Set the length in seconds of the FFT buffer used when doing pitch shifting. More...
 
Size getOversampling () const
 Return the oversampling factor currently used by this pitch shifter. More...
 
void setOversampling (Size newOversampling)
 Set the oversampling factor currently used by this pitch shifter. More...
 
Gain getMix () const
 Return the ratio of input signal to pitch shifted signal sent to the output of the pitch shifter. More...
 
void setMix (Gain newMix)
 Set the ratio of input signal to pitch shifted signal sent to the output of the pitch shifter. More...
 
virtual UTF8String getName () const
 Return a human-readable name for this pitch shifter. More...
 
virtual UTF8String getManufacturer () const
 Return the manufacturer name of this pitch shifter. More...
 
virtual FilterVersion getVersion () const
 Return an object representing the version of this pitch shifter. More...
 
virtual FilterCategory getCategory () const
 Return an object that describes the category of effect that this filter implements. More...
 
virtual Time getLatency () const
 Return a Time value indicating the latency of this pitch shifter in seconds. More...
 
virtual Size getParameterCount () const
 Return the total number of generic accessible parameters this filter has. More...
 
virtual Bool getParameterInfo (Index parameterIndex, FilterParameterInfo &info) const
 Get information about the filter parameter at the specified index. More...
 
- Public Member Functions inherited from om::sound::filters::SoundFilter
virtual ~SoundFilter ()
 Destroy this sound filter object. More...
 
SoundResult read (SoundBuffer &outputBuffer, Size numSamples)
 Fill the specified output buffer with the requested number of samples, based on internal filter state. More...
 
SoundResult read (SoundFrame &outputFrame, Size numSamples)
 Fill the specified output frame with the requested number of samples, based on internal filter state. More...
 
SoundResult write (const SoundBuffer &inputBuffer, Size numSamples)
 Process the specified input buffer samples and do something with them. More...
 
SoundResult write (const SoundFrame &inputFrame, Size numSamples)
 Process the specified input frame samples and do something with them. More...
 
SoundResult process (const SoundBuffer &inputBuffer, SoundBuffer &outputBuffer, Size numSamples)
 Apply this filter to the specified input buffer data, placing the result in the output buffer. More...
 
SoundResult process (const SoundBuffer &inputBuffer, SoundFrame &outputFrame, Size numSamples)
 Apply this filter to the specified input buffer data, placing the result in the output frame. More...
 
SoundResult process (const SoundFrame &inputFrame, SoundFrame &outputFrame, Size numSamples)
 Apply this filter to the specified input frame data, placing the result in the output frame. More...
 
SoundResult process (const SoundFrame &inputBuffer, SoundBuffer &outputBuffer, Size numSamples)
 Apply this filter to the specified input frame data, placing the result in the output buffer. More...
 
void reset ()
 Signal to the filter that the audio stream is restarting. More...
 
UInt64 getFrameIndex () const
 Return the index of the next frame to be processed (or the current one if currently processing). More...
 
Size getInputCount () const
 Return the current number of audio inputs that this filter has. More...
 
virtual UTF8String getInputName (Index inputIndex) const
 Return a human-readable name of the filter audio input at the specified index. More...
 
Size getOutputCount () const
 Return the current number of audio outputs that this filter has. More...
 
virtual UTF8String getOutputName (Index outputIndex) const
 Return a human-readable name of the filter audio output at the specified index. More...
 
Size getMIDIInputCount () const
 Return the current number of MIDI inputs that this filter has. More...
 
virtual UTF8String getMIDIInputName (Index inputIndex) const
 Return a human-readable name of the filter MIDI input at the specified index. More...
 
Size getMIDIOutputCount () const
 Return the current number of MIDI outputs that this filter has. More...
 
virtual UTF8String getMIDIOutputName (Index outputIndex) const
 Return a human-readable name of the filter MIDI output at the specified index. More...
 
virtual Bool getParameterIndex (const UTF8String &parameterName, Index &parameterIndex) const
 Query the index of the parameter with the specified name. More...
 
virtual Bool getParameterValueName (Index parameterIndex, const FilterParameter &value, UTF8String &name) const
 Get any special name associated with the specified value of an indexed parameter. More...
 
Bool getParameter (Index parameterIndex, FilterParameter &value) const
 Place the value of the parameter at the specified index in the output parameter. More...
 
Bool getParameter (Index parameterIndex, Bool &value) const
 Place the value of the parameter at the specified index in the output parameter. More...
 
Bool getParameter (Index parameterIndex, Int64 &value) const
 Place the value of the parameter at the specified index in the output parameter. More...
 
Bool getParameter (Index parameterIndex, Float32 &value) const
 Place the value of the parameter at the specified index in the output parameter. More...
 
Bool getParameter (Index parameterIndex, Float64 &value) const
 Place the value of the parameter at the specified index in the output parameter. More...
 
template<typename ParameterType >
Bool getParameter (const UTF8String &name, ParameterType &value) const
 Place the value of the parameter with the specified name in the output parameter. More...
 
template<typename ParameterType >
Bool getParameter (const char *name, ParameterType &value) const
 Place the value of the parameter with the specified name in the output parameter. More...
 
Bool setParameter (Index parameterIndex, const FilterParameter &value)
 Attempt to set the parameter value at the specified index. More...
 
Bool setParameter (Index parameterIndex, Bool value)
 Attempt to set the parameter value at the specified index. More...
 
Bool setParameter (Index parameterIndex, Int64 value)
 Attempt to set the parameter value at the specified index. More...
 
Bool setParameter (Index parameterIndex, Float32 value)
 Attempt to set the parameter value at the specified index. More...
 
Bool setParameter (Index parameterIndex, Float64 value)
 Attempt to set the parameter value at the specified index. More...
 
template<typename ParameterType >
Bool setParameter (const UTF8String &name, ParameterType value)
 Attempt to set the parameter value with the specified name. More...
 
template<typename ParameterType >
Bool setParameter (const char *name, ParameterType value)
 Attempt to set the parameter value with the specified name. More...
 
virtual Bool writeState (DataOutputStream &stream) const
 Write the current state of this sound filter to a data output stream. More...
 
virtual Bool readState (DataInputStream &stream)
 Read a previously saved filter state from the specified data input stream and replace the filter's state. More...
 
virtual Size getPresetCount () const
 Return the number of standard configuration presets that this sound filter has. More...
 
virtual Bool getPreset (Index presetIndex, FilterPreset &preset) const
 Get the standard preset for this sound filter with the specified index. More...
 
Bool getIsSynchronized () const
 Return whether or not this sound filter performs thread synchronization. More...
 
void setIsSynchronized (Bool newIsSynchronized)
 Set whether or not this sound filter performs thread synchronization. More...
 
virtual Bool allowsInPlaceProcessing () const
 Return whether or not this sound filter can process audio data in-place. More...
 

Static Public Attributes

static const UTF8String NAME
 A string indicating the human-readable name of this pitch shifter. More...
 
static const UTF8String MANUFACTURER
 A string indicating the manufacturer name of this pitch shifter. More...
 
static const FilterVersion VERSION
 An object indicating the version of this pitch shifter. More...
 
- Static Public Attributes inherited from om::sound::filters::SoundFilter
static const om::resources::ResourceType RESOURCE_TYPE
 The resource type for a sound filter. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from om::sound::filters::SoundFilter
static Size getMaximumNumberOfInputs ()
 Return the maximum number of audio inputs that a SoundFilter can support. More...
 
static Size getMaximumNumberOfOutputs ()
 Return the maximum number of audio outputs that a SoundFilter can support. More...
 
static Size getMaximumNumberOfMIDIInputs ()
 Return the maximum number of MIDI inputs that a SoundFilter can support. More...
 
static Size getMaximumNumberOfMIDIOutputs ()
 Return the maximum number of MIDI outputs that a SoundFilter can support. More...
 
- Protected Member Functions inherited from om::sound::filters::SoundFilter
 SoundFilter ()
 Create a new sound filter with 1 audio input and output, and no MIDI inputs or outputs. More...
 
 SoundFilter (Size numInputs, Size numOutputs)
 Create a new sound filter with the specified number of audio inputs and outputs. More...
 
 SoundFilter (Size numInputs, Size numOutputs, Size numMIDIInputs, Size numMIDIOutputs)
 Create a new sound filter with the specified number of audio inputs and outputs. More...
 
void setInputCount (Size newNumInputs)
 Set the number of inputs that this filter should have. More...
 
void setOutputCount (Size newNumOutputs)
 Set the number of outputs that this filter should have. More...
 
void setMIDIInputCount (Size newNumMIDIInputs)
 Set the number of MIDI inputs that this filter should have. More...
 
void setMIDIOutputCount (Size newNumMIDIOutputs)
 Set the number of MIDI outputs that this filter should have. More...
 
Bool isFirstFrame () const
 Return whether or not the filter's next frame to be processed is also its first frame. More...
 
void lockMutex () const
 Acquire a mutex which handles subclass rendering parameter synchronization. More...
 
void unlockMutex () const
 Release a mutex which handles subclass rendering parameter synchronization. More...
 

Detailed Description

A class that shifts the pitch of input audio up or down by a number of semitones.

This classes uses an oversampled DTFT to shift the pitch of input audio up or down.

The pitch shifter allows the user to set the FFT buffer size in seconds, controlling the approximate time-domain resolution of the effect. A larger buffer size produces better frequency resolution but less time resolution, resulting in transient smearing. A smaller buffer can produce frequency domain artifacts due to the limited frequency resolution, but will have better transient response. The buffer length also determines the approximate latency of the effect.

Additionally, the shifter allows the user to control the oversampling factor for the effect. A higher oversampling level produces better quality results but at an exponential increase in CPU time. Higher oversampling amounts also can increase the time-domain smearing of the effect.

Constructor & Destructor Documentation

om::sound::filters::PitchShifter::PitchShifter ( )

Create a new pitch shifter with no pitch shift.

om::sound::filters::PitchShifter::PitchShifter ( Float  newSemitoneShift)

Create a new pitch shifter which shifts the input audio by the specified number of semitones.

Member Function Documentation

Float om::sound::filters::PitchShifter::getShift ( ) const
inline

Return the current pitch shift amount expressed as a frequency multiplier.

void om::sound::filters::PitchShifter::setShift ( Float  newShift)
inline

Set the pitch shift amount, expressed as a frequency multiplier.

Float om::sound::filters::PitchShifter::getSemitoneShift ( ) const
inline

Return the current pitch shift amount in signed semitones.

void om::sound::filters::PitchShifter::setSemitoneShift ( Float  newSemitones)
inline

Set the current pitch shift amount in signed semitones.

Float om::sound::filters::PitchShifter::getBufferLength ( ) const
inline

Return the length in seconds of the FFT buffer used when doing pitch shifting.

A longer buffer will result in higher frequency-domain resolution but decreased time-domain resolution. During rendering, since FFT buffers must have a power-of-two size, the next largest power of two is used for the buffer size, calculated based on the current sample rate and buffer length in seconds.

void om::sound::filters::PitchShifter::setBufferLength ( Float  newBufferLength)
inline

Set the length in seconds of the FFT buffer used when doing pitch shifting.

A longer buffer will result in higher frequency-domain resolution but decreased time-domain resolution. During rendering, since FFT buffers must have a power-of-two size, the next largest power of two is used for the buffer size, calculated based on the current sample rate and buffer length in seconds.

The new buffer length is clamped to be greater than or equal to 0.

Size om::sound::filters::PitchShifter::getOversampling ( ) const
inline

Return the oversampling factor currently used by this pitch shifter.

This number indicates the number of FFT passes that the shifter makes over the input audio. The more passes, the better quality the resulting shifted audio will be. However, an oversampling factor N will require approximately 2^N times as much time to process the effect.

The default oversampling factor is 2.

void om::sound::filters::PitchShifter::setOversampling ( Size  newOversampling)
inline

Set the oversampling factor currently used by this pitch shifter.

This number indicates the number of FFT passes that the shifter makes over the input audio. The more passes, the better quality the resulting shifted audio will be. However, an oversampling factor N will require approximately 2^N times as much time to process the effect.

The default oversampling factor is 2.

Gain om::sound::filters::PitchShifter::getMix ( ) const
inline

Return the ratio of input signal to pitch shifted signal sent to the output of the pitch shifter.

Valid mix values are in the range [0,1]. A mix value of 1 indicates that only the output of the pitch shifter should be heard at the output, while a value of 0 indicates that only the input of the pitch shifter should be heard at the output. A value of 0.5 indicates that both should be mixed together equally at -6dB.

void om::sound::filters::PitchShifter::setMix ( Gain  newMix)
inline

Set the ratio of input signal to pitch shifted signal sent to the output of the pitch shifter.

Valid mix values are in the range [0,1]. A mix value of 1 indicates that only the output of the pitch shifter should be heard at the output, while a value of 0 indicates that only the input of the pitch shifter should be heard at the output. A value of 0.5 indicates that both should be mixed together equally at -6dB.

The new mix value is clamped to the valid range of [0,1].

virtual UTF8String om::sound::filters::PitchShifter::getName ( ) const
virtual

Return a human-readable name for this pitch shifter.

The method returns the string "Pitch Shifter".

Reimplemented from om::sound::filters::SoundFilter.

virtual UTF8String om::sound::filters::PitchShifter::getManufacturer ( ) const
virtual

Return the manufacturer name of this pitch shifter.

The method returns the string "Om Sound".

Reimplemented from om::sound::filters::SoundFilter.

virtual FilterVersion om::sound::filters::PitchShifter::getVersion ( ) const
virtual

Return an object representing the version of this pitch shifter.

Reimplemented from om::sound::filters::SoundFilter.

virtual FilterCategory om::sound::filters::PitchShifter::getCategory ( ) const
virtual

Return an object that describes the category of effect that this filter implements.

This method returns the value FilterCategory::PITCH.

Reimplemented from om::sound::filters::SoundFilter.

virtual Time om::sound::filters::PitchShifter::getLatency ( ) const
virtual

Return a Time value indicating the latency of this pitch shifter in seconds.

The latency of the pitch shifter is equal to the shifter's buffer length.

Reimplemented from om::sound::filters::SoundFilter.

virtual Size om::sound::filters::PitchShifter::getParameterCount ( ) const
virtual

Return the total number of generic accessible parameters this filter has.

Reimplemented from om::sound::filters::SoundFilter.

virtual Bool om::sound::filters::PitchShifter::getParameterInfo ( Index  parameterIndex,
FilterParameterInfo info 
) const
virtual

Get information about the filter parameter at the specified index.

Reimplemented from om::sound::filters::SoundFilter.

Member Data Documentation

const UTF8String om::sound::filters::PitchShifter::NAME
static

A string indicating the human-readable name of this pitch shifter.

const UTF8String om::sound::filters::PitchShifter::MANUFACTURER
static

A string indicating the manufacturer name of this pitch shifter.

const FilterVersion om::sound::filters::PitchShifter::VERSION
static

An object indicating the version of this pitch shifter.


The documentation for this class was generated from the following file: