Parcourir la source

Accept floats instead of int16_ts for waveshape in shape()

dds
Damien Clarke il y a 7 ans
Parent
révision
4e8caa70dd
2 fichiers modifiés avec 17 ajouts et 3 suppressions
  1. +15
    -2
      effect_waveshaper.cpp
  2. +2
    -1
      effect_waveshaper.h

+ 15
- 2
effect_waveshaper.cpp Voir le fichier

@@ -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 Voir le fichier

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

Chargement…
Annuler
Enregistrer