Explorar el Código

Accept floats instead of int16_ts for waveshape in shape()

dds
Damien Clarke hace 7 años
padre
commit
4e8caa70dd
Se han modificado 2 ficheros con 17 adiciones y 3 borrados
  1. +15
    -2
      effect_waveshaper.cpp
  2. +2
    -1
      effect_waveshaper.h

+ 15
- 2
effect_waveshaper.cpp Ver fichero

@@ -24,13 +24,26 @@

#include "effect_waveshaper.h"

void AudioEffectWaveshaper::shape(int16_t* waveshape, int length)
AudioEffectWaveshaper::~AudioEffectWaveshaper()
{
if(this->waveshape) {
delete [] this->waveshape;
}
}

void AudioEffectWaveshaper::shape(float* waveshape, int length)
{
// length must be bigger than 1 and equal to a power of two + 1
// anything else means we don't continue
if(!waveshape || length < 2 || length > 32769 || ((length - 1) & (length - 2))) return;

this->waveshape = waveshape;
if(this->waveshape) {
delete [] this->waveshape;
}
this->waveshape = new int16_t[length];
for(int i = 0; i < length; i++) {
this->waveshape[i] = 32767 * waveshape[i];
}

// set lerpshift to the number of bits to shift while interpolating
// to cover the entire waveshape over a uint16_t input range

+ 2
- 1
effect_waveshaper.h Ver fichero

@@ -32,8 +32,9 @@ class AudioEffectWaveshaper : public AudioStream
{
public:
AudioEffectWaveshaper(void): AudioStream(1, inputQueueArray) {}
~AudioEffectWaveshaper();
virtual void update(void);
void shape(int16_t* waveshape, int length);
void shape(float* waveshape, int length);
private:
audio_block_t *inputQueueArray[1];
int16_t* waveshape;

Cargando…
Cancelar
Guardar