Browse Source

Accept floats instead of int16_ts for waveshape in shape()

dds
Damien Clarke 7 years ago
parent
commit
4e8caa70dd
2 changed files with 17 additions and 3 deletions
  1. +15
    -2
      effect_waveshaper.cpp
  2. +2
    -1
      effect_waveshaper.h

+ 15
- 2
effect_waveshaper.cpp View File

@@ -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 View File

@@ -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;

Loading…
Cancel
Save