diff options
Diffstat (limited to 'intern/audaspace/FX/AUD_BaseIIRFilterReader.cpp')
-rw-r--r-- | intern/audaspace/FX/AUD_BaseIIRFilterReader.cpp | 80 |
1 files changed, 73 insertions, 7 deletions
diff --git a/intern/audaspace/FX/AUD_BaseIIRFilterReader.cpp b/intern/audaspace/FX/AUD_BaseIIRFilterReader.cpp index 79039ca605b..29ff6d90080 100644 --- a/intern/audaspace/FX/AUD_BaseIIRFilterReader.cpp +++ b/intern/audaspace/FX/AUD_BaseIIRFilterReader.cpp @@ -33,20 +33,20 @@ #include <cstring> -#define CC m_channels + m_channel +#define CC m_specs.channels + m_channel AUD_BaseIIRFilterReader::AUD_BaseIIRFilterReader(AUD_Reference<AUD_IReader> reader, int in, int out) : AUD_EffectReader(reader), - m_channels(reader->getSpecs().channels), + m_specs(reader->getSpecs()), m_xlen(in), m_ylen(out), m_xpos(0), m_ypos(0), m_channel(0) { - m_x = new sample_t[in * m_channels]; - m_y = new sample_t[out * m_channels]; + m_x = new sample_t[m_xlen * m_specs.channels]; + m_y = new sample_t[m_ylen * m_specs.channels]; - memset(m_x, 0, sizeof(sample_t) * in * m_channels); - memset(m_y, 0, sizeof(sample_t) * out * m_channels); + memset(m_x, 0, sizeof(sample_t) * m_xlen * m_specs.channels); + memset(m_y, 0, sizeof(sample_t) * m_ylen * m_specs.channels); } AUD_BaseIIRFilterReader::~AUD_BaseIIRFilterReader() @@ -55,11 +55,73 @@ AUD_BaseIIRFilterReader::~AUD_BaseIIRFilterReader() delete[] m_y; } +void AUD_BaseIIRFilterReader::setLengths(int in, int out) +{ + if(in != m_xlen) + { + sample_t* xn = new sample_t[in * m_specs.channels]; + memset(xn, 0, sizeof(sample_t) * in * m_specs.channels); + + for(m_channel = 0; m_channel < m_specs.channels; m_channel++) + { + for(int i = 1; i <= in && i <= m_xlen; i++) + { + xn[(in - i) * CC] = x(-i); + } + } + + delete[] m_x; + m_x = xn; + m_xpos = 0; + m_xlen = in; + } + + if(out != m_ylen) + { + sample_t* yn = new sample_t[out * m_specs.channels]; + memset(yn, 0, sizeof(sample_t) * out * m_specs.channels); + + for(m_channel = 0; m_channel < m_specs.channels; m_channel++) + { + for(int i = 1; i <= out && i <= m_ylen; i++) + { + yn[(out - i) * CC] = y(-i); + } + } + + delete[] m_y; + m_y = yn; + m_ypos = 0; + m_ylen = out; + } +} + void AUD_BaseIIRFilterReader::read(int& length, bool& eos, sample_t* buffer) { + AUD_Specs specs = m_reader->getSpecs(); + if(specs.channels != m_specs.channels) + { + m_specs.channels = specs.channels; + + delete[] m_x; + delete[] m_y; + + m_x = new sample_t[m_xlen * m_specs.channels]; + m_y = new sample_t[m_ylen * m_specs.channels]; + + memset(m_x, 0, sizeof(sample_t) * m_xlen * m_specs.channels); + memset(m_y, 0, sizeof(sample_t) * m_ylen * m_specs.channels); + } + + if(specs.rate != m_specs.rate) + { + m_specs = specs; + sampleRateChanged(m_specs.rate); + } + m_reader->read(length, eos, buffer); - for(m_channel = 0; m_channel < m_channels; m_channel++) + for(m_channel = 0; m_channel < m_specs.channels; m_channel++) { for(int i = 0; i < length; i++) { @@ -71,3 +133,7 @@ void AUD_BaseIIRFilterReader::read(int& length, bool& eos, sample_t* buffer) } } } + +void AUD_BaseIIRFilterReader::sampleRateChanged(AUD_SampleRate rate) +{ +} |