AXFX2_PITCHSHIFT

Syntax

#include <cafe.h>
#include <cafe/axfx.h>

typedef struct
{
    // User params
    f32 pitch_shift;   // -24.0 to +24.0. The amount of pitch shift in semitones
    f32 out_gain;      // 0.0 to 2.0. The gain of the effect output.
    f32 dry_gain;      // 0.0 to 2.0. The gain of the dry signal.
} AXFX2_PITCHSHIFT;

s32  AXFX2PitchshiftGetMemSize            (AXFX_PITCHSHIFT_MODE mode, AXFX_SAMPLE_RATE sampleRate);
BOOL AXFX2PitchshiftInit                  (AXFX2_PITCHSHIFT *pitchshift, AXFX_PITCHSHIFT_MODE mode, AXFX_SAMPLE_RATE sampleRate);
BOOL AXFX2PitchshiftSettingsUpdate        (AXFX2_PITCHSHIFT *pitchshift);
BOOL AXFX2PitchshiftSettingsUpdateNoReset (AXFX2_PITCHSHIFT *pitchshift);
void AXFX2PitchshiftShutdown              (AXFX2_PITCHSHIFT *pitchshift);
void AXFX2PitchshiftCallback              (AXFX_6CH_BUFFERUPDATE *bufferUpdate, AXFX2_PITCHSHIFT *pitchshift, AXAUXCBSTRUCT *info);

Elements

pitch_shift Specify a float value in semitones as -24.0 <= value <= +24.0. The amount of pitch shift in semitones.
out_gain Specify a value as 0.0 <= value <= 2.0. Out gain controls the output level of the processed sound. Since for some settings the effect can be subtle, the parameter can take float values from 0.0 to 2.0.
dry_gain Specify a value as 0.0 <= value <= 2.0. Dry gain adjusts level of the input to the effect which is mixed with the output of the processed sound.

Description

There are three pitchshift effects that operate on 2, 4, and 6 channels. Appropriate values must be assigned to the parameters of the AXFX2_PITCHSHIFT structure function before the call to AXFX2PitchshiftInit.

The Pitch Shifter performs a time-based pitch shift (as opposed to a frequency domain pitch shift.) To raise the pitch of a prerecorded sound on a tape, you play the tape at a faster speed than it was recorded at. And to lower the pitch you would play the tape at a slower speed.

However, the pitch shifter effect, like all the effects described, works in real-time, processing a stream of incoming audio. It works by passing the incoming audio through a delay line, which functions like the tape described above, and then reading the output of this delay line at a different speed than the input. This is implemented by changing the location of the read pointer of the delay line at a constant rate. So, if we shorten the delay line by one sample every sample period, we are reading out two samples for every sample input, doubling the play-back speed (or raising the pitch by one octave.) If we increase the delay line lengths by one sample every sample period we lower the pitch by an octave.

You cannot continue to shorten or lengthen the location of the read pointer in a delay line, before reaching either end of the delay line. The solution is to have multiple read pointers, spread across the delay line, each of them changing location at the same rate. The outputs of each of these read pointers are attenuated by a window according to their location. When the pointer is in the middle of the delay line its output is at a maximum. As the read pointer approaches either end of the delay line its output is gradually scaled to zero.

The pitch shifter uses three of these read pointers. The locations for each of these are controlled by a low-frequency oscillator (LFO) with a saw-tooth shape. The speed of the LFO determines the amount of pitch shift. The direction of the saw-tooth slope determines whether the pitch is shifted down (a rising saw-tooth) or up (a falling saw-tooth.) The outputs of the three read pointers are summed and used as the output of the effect. The pitch shifter uses one delay line, three read pointers, and three attenuators for each channel of the effect.

Availability

Library Version Availability
Sound 2.0 Yes
Sound 1.0 No

Performance

The following table lists the CPU utilization given the specified mode and channel settings. The Sound 2 Library Interactive Effects demo displays real-time CPU usage metrics from which this data is derived.

mode32k48k
2ch3.11%4.73%
4ch4.37%6.59%
6ch5.69%8.51%

See Also

AXFX2 Pitchshift Overview
AXFX2PitchshiftGetMemSize
AXFX2PitchshiftInit
AXFX2PitchshiftShutdown
AXFX2PitchshiftSettingsUpdate
AXFX2PitchshiftSettingsUpdateNoReset
AXFX2PitchshiftCallback
alleffects demo

Revision History

2014/03/11 CPU metrics
2013/08/26 Initial version.


CONFIDENTIAL