diff options
-rw-r--r-- | Alc/ALc.c | 5 | ||||
-rw-r--r-- | Alc/effects/pshifter.c | 494 | ||||
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rw-r--r-- | OpenAL32/Include/alAuxEffectSlot.h | 1 | ||||
-rw-r--r-- | OpenAL32/Include/alEffect.h | 9 | ||||
-rw-r--r-- | OpenAL32/alAuxEffectSlot.c | 1 | ||||
-rw-r--r-- | OpenAL32/alEffect.c | 6 | ||||
-rw-r--r-- | alsoftrc.sample | 2 | ||||
-rw-r--r-- | utils/alsoft-config/mainwindow.cpp | 4 | ||||
-rw-r--r-- | utils/alsoft-config/mainwindow.ui | 30 |
10 files changed, 543 insertions, 10 deletions
@@ -547,10 +547,10 @@ static const struct { DECL(AL_EFFECT_DISTORTION), DECL(AL_EFFECT_ECHO), DECL(AL_EFFECT_FLANGER), + DECL(AL_EFFECT_PITCH_SHIFTER), #if 0 DECL(AL_EFFECT_FREQUENCY_SHIFTER), DECL(AL_EFFECT_VOCAL_MORPHER), - DECL(AL_EFFECT_PITCH_SHIFTER), #endif DECL(AL_EFFECT_RING_MODULATOR), #if 0 @@ -634,6 +634,9 @@ static const struct { DECL(AL_RING_MODULATOR_HIGHPASS_CUTOFF), DECL(AL_RING_MODULATOR_WAVEFORM), + DECL(AL_PITCH_SHIFTER_COARSE_TUNE), + DECL(AL_PITCH_SHIFTER_FINE_TUNE), + DECL(AL_COMPRESSOR_ONOFF), DECL(AL_EQUALIZER_LOW_GAIN), diff --git a/Alc/effects/pshifter.c b/Alc/effects/pshifter.c new file mode 100644 index 00000000..2bf911f8 --- /dev/null +++ b/Alc/effects/pshifter.c @@ -0,0 +1,494 @@ +/**
+ * OpenAL cross platform audio library
+ * Copyright (C) 2018 by Raul Herraiz.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * Or go to http://www.gnu.org/copyleft/lgpl.html
+ */
+
+#include "config.h"
+
+#include <math.h>
+#include <stdlib.h>
+
+#include "alMain.h"
+#include "alFilter.h"
+#include "alAuxEffectSlot.h"
+#include "alError.h"
+#include "alu.h"
+
+#define MAX_SIZE 2048
+
+typedef struct ALcomplex{
+
+ ALfloat Real;
+ ALfloat Imag;
+
+}ALcomplex;
+
+typedef struct ALphasor{
+
+ ALfloat Amplitude;
+ ALfloat Phase;
+
+}ALphasor;
+
+typedef struct ALFrequencyDomain{
+
+ ALfloat Amplitude;
+ ALfloat Frequency;
+
+}ALfrequencyDomain;
+
+typedef struct ALpshifterState {
+ DERIVE_FROM_TYPE(ALeffectState);
+
+ /* Effect gains for each channel */
+ ALfloat Gain[MAX_OUTPUT_CHANNELS];
+
+ /* Effect parameters */
+ ALsizei count;
+ ALsizei STFT_size;
+ ALsizei step;
+ ALsizei FIFOLatency;
+ ALsizei oversamp;
+ ALfloat PitchShift;
+ ALfloat Frequency;
+
+ /*Effects buffers*/
+ ALfloat InFIFO[MAX_SIZE];
+ ALfloat OutFIFO[MAX_SIZE];
+ ALfloat LastPhase[(MAX_SIZE>>1) +1];
+ ALfloat SumPhase[(MAX_SIZE>>1) +1];
+ ALfloat OutputAccum[MAX_SIZE<<1];
+ ALfloat window[MAX_SIZE];
+
+ ALcomplex FFTbuffer[MAX_SIZE];
+
+ ALfrequencyDomain Analysis_buffer[MAX_SIZE];
+ ALfrequencyDomain Syntesis_buffer[MAX_SIZE];
+
+
+} ALpshifterState;
+
+static inline ALphasor rect2polar( ALcomplex number );
+static inline ALcomplex polar2rect( ALphasor number );
+static inline ALvoid FFT(ALcomplex *FFTBuffer, ALsizei FFTSize, ALint Sign);
+
+static ALvoid ALpshifterState_Destruct(ALpshifterState *state);
+static ALboolean ALpshifterState_deviceUpdate(ALpshifterState *state, ALCdevice *device);
+static ALvoid ALpshifterState_update(ALpshifterState *state, const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props);
+static ALvoid ALpshifterState_process(ALpshifterState *state, ALsizei SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALsizei NumChannels);
+DECLARE_DEFAULT_ALLOCATORS(ALpshifterState)
+
+DEFINE_ALEFFECTSTATE_VTABLE(ALpshifterState);
+
+static void ALpshifterState_Construct(ALpshifterState *state)
+{
+ ALsizei i;
+
+ ALeffectState_Construct(STATIC_CAST(ALeffectState, state));
+ SET_VTABLE2(ALpshifterState, ALeffectState, state);
+
+ /*Initializing parameters and set to zero the buffers */
+ state->STFT_size = MAX_SIZE>>1;
+ state->oversamp = 1<<2;
+
+ state->step = state->STFT_size / state->oversamp ;
+ state->FIFOLatency = state->step * ( state->oversamp-1 );
+ state->count = state->FIFOLatency;
+
+ memset(state->InFIFO, 0, MAX_SIZE*sizeof(ALfloat));
+ memset(state->OutFIFO, 0, MAX_SIZE*sizeof(ALfloat));
+ memset(state->FFTbuffer, 0, MAX_SIZE*sizeof(ALcomplex));
+ memset(state->LastPhase, 0, ((MAX_SIZE>>1) +1)*sizeof(ALfloat));
+ memset(state->SumPhase, 0, ((MAX_SIZE>>1) +1)*sizeof(ALfloat));
+ memset(state->OutputAccum, 0, (MAX_SIZE<<1)*sizeof(ALfloat));
+ memset(state->Analysis_buffer, 0, MAX_SIZE*sizeof(ALfrequencyDomain));
+
+ /* Create lockup table of the Hann window for the desired size, i.e. STFT_size */
+ for ( i = 0; i < state->STFT_size>>1 ; i++ )
+ {
+ state->window[i] = state->window[state->STFT_size-(i+1)] \
+ = 0.5f * ( 1 - cosf(F_TAU*(ALfloat)i/(ALfloat)(state->STFT_size-1)));
+ }
+}
+
+static ALvoid ALpshifterState_Destruct(ALpshifterState *state)
+{
+ ALeffectState_Destruct(STATIC_CAST(ALeffectState,state));
+}
+
+static ALboolean ALpshifterState_deviceUpdate(ALpshifterState *UNUSED(state), ALCdevice *UNUSED(device))
+{
+ return AL_TRUE;
+}
+
+static ALvoid ALpshifterState_update(ALpshifterState *state, const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props)
+{
+ const ALCdevice *device = context->Device;
+ ALfloat coeffs[MAX_AMBI_COEFFS];
+ const ALfloat adjust = 0.707945784384f; /*-3dB adjust*/
+
+ state->Frequency = (ALfloat)device->Frequency;
+ state->PitchShift = powf(2.0f,((ALfloat)props->Pshifter.CoarseTune + props->Pshifter.FineTune/100.0f)/12.0f);
+
+ CalcAngleCoeffs(0.0f, 0.0f, 0.0f, coeffs);
+ ComputeDryPanGains(&device->Dry, coeffs, slot->Params.Gain * adjust, state->Gain);
+}
+
+static ALvoid ALpshifterState_process(ALpshifterState *state, ALsizei SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALsizei NumChannels)
+{
+ /*Pitch shifter engine based on the work of Stephan Bernsee.
+ * http://blogs.zynaptiq.com/bernsee/pitch-shifting-using-the-ft/ **/
+
+ ALsizei i, j, k, STFT_half_size;
+ ALfloat freq_bin, expected, tmp;
+ ALfloat bufferOut[BUFFERSIZE];
+ ALphasor component;
+
+
+ STFT_half_size = state->STFT_size >> 1;
+ freq_bin = state->Frequency / (ALfloat)state->STFT_size;
+ expected = F_TAU / (ALfloat)state->oversamp;
+
+
+ for (i = 0; i < SamplesToDo; i++)
+ {
+ /* Fill FIFO buffer with samples data */
+ state->InFIFO[state->count] = SamplesIn[0][i];
+ bufferOut[i] = state->OutFIFO[state->count - state->FIFOLatency];
+
+ state->count++;
+
+ /* Check whether FIFO buffer is filled */
+ if ( state->count >= state->STFT_size )
+ {
+ state->count = state->FIFOLatency;
+
+ /* Real signal windowing and store in FFTbuffer */
+ for ( k = 0; k < state->STFT_size; k++ )
+ {
+ state->FFTbuffer[k].Real = state->InFIFO[k] * state->window[k];
+ state->FFTbuffer[k].Imag = 0.0f;
+ }
+
+ /* ANALYSIS */
+ /* Apply FFT to FFTbuffer data */
+ FFT( state->FFTbuffer, state->STFT_size, -1 );
+
+ /* Analyze the obtained data. Since the real FFT is symmetric, only STFT_half_size+1 samples are needed */
+ for ( k = 0; k <= STFT_half_size; k++ )
+ {
+ /* Compute amplitude and phase */
+ component = rect2polar( state->FFTbuffer[k] );
+
+ /* Compute phase difference and subtract expected phase difference */
+ tmp = ( component.Phase - state->LastPhase[k] ) - (ALfloat)k*expected;
+
+ /* Map delta phase into +/- Pi interval */
+ tmp -= F_PI*(ALfloat)( fastf2i(tmp/F_PI) + fastf2i(tmp/F_PI) % 2 );
+
+ /* Get deviation from bin frequency from the +/- Pi interval */
+ tmp /= expected;
+
+ /* Compute the k-th partials' true frequency, twice the amplitude for maintain the gain
+ (because half of bins are used) and store amplitude and true frequency in analysis buffer */
+ state->Analysis_buffer[k].Amplitude = 2.0f * component.Amplitude;
+ state->Analysis_buffer[k].Frequency = ((ALfloat)k + tmp) * freq_bin;
+
+ /* Store actual phase[k] for the calculations in the next frame*/
+ state->LastPhase[k] = component.Phase;
+
+ }
+
+ /* PROCESSING */
+ /* pitch shifting */
+ memset(state->Syntesis_buffer, 0, state->STFT_size*sizeof(ALfrequencyDomain));
+
+ for (k = 0; k <= STFT_half_size; k++)
+ {
+ j = fastf2i( (ALfloat)k*state->PitchShift );
+
+ if ( j <= STFT_half_size )
+ {
+ state->Syntesis_buffer[j].Amplitude += state->Analysis_buffer[k].Amplitude;
+ state->Syntesis_buffer[j].Frequency = state->Analysis_buffer[k].Frequency * state->PitchShift;
+ }
+ }
+
+ /* SYNTHESIS */
+ /* Synthesis the processing data */
+ for ( k = 0; k <= STFT_half_size; k++ )
+ {
+ /* Compute bin deviation from scaled freq */
+ tmp = state->Syntesis_buffer[k].Frequency /freq_bin - (ALfloat)k;
+
+ /* Calculate actual delta phase and accumulate it to get bin phase */
+ state->SumPhase[k] += ((ALfloat)k + tmp) * expected;
+
+ component.Amplitude = state->Syntesis_buffer[k].Amplitude;
+ component.Phase = state->SumPhase[k];
+
+ /* Compute phasor component to cartesian complex number and storage it into FFTbuffer*/
+ state->FFTbuffer[k] = polar2rect( component );
+ }
+
+ /* zero negative frequencies for recontruct a real signal */
+ memset( &state->FFTbuffer[STFT_half_size+1], 0, (STFT_half_size-1) * sizeof(ALcomplex) );
+
+ /* Apply iFFT to buffer data */
+ FFT( state->FFTbuffer, state->STFT_size, 1 );
+
+ /* Windowing and add to output */
+ for( k=0; k < state->STFT_size; k++ )
+ {
+ state->OutputAccum[k] += 2.0f * state->window[k]*state->FFTbuffer[k].Real / (STFT_half_size * state->oversamp);
+ }
+
+ /* Shift accumulator, input & output FIFO */
+ memmove(state->OutFIFO , state->OutputAccum , state->step * sizeof(ALfloat));
+ memmove(state->OutputAccum, state->OutputAccum + state->step, state->STFT_size * sizeof(ALfloat));
+ memmove(state->InFIFO , state->InFIFO + state->step, state->FIFOLatency * sizeof(ALfloat));
+
+ }
+ }
+
+ /* Now, mix the processed sound data to the output*/
+
+ for (j = 0; j < NumChannels; j++ )
+ {
+ ALfloat gain = state->Gain[j];
+
+ if(!(fabsf(gain) > GAIN_SILENCE_THRESHOLD))
+ continue;
+
+ for(i = 0;i < SamplesToDo;i++)
+ SamplesOut[j][i] += gain * bufferOut[i];
+
+ }
+
+
+}
+
+typedef struct PshifterStateFactory {
+ DERIVE_FROM_TYPE(EffectStateFactory);
+} PshifterStateFactory;
+
+static ALeffectState *PshifterStateFactory_create(PshifterStateFactory *UNUSED(factory))
+{
+ ALpshifterState *state;
+
+ NEW_OBJ0(state, ALpshifterState)();
+ if(!state) return NULL;
+
+ return STATIC_CAST(ALeffectState, state);
+}
+
+DEFINE_EFFECTSTATEFACTORY_VTABLE(PshifterStateFactory);
+
+EffectStateFactory *PshifterStateFactory_getFactory(void)
+{
+ static PshifterStateFactory PshifterFactory = { { GET_VTABLE2(PshifterStateFactory, EffectStateFactory) } };
+
+ return STATIC_CAST(EffectStateFactory, &PshifterFactory);
+}
+
+
+void ALpshifter_setParamf(ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALfloat UNUSED(val))
+{
+ alSetError( context, AL_INVALID_ENUM, "Invalid pitch shifter float property 0x%04x", param );
+}
+
+void ALpshifter_setParamfv(ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, const ALfloat *UNUSED(vals))
+{
+ alSetError( context, AL_INVALID_ENUM, "Invalid pitch shifter float-vector property 0x%04x", param );
+}
+
+void ALpshifter_setParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val)
+{
+ ALeffectProps *props = &effect->Props;
+ switch(param)
+ {
+ case AL_PITCH_SHIFTER_COARSE_TUNE:
+ if(!(val >= AL_PITCH_SHIFTER_MIN_COARSE_TUNE && val <= AL_PITCH_SHIFTER_MAX_COARSE_TUNE))
+ SETERR_RETURN(context, AL_INVALID_VALUE,,"Pitch shifter coarse tune out of range");
+ props->Pshifter.CoarseTune = val;
+ break;
+
+ case AL_PITCH_SHIFTER_FINE_TUNE:
+ if(!(val >= AL_PITCH_SHIFTER_MIN_FINE_TUNE && val <= AL_PITCH_SHIFTER_MAX_FINE_TUNE))
+ SETERR_RETURN(context, AL_INVALID_VALUE,,"Pitch shifter fine tune out of range");
+ props->Pshifter.FineTune = val;
+ break;
+
+ default:
+ alSetError(context, AL_INVALID_ENUM, "Invalid pitch shifter integer property 0x%04x", param);
+ }
+}
+void ALpshifter_setParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals)
+{
+ ALpshifter_setParami(effect, context, param, vals[0]);
+}
+
+void ALpshifter_getParami(const ALeffect *effect, ALCcontext *context, ALenum param, ALint *val)
+{
+ const ALeffectProps *props = &effect->Props;
+ switch(param)
+ {
+ case AL_PITCH_SHIFTER_COARSE_TUNE:
+ *val = (ALint)props->Pshifter.CoarseTune;
+ break;
+ case AL_PITCH_SHIFTER_FINE_TUNE:
+ *val = (ALint)props->Pshifter.FineTune;
+ break;
+
+ default:
+ alSetError(context, AL_INVALID_ENUM, "Invalid pitch shifter integer property 0x%04x", param);
+ }
+}
+void ALpshifter_getParamiv(const ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals)
+{
+ ALpshifter_getParami(effect, context, param, vals);
+}
+
+void ALpshifter_getParamf(const ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALfloat *UNUSED(val))
+{
+ alSetError(context, AL_INVALID_ENUM, "Invalid pitch shifter float property 0x%04x", param);
+}
+
+void ALpshifter_getParamfv(const ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALfloat *UNUSED(vals))
+{
+ alSetError(context, AL_INVALID_ENUM, "Invalid pitch shifter float vector-property 0x%04x", param);
+}
+
+DEFINE_ALEFFECT_VTABLE(ALpshifter);
+
+
+/* Converts ALcomplex to ALphasor*/
+static inline ALphasor rect2polar( ALcomplex number )
+{
+ ALphasor polar;
+
+ polar.Amplitude = sqrtf ( number.Real*number.Real + number.Imag*number.Imag );
+ polar.Phase = atan2f( number.Imag , number.Real );
+
+ return polar;
+}
+
+/* Converts ALphasor to ALcomplex*/
+static inline ALcomplex polar2rect( ALphasor number )
+{
+ ALcomplex cartesian;
+
+ cartesian.Real = number.Amplitude * cosf( number.Phase );
+ cartesian.Imag = number.Amplitude * sinf( number.Phase );
+
+ return cartesian;
+}
+
+/* Addition of two complex numbers (ALcomplex format)*/
+static inline ALcomplex complex_add( ALcomplex a, ALcomplex b )
+{
+ ALcomplex result;
+
+ result.Real = ( a.Real + b.Real );
+ result.Imag = ( a.Imag + b.Imag );
+
+ return result;
+}
+
+/* Substraction of two complex numbers (ALcomplex format)*/
+static inline ALcomplex complex_subst( ALcomplex a, ALcomplex b )
+{
+ ALcomplex result;
+
+ result.Real = ( a.Real - b.Real );
+ result.Imag = ( a.Imag - b.Imag );
+
+ return result;
+}
+
+/* Multiplication of two complex numbers (ALcomplex format)*/
+static inline ALcomplex complex_mult( ALcomplex a, ALcomplex b )
+{
+ ALcomplex result;
+
+ result.Real = ( a.Real * b.Real - a.Imag * b.Imag );
+ result.Imag = ( a.Imag * b.Real + a.Real * b.Imag );
+
+ return result;
+}
+
+/* Iterative implementation of 2-radix FFT (In-place algorithm). Sign = -1 is FFT and 1 is
+ iFFT (inverse). Fills FFTBuffer[0...FFTSize-1] with the Discrete Fourier Transform (DFT)
+ of the time domain data stored in FFTBuffer[0...FFTSize-1]. FFTBuffer is an array of
+ complex numbers (ALcomplex), FFTSize MUST BE power of two.*/
+
+static inline ALvoid FFT(ALcomplex *FFTBuffer, ALsizei FFTSize, ALint Sign)
+{
+ ALfloat arg;
+ ALsizei i, j, k, mask, step, step2;
+ ALcomplex temp, u, w;
+
+ /*bit-reversal permutation applied to a sequence of FFTSize items*/
+ for (i = 1; i < FFTSize-1; i++ )
+ {
+
+ for ( mask = 0x1, j = 0; mask < FFTSize; mask <<= 1 )
+ {
+ if ( ( i & mask ) != 0 ) j++;
+
+ j <<= 1;
+ }
+
+ j >>= 1;
+
+ if ( i < j )
+ {
+ temp = FFTBuffer[i];
+ FFTBuffer[i] = FFTBuffer[j];
+ FFTBuffer[j] = temp;
+ }
+ }
+
+ /* Iterative form of Danielson�Lanczos lemma */
+ for ( i = 1, step = 2; i < FFTSize; i<<=1, step <<= 1 )
+ {
+
+ step2 = step >> 1;
+ arg = F_PI / step2;
+
+ w.Real = cosf( arg );
+ w.Imag = sinf( arg ) * Sign;
+
+ u.Real = 1.0f;
+ u.Imag = 0.0f;
+
+ for ( j = 0; j < step2; j++ )
+ {
+
+ for ( k = j; k < FFTSize; k += step )
+ {
+
+ temp = complex_mult( FFTBuffer[k+step2], u );
+ FFTBuffer[k+step2] = complex_subst( FFTBuffer[k], temp );
+ FFTBuffer[k] = complex_add( FFTBuffer[k], temp );
+ }
+
+ u = complex_mult(u,w);
+ }
+ }
+}
diff --git a/CMakeLists.txt b/CMakeLists.txt index 4a6d8ae0..986a6c32 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -726,6 +726,7 @@ SET(ALC_OBJS Alc/ALc.c Alc/effects/equalizer.c Alc/effects/modulator.c Alc/effects/null.c + Alc/effects/pshifter.c Alc/effects/reverb.c Alc/helpers.c Alc/hrtf.c diff --git a/OpenAL32/Include/alAuxEffectSlot.h b/OpenAL32/Include/alAuxEffectSlot.h index 61c72153..bb9aef59 100644 --- a/OpenAL32/Include/alAuxEffectSlot.h +++ b/OpenAL32/Include/alAuxEffectSlot.h @@ -167,6 +167,7 @@ EffectStateFactory *EchoStateFactory_getFactory(void); EffectStateFactory *EqualizerStateFactory_getFactory(void); EffectStateFactory *FlangerStateFactory_getFactory(void); EffectStateFactory *ModulatorStateFactory_getFactory(void); +EffectStateFactory *PshifterStateFactory_getFactory(void); EffectStateFactory *DedicatedStateFactory_getFactory(void); diff --git a/OpenAL32/Include/alEffect.h b/OpenAL32/Include/alEffect.h index 95fa035e..50b64ee1 100644 --- a/OpenAL32/Include/alEffect.h +++ b/OpenAL32/Include/alEffect.h @@ -19,6 +19,7 @@ enum { EQUALIZER_EFFECT, FLANGER_EFFECT, MODULATOR_EFFECT, + PSHIFTER_EFFECT, DEDICATED_EFFECT, MAX_EFFECTS @@ -32,7 +33,7 @@ struct EffectList { int type; ALenum val; }; -#define EFFECTLIST_SIZE 11 +#define EFFECTLIST_SIZE 12 extern const struct EffectList EffectList[EFFECTLIST_SIZE]; @@ -66,6 +67,7 @@ extern const struct ALeffectVtable ALequalizer_vtable; extern const struct ALeffectVtable ALflanger_vtable; extern const struct ALeffectVtable ALmodulator_vtable; extern const struct ALeffectVtable ALnull_vtable; +extern const struct ALeffectVtable ALpshifter_vtable; extern const struct ALeffectVtable ALdedicated_vtable; @@ -150,6 +152,11 @@ typedef union ALeffectProps { } Modulator; struct { + ALint CoarseTune; + ALint FineTune; + } Pshifter; + + struct { ALfloat Gain; } Dedicated; } ALeffectProps; diff --git a/OpenAL32/alAuxEffectSlot.c b/OpenAL32/alAuxEffectSlot.c index 301244a0..d04fc4a7 100644 --- a/OpenAL32/alAuxEffectSlot.c +++ b/OpenAL32/alAuxEffectSlot.c @@ -55,6 +55,7 @@ static const struct { { AL_EFFECT_EQUALIZER, EqualizerStateFactory_getFactory }, { AL_EFFECT_FLANGER, FlangerStateFactory_getFactory }, { AL_EFFECT_RING_MODULATOR, ModulatorStateFactory_getFactory }, + { AL_EFFECT_PITCH_SHIFTER, PshifterStateFactory_getFactory}, { AL_EFFECT_DEDICATED_DIALOGUE, DedicatedStateFactory_getFactory }, { AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT, DedicatedStateFactory_getFactory } }; diff --git a/OpenAL32/alEffect.c b/OpenAL32/alEffect.c index 6b16fc56..e7dc6ace 100644 --- a/OpenAL32/alEffect.c +++ b/OpenAL32/alEffect.c @@ -45,6 +45,7 @@ const struct EffectList EffectList[EFFECTLIST_SIZE] = { { "equalizer", EQUALIZER_EFFECT, AL_EFFECT_EQUALIZER }, { "flanger", FLANGER_EFFECT, AL_EFFECT_FLANGER }, { "modulator", MODULATOR_EFFECT, AL_EFFECT_RING_MODULATOR }, + { "pshifter", PSHIFTER_EFFECT, AL_EFFECT_PITCH_SHIFTER }, { "dedicated", DEDICATED_EFFECT, AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT }, { "dedicated", DEDICATED_EFFECT, AL_EFFECT_DEDICATED_DIALOGUE }, }; @@ -589,6 +590,11 @@ static void InitEffectParams(ALeffect *effect, ALenum type) effect->Props.Modulator.Waveform = AL_RING_MODULATOR_DEFAULT_WAVEFORM; effect->vtab = &ALmodulator_vtable; break; + case AL_EFFECT_PITCH_SHIFTER: + effect->Props.Pshifter.CoarseTune = AL_PITCH_SHIFTER_DEFAULT_COARSE_TUNE; + effect->Props.Pshifter.FineTune = AL_PITCH_SHIFTER_DEFAULT_FINE_TUNE; + effect->vtab = &ALpshifter_vtable; + break; case AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT: case AL_EFFECT_DEDICATED_DIALOGUE: effect->Props.Dedicated.Gain = 1.0f; diff --git a/alsoftrc.sample b/alsoftrc.sample index b457a2db..cac9fd93 100644 --- a/alsoftrc.sample +++ b/alsoftrc.sample @@ -220,7 +220,7 @@ # Sets which effects to exclude, preventing apps from using them. This can # help for apps that try to use effects which are too CPU intensive for the # system to handle. Available effects are: eaxreverb,reverb,chorus,compressor, -# distortion,echo,equalizer,flanger,modulator,dedicated +# distortion,echo,equalizer,flanger,modulator,dedicated,pshifter #excludefx = ## default-reverb: (global) diff --git a/utils/alsoft-config/mainwindow.cpp b/utils/alsoft-config/mainwindow.cpp index a3b0c559..94aa0750 100644 --- a/utils/alsoft-config/mainwindow.cpp +++ b/utils/alsoft-config/mainwindow.cpp @@ -380,6 +380,7 @@ MainWindow::MainWindow(QWidget *parent) : connect(ui->enableFlangerCheck, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton())); connect(ui->enableModulatorCheck, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton())); connect(ui->enableDedicatedCheck, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton())); + connect(ui->enablePitchShifterCheck, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton())); connect(ui->pulseAutospawnCheckBox, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton())); connect(ui->pulseAllowMovesCheckBox, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton())); @@ -845,6 +846,7 @@ void MainWindow::loadConfig(const QString &fname) ui->enableFlangerCheck->setChecked(!excludefx.contains("flanger", Qt::CaseInsensitive)); ui->enableModulatorCheck->setChecked(!excludefx.contains("modulator", Qt::CaseInsensitive)); ui->enableDedicatedCheck->setChecked(!excludefx.contains("dedicated", Qt::CaseInsensitive)); + ui->enablePitchShifterCheck->setChecked(!excludefx.contains("pshifter", Qt::CaseInsensitive)); ui->pulseAutospawnCheckBox->setChecked(settings.value("pulse/spawn-server", true).toBool()); ui->pulseAllowMovesCheckBox->setChecked(settings.value("pulse/allow-moves", false).toBool()); @@ -1058,6 +1060,8 @@ void MainWindow::saveConfig(const QString &fname) const strlist.append("modulator"); if(!ui->enableDedicatedCheck->isChecked()) strlist.append("dedicated"); + if(!ui->enablePitchShifterCheck->isChecked()) + strlist.append("pshifter"); settings.setValue("excludefx", strlist.join(QChar(','))); settings.setValue("pulse/spawn-server", diff --git a/utils/alsoft-config/mainwindow.ui b/utils/alsoft-config/mainwindow.ui index b91c1c4d..b4766d5a 100644 --- a/utils/alsoft-config/mainwindow.ui +++ b/utils/alsoft-config/mainwindow.ui @@ -53,7 +53,7 @@ </rect> </property> <property name="currentIndex"> - <number>0</number> + <number>5</number> </property> <widget class="QWidget" name="tab_3"> <attribute name="title"> @@ -131,8 +131,8 @@ to stereo output.</string> <rect> <x>380</x> <y>20</y> - <width>93</width> - <height>29</height> + <width>80</width> + <height>20</height> </rect> </property> <property name="toolTip"> @@ -1933,7 +1933,7 @@ be useful for preventing those extensions from being used.</string> <x>10</x> <y>100</y> <width>511</width> - <height>191</height> + <height>231</height> </rect> </property> <property name="toolTip"> @@ -2108,6 +2108,22 @@ added by the ALC_EXT_DEDICATED extension.</string> <bool>true</bool> </property> </widget> + <widget class="QCheckBox" name="enablePitchShifterCheck"> + <property name="geometry"> + <rect> + <x>70</x> + <y>180</y> + <width>131</width> + <height>21</height> + </rect> + </property> + <property name="text"> + <string>Pitch Shifter</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> </widget> <widget class="QLabel" name="label_13"> <property name="geometry"> @@ -2130,8 +2146,8 @@ added by the ALC_EXT_DEDICATED extension.</string> <rect> <x>160</x> <y>20</y> - <width>125</width> - <height>29</height> + <width>108</width> + <height>20</height> </rect> </property> <property name="sizeAdjustPolicy"> @@ -2300,7 +2316,7 @@ added by the ALC_EXT_DEDICATED extension.</string> <x>0</x> <y>0</y> <width>564</width> - <height>27</height> + <height>21</height> </rect> </property> <widget class="QMenu" name="menuFile"> |