diff options
Diffstat (limited to 'intern/audaspace/fftw')
-rw-r--r-- | intern/audaspace/fftw/AUD_BandPassFactory.cpp | 75 | ||||
-rw-r--r-- | intern/audaspace/fftw/AUD_BandPassFactory.h | 92 | ||||
-rw-r--r-- | intern/audaspace/fftw/AUD_BandPassReader.cpp | 127 | ||||
-rw-r--r-- | intern/audaspace/fftw/AUD_BandPassReader.h | 102 |
4 files changed, 0 insertions, 396 deletions
diff --git a/intern/audaspace/fftw/AUD_BandPassFactory.cpp b/intern/audaspace/fftw/AUD_BandPassFactory.cpp deleted file mode 100644 index 1e6538d80de..00000000000 --- a/intern/audaspace/fftw/AUD_BandPassFactory.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * Copyright 2009-2011 Jörg Hermann Müller - * - * This file is part of AudaSpace. - * - * Audaspace is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * AudaSpace 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Audaspace; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file audaspace/fftw/AUD_BandPassFactory.cpp - * \ingroup audfftw - */ - - -#include "AUD_BandPassFactory.h" -#include "AUD_BandPassReader.h" - -AUD_BandPassFactory::AUD_BandPassFactory(AUD_IFactory* factory, float low, - float high) : - AUD_EffectFactory(factory), - m_low(low), - m_high(high) {} - -AUD_BandPassFactory::AUD_BandPassFactory(float low, float high) : - AUD_EffectFactory(0), - m_low(low), - m_high(high) {} - -float AUD_BandPassFactory::getLow() -{ - return m_low; -} - -float AUD_BandPassFactory::getHigh() -{ - return m_high; -} - -void AUD_BandPassFactory::setLow(float low) -{ - m_low = low; -} - -void AUD_BandPassFactory::setHigh(float high) -{ - m_high = high; -} - -AUD_IReader* AUD_BandPassFactory::createReader() -{ - AUD_IReader* reader = getReader(); - - if(reader != 0) - { - reader = new AUD_BandPassReader(reader, m_low, m_high); - AUD_NEW("reader") - } - - return reader; -} diff --git a/intern/audaspace/fftw/AUD_BandPassFactory.h b/intern/audaspace/fftw/AUD_BandPassFactory.h deleted file mode 100644 index 90b090dce16..00000000000 --- a/intern/audaspace/fftw/AUD_BandPassFactory.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * Copyright 2009-2011 Jörg Hermann Müller - * - * This file is part of AudaSpace. - * - * Audaspace is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * AudaSpace 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Audaspace; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file audaspace/fftw/AUD_BandPassFactory.h - * \ingroup audfftw - */ - - -#ifndef __AUD_BANDPASSFACTORY_H__ -#define __AUD_BANDPASSFACTORY_H__ - -#include "AUD_EffectFactory.h" - -/** - * This factory creates a band pass filter for a sound wave. - */ -class AUD_BandPassFactory : public AUD_EffectFactory -{ -private: - /** - * The lowest frequency to be passed. - */ - float m_low; - - /** - * The highest frequency to be passed. - */ - float m_high; - -public: - /** - * Creates a new band pass factory. - * \param factory The input factory. - * \param low The lowest passed frequency. - * \param high The highest passed frequency. - */ - AUD_BandPassFactory(AUD_IFactory* factory, float low, float high); - - /** - * Creates a new band pass factory. - * \param low The lowest passed frequency. - * \param high The highest passed frequency. - */ - AUD_BandPassFactory(float low, float high); - - /** - * Returns the lowest passed frequency. - */ - float getLow(); - - /** - * Returns the highest passed frequency. - */ - float getHigh(); - - /** - * Sets the lowest passed frequency. - * \param low The lowest passed frequency. - */ - void setLow(float low); - - /** - * Sets the highest passed frequency. - * \param high The highest passed frequency. - */ - void setHigh(float high); - - virtual AUD_IReader* createReader(); -}; - -#endif //__AUD_BANDPASSFACTORY_H__ diff --git a/intern/audaspace/fftw/AUD_BandPassReader.cpp b/intern/audaspace/fftw/AUD_BandPassReader.cpp deleted file mode 100644 index 7e181fb499d..00000000000 --- a/intern/audaspace/fftw/AUD_BandPassReader.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * Copyright 2009-2011 Jörg Hermann Müller - * - * This file is part of AudaSpace. - * - * Audaspace is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * AudaSpace 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Audaspace; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file audaspace/fftw/AUD_BandPassReader.cpp - * \ingroup audfftw - */ - - -#include "AUD_BandPassReader.h" -#include "AUD_Buffer.h" - -#include <cstring> -#include <stdio.h> - -AUD_BandPassReader::AUD_BandPassReader(AUD_IReader* reader, float low, - float high) : - AUD_EffectReader(reader), m_low(low), m_high(high) -{ - m_buffer = new AUD_Buffer(); AUD_NEW("buffer") - m_in = new AUD_Buffer(); AUD_NEW("buffer") - m_out = new AUD_Buffer(); AUD_NEW("buffer") - m_length = 0; -} - -AUD_BandPassReader::~AUD_BandPassReader() -{ - if(m_length != 0) - { - fftw_destroy_plan(m_forward); - fftw_destroy_plan(m_backward); - } - - delete m_buffer; AUD_DELETE("buffer") - delete m_in; AUD_DELETE("buffer") - delete m_out; AUD_DELETE("buffer") -} - -AUD_ReaderType AUD_BandPassReader::getType() -{ - return m_reader->getType(); -} - -void AUD_BandPassReader::read(int & length, sample_t* & buffer) -{ - AUD_Specs specs = m_reader->getSpecs(); - - m_reader->read(length, buffer); - - if(length > 0) - { - m_buffer->assureSize(length * AUD_SAMPLE_SIZE(specs)); - - if(length != m_length) - { - if(m_length != 0) - { - fftw_destroy_plan(m_forward); - fftw_destroy_plan(m_backward); - } - - m_length = length; - - if(m_length * sizeof(double) > m_in->getSize()) - { - m_in->resize(m_length * sizeof(double)); - m_out->resize((m_length / 2 + 1) * sizeof(fftw_complex)); - } - - m_forward = fftw_plan_dft_r2c_1d(m_length, - (double*)m_in->getBuffer(), - (fftw_complex*)m_out->getBuffer(), - FFTW_ESTIMATE); - m_backward = fftw_plan_dft_c2r_1d(m_length, - (fftw_complex*)m_out->getBuffer(), - (double*)m_in->getBuffer(), - FFTW_ESTIMATE); - } - - double* target = (double*) m_in->getBuffer(); - sample_t* target2 = m_buffer->getBuffer(); - fftw_complex* complex = (fftw_complex*) m_out->getBuffer(); - float frequency; - - for(int channel = 0; channel < specs.channels; channel++) - { - for(int i = 0; i < m_length; i++) - target[i] = buffer[i * specs.channels + channel]; - - fftw_execute(m_forward); - - for(int i = 0; i < m_length / 2 + 1; i++) - { - frequency = i * specs.rate / (m_length / 2.0f + 1.0f); - if((frequency < m_low) || (frequency > m_high)) - complex[i][0] = complex[i][1] = 0.0; - } - - fftw_execute(m_backward); - - for(int i = 0; i < m_length; i++) - target2[i * specs.channels + channel] = target[i] / m_length; - } - } - - buffer = m_buffer->getBuffer(); -} diff --git a/intern/audaspace/fftw/AUD_BandPassReader.h b/intern/audaspace/fftw/AUD_BandPassReader.h deleted file mode 100644 index 55a950818e0..00000000000 --- a/intern/audaspace/fftw/AUD_BandPassReader.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * Copyright 2009-2011 Jörg Hermann Müller - * - * This file is part of AudaSpace. - * - * Audaspace is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * AudaSpace 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Audaspace; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file audaspace/fftw/AUD_BandPassReader.h - * \ingroup audfftw - */ - - -#ifndef __AUD_BANDPASSREADER_H__ -#define __AUD_BANDPASSREADER_H__ - -#include <fftw3.h> - -#include "AUD_EffectReader.h" -class AUD_Buffer; - -/** - * This class only passes a specific frequency band of another reader. - */ -class AUD_BandPassReader : public AUD_EffectReader -{ -private: - /** - * The playback buffer. - */ - AUD_Buffer *m_buffer; - - /** - * The input buffer for fourier transformations. - */ - AUD_Buffer *m_in; - - /** - * The output buffer for fourier transformations. - */ - AUD_Buffer *m_out; - - /** - * The lowest passed frequency. - */ - float m_low; - - /** - * The highest passed frequency. - */ - float m_high; - - /** - * The fftw plan for forward transformation. - */ - fftw_plan m_forward; - - /** - * The fftw plan for backward transformation. - */ - fftw_plan m_backward; - - /** - * The length of the plans. - */ - int m_length; - -public: - /** - * Creates a new band pass reader. - * \param reader The reader to read from. - * \param low The lowest passed frequency. - * \param high The highest passed frequency. - */ - AUD_BandPassReader(AUD_IReader* reader, float low, float high); - - /** - * Destroys the reader. - */ - virtual ~AUD_BandPassReader(); - - virtual AUD_ReaderType getType(); - virtual void read(int & length, sample_t* & buffer); -}; - -#endif //__AUD_BANDPASSREADER_H__ |