[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30832] branches/soc-2010-nexyon/intern/ audaspace: Audaspace: HUGE Refactor.
Joerg Mueller
nexyon at gmail.com
Wed Jul 28 11:36:03 CEST 2010
Revision: 30832
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30832
Author: nexyon
Date: 2010-07-28 11:36:03 +0200 (Wed, 28 Jul 2010)
Log Message:
-----------
Audaspace: HUGE Refactor.
Some points of the refactor not sorted by importance:
* Fixed immutability of readers and factories (there are exceptions...)
* Fixed copy constructors and = operators
* Removed messaging system
* Removed reader types
* Added const where possible
* Using initalisers when possible
* Avoided use of pointers when possible
* Removed AUD_NEW and AUD_DELETE macros
* Removed useless NULL pointer checks
* Fixed exception catching
* Fixed some yet unknown bugs
* Lots of other stuff
Modified Paths:
--------------
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_AccumulatorFactory.cpp
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_AccumulatorFactory.h
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_AccumulatorReader.cpp
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_AccumulatorReader.h
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_ButterworthFactory.cpp
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_ButterworthFactory.h
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_ButterworthReader.cpp
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_ButterworthReader.h
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_DelayFactory.cpp
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_DelayFactory.h
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_DelayReader.cpp
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_DelayReader.h
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_DoubleFactory.cpp
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_DoubleFactory.h
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_DoubleReader.cpp
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_DoubleReader.h
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_EffectFactory.cpp
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_EffectFactory.h
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_EffectReader.cpp
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_EffectReader.h
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_EnvelopeFactory.cpp
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_EnvelopeFactory.h
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_EnvelopeReader.cpp
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_EnvelopeReader.h
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_FaderFactory.cpp
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_FaderFactory.h
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_FaderReader.cpp
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_FaderReader.h
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_HighpassFactory.cpp
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_HighpassFactory.h
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_HighpassReader.cpp
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_HighpassReader.h
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_LimiterFactory.cpp
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_LimiterFactory.h
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_LimiterReader.cpp
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_LimiterReader.h
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_LoopFactory.cpp
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_LoopFactory.h
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_LoopReader.cpp
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_LoopReader.h
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_LowpassFactory.cpp
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_LowpassFactory.h
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_LowpassReader.cpp
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_LowpassReader.h
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_PingPongFactory.cpp
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_PingPongFactory.h
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_PitchFactory.cpp
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_PitchFactory.h
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_PitchReader.cpp
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_PitchReader.h
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_RectifyFactory.cpp
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_RectifyFactory.h
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_RectifyReader.cpp
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_RectifyReader.h
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_ReverseFactory.cpp
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_ReverseFactory.h
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_ReverseReader.cpp
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_ReverseReader.h
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_SquareFactory.cpp
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_SquareFactory.h
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_SquareReader.cpp
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_SquareReader.h
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_SumFactory.cpp
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_SumFactory.h
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_SumReader.cpp
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_SumReader.h
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_SuperposeFactory.cpp
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_SuperposeFactory.h
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_SuperposeReader.cpp
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_SuperposeReader.h
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_VolumeFactory.cpp
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_VolumeFactory.h
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_VolumeReader.cpp
branches/soc-2010-nexyon/intern/audaspace/FX/AUD_VolumeReader.h
branches/soc-2010-nexyon/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp
branches/soc-2010-nexyon/intern/audaspace/OpenAL/AUD_OpenALDevice.h
branches/soc-2010-nexyon/intern/audaspace/Python/AUD_PyAPI.cpp
branches/soc-2010-nexyon/intern/audaspace/SDL/AUD_SDLDevice.h
branches/soc-2010-nexyon/intern/audaspace/SRC/AUD_SRCResampleFactory.cpp
branches/soc-2010-nexyon/intern/audaspace/SRC/AUD_SRCResampleFactory.h
branches/soc-2010-nexyon/intern/audaspace/SRC/AUD_SRCResampleReader.cpp
branches/soc-2010-nexyon/intern/audaspace/SRC/AUD_SRCResampleReader.h
branches/soc-2010-nexyon/intern/audaspace/ffmpeg/AUD_FFMPEGFactory.cpp
branches/soc-2010-nexyon/intern/audaspace/ffmpeg/AUD_FFMPEGFactory.h
branches/soc-2010-nexyon/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp
branches/soc-2010-nexyon/intern/audaspace/ffmpeg/AUD_FFMPEGReader.h
branches/soc-2010-nexyon/intern/audaspace/fftw/AUD_BandPassReader.h
branches/soc-2010-nexyon/intern/audaspace/intern/AUD_Buffer.cpp
branches/soc-2010-nexyon/intern/audaspace/intern/AUD_Buffer.h
branches/soc-2010-nexyon/intern/audaspace/intern/AUD_BufferReader.cpp
branches/soc-2010-nexyon/intern/audaspace/intern/AUD_BufferReader.h
branches/soc-2010-nexyon/intern/audaspace/intern/AUD_C-API.cpp
branches/soc-2010-nexyon/intern/audaspace/intern/AUD_ChannelMapperFactory.cpp
branches/soc-2010-nexyon/intern/audaspace/intern/AUD_ChannelMapperFactory.h
branches/soc-2010-nexyon/intern/audaspace/intern/AUD_ChannelMapperReader.cpp
branches/soc-2010-nexyon/intern/audaspace/intern/AUD_ChannelMapperReader.h
branches/soc-2010-nexyon/intern/audaspace/intern/AUD_ConverterFactory.cpp
branches/soc-2010-nexyon/intern/audaspace/intern/AUD_ConverterFactory.h
branches/soc-2010-nexyon/intern/audaspace/intern/AUD_ConverterReader.cpp
branches/soc-2010-nexyon/intern/audaspace/intern/AUD_ConverterReader.h
branches/soc-2010-nexyon/intern/audaspace/intern/AUD_FileFactory.cpp
branches/soc-2010-nexyon/intern/audaspace/intern/AUD_FileFactory.h
branches/soc-2010-nexyon/intern/audaspace/intern/AUD_IDevice.h
branches/soc-2010-nexyon/intern/audaspace/intern/AUD_IFactory.h
branches/soc-2010-nexyon/intern/audaspace/intern/AUD_IReader.h
branches/soc-2010-nexyon/intern/audaspace/intern/AUD_LinearResampleFactory.cpp
branches/soc-2010-nexyon/intern/audaspace/intern/AUD_LinearResampleFactory.h
branches/soc-2010-nexyon/intern/audaspace/intern/AUD_LinearResampleReader.cpp
branches/soc-2010-nexyon/intern/audaspace/intern/AUD_LinearResampleReader.h
branches/soc-2010-nexyon/intern/audaspace/intern/AUD_Mixer.cpp
branches/soc-2010-nexyon/intern/audaspace/intern/AUD_Mixer.h
branches/soc-2010-nexyon/intern/audaspace/intern/AUD_MixerFactory.cpp
branches/soc-2010-nexyon/intern/audaspace/intern/AUD_MixerFactory.h
branches/soc-2010-nexyon/intern/audaspace/intern/AUD_NULLDevice.cpp
branches/soc-2010-nexyon/intern/audaspace/intern/AUD_NULLDevice.h
branches/soc-2010-nexyon/intern/audaspace/intern/AUD_ReadDevice.cpp
branches/soc-2010-nexyon/intern/audaspace/intern/AUD_ReadDevice.h
branches/soc-2010-nexyon/intern/audaspace/intern/AUD_Reference.h
branches/soc-2010-nexyon/intern/audaspace/intern/AUD_SequencerFactory.cpp
branches/soc-2010-nexyon/intern/audaspace/intern/AUD_SequencerFactory.h
branches/soc-2010-nexyon/intern/audaspace/intern/AUD_SequencerReader.cpp
branches/soc-2010-nexyon/intern/audaspace/intern/AUD_SequencerReader.h
branches/soc-2010-nexyon/intern/audaspace/intern/AUD_SinusFactory.cpp
branches/soc-2010-nexyon/intern/audaspace/intern/AUD_SinusFactory.h
branches/soc-2010-nexyon/intern/audaspace/intern/AUD_SinusReader.cpp
branches/soc-2010-nexyon/intern/audaspace/intern/AUD_SinusReader.h
branches/soc-2010-nexyon/intern/audaspace/intern/AUD_SoftwareDevice.cpp
branches/soc-2010-nexyon/intern/audaspace/intern/AUD_SoftwareDevice.h
branches/soc-2010-nexyon/intern/audaspace/intern/AUD_Space.h
branches/soc-2010-nexyon/intern/audaspace/intern/AUD_StreamBufferFactory.cpp
branches/soc-2010-nexyon/intern/audaspace/intern/AUD_StreamBufferFactory.h
branches/soc-2010-nexyon/intern/audaspace/jack/AUD_JackDevice.cpp
branches/soc-2010-nexyon/intern/audaspace/jack/AUD_JackDevice.h
branches/soc-2010-nexyon/intern/audaspace/sndfile/AUD_SndFileFactory.cpp
branches/soc-2010-nexyon/intern/audaspace/sndfile/AUD_SndFileFactory.h
branches/soc-2010-nexyon/intern/audaspace/sndfile/AUD_SndFileReader.cpp
branches/soc-2010-nexyon/intern/audaspace/sndfile/AUD_SndFileReader.h
Added Paths:
-----------
branches/soc-2010-nexyon/intern/audaspace/intern/AUD_DefaultMixer.cpp
branches/soc-2010-nexyon/intern/audaspace/intern/AUD_DefaultMixer.h
Modified: branches/soc-2010-nexyon/intern/audaspace/FX/AUD_AccumulatorFactory.cpp
===================================================================
--- branches/soc-2010-nexyon/intern/audaspace/FX/AUD_AccumulatorFactory.cpp 2010-07-28 08:06:46 UTC (rev 30831)
+++ branches/soc-2010-nexyon/intern/audaspace/FX/AUD_AccumulatorFactory.cpp 2010-07-28 09:36:03 UTC (rev 30832)
@@ -29,21 +29,11 @@
AUD_AccumulatorFactory::AUD_AccumulatorFactory(AUD_IFactory* factory,
bool additive) :
AUD_EffectFactory(factory),
- m_additive(additive) {}
-
-AUD_AccumulatorFactory::AUD_AccumulatorFactory(bool additive) :
- AUD_EffectFactory(0),
- m_additive(additive) {}
-
-AUD_IReader* AUD_AccumulatorFactory::createReader()
+ m_additive(additive)
{
- AUD_IReader* reader = getReader();
+}
- if(reader != 0)
- {
- reader = new AUD_AccumulatorReader(reader, m_additive);
- AUD_NEW("reader")
- }
-
- return reader;
+AUD_IReader* AUD_AccumulatorFactory::createReader() const
+{
+ return new AUD_AccumulatorReader(getReader(), m_additive);
}
Modified: branches/soc-2010-nexyon/intern/audaspace/FX/AUD_AccumulatorFactory.h
===================================================================
--- branches/soc-2010-nexyon/intern/audaspace/FX/AUD_AccumulatorFactory.h 2010-07-28 08:06:46 UTC (rev 30831)
+++ branches/soc-2010-nexyon/intern/audaspace/FX/AUD_AccumulatorFactory.h 2010-07-28 09:36:03 UTC (rev 30832)
@@ -37,8 +37,12 @@
/**
* Whether the accumulator is additive.
*/
- bool m_additive;
+ const bool m_additive;
+ // hide copy constructor and operator=
+ AUD_AccumulatorFactory(const AUD_AccumulatorFactory&);
+ AUD_AccumulatorFactory& operator=(const AUD_AccumulatorFactory&);
+
public:
/**
* Creates a new accumulator factory.
@@ -47,13 +51,7 @@
*/
AUD_AccumulatorFactory(AUD_IFactory* factory, bool additive = false);
- /**
- * Creates a new accumulator factory.
- * \param additive Whether the accumulator is additive.
- */
- AUD_AccumulatorFactory(bool additive = false);
-
- virtual AUD_IReader* createReader();
+ virtual AUD_IReader* createReader() const;
};
#endif //AUD_ACCUMULATORFACTORY
Modified: branches/soc-2010-nexyon/intern/audaspace/FX/AUD_AccumulatorReader.cpp
===================================================================
--- branches/soc-2010-nexyon/intern/audaspace/FX/AUD_AccumulatorReader.cpp 2010-07-28 08:06:46 UTC (rev 30831)
+++ branches/soc-2010-nexyon/intern/audaspace/FX/AUD_AccumulatorReader.cpp 2010-07-28 09:36:03 UTC (rev 30832)
@@ -24,7 +24,6 @@
*/
#include "AUD_AccumulatorReader.h"
-#include "AUD_Buffer.h"
#include <cstring>
@@ -33,42 +32,29 @@
AUD_AccumulatorReader::AUD_AccumulatorReader(AUD_IReader* reader,
bool additive) :
AUD_EffectReader(reader),
- m_additive(additive)
+ m_additive(additive),
+ m_sums(AUD_SAMPLE_SIZE(reader->getSpecs())),
+ m_prevs(AUD_SAMPLE_SIZE(reader->getSpecs()))
{
- AUD_Specs specs = reader->getSpecs();
- int samplesize = AUD_SAMPLE_SIZE(specs);
-
- m_buffer = new AUD_Buffer(); AUD_NEW("buffer")
-
- m_sums = new AUD_Buffer(samplesize); AUD_NEW("buffer")
- memset(m_sums->getBuffer(), 0, samplesize);
-
- m_prevs = new AUD_Buffer(samplesize); AUD_NEW("buffer")
- memset(m_prevs->getBuffer(), 0, samplesize);
+ memset(m_sums.getBuffer(), 0, m_sums.getSize());
+ memset(m_prevs.getBuffer(), 0, m_prevs.getSize());
}
-AUD_AccumulatorReader::~AUD_AccumulatorReader()
-{
- delete m_buffer; AUD_DELETE("buffer")
- delete m_sums; AUD_DELETE("buffer")
- delete m_prevs; AUD_DELETE("buffer")
-}
-
void AUD_AccumulatorReader::read(int & length, sample_t* & buffer)
{
sample_t* buf;
sample_t* sums;
sample_t* prevs;
- sums = m_sums->getBuffer();
- prevs = m_prevs->getBuffer();
+ sums = m_sums.getBuffer();
+ prevs = m_prevs.getBuffer();
AUD_Specs specs = m_reader->getSpecs();
m_reader->read(length, buf);
- if(m_buffer->getSize() < length * AUD_SAMPLE_SIZE(specs))
- m_buffer->resize(length * AUD_SAMPLE_SIZE(specs));
+ if(m_buffer.getSize() < length * AUD_SAMPLE_SIZE(specs))
+ m_buffer.resize(length * AUD_SAMPLE_SIZE(specs));
- buffer = m_buffer->getBuffer();
+ buffer = m_buffer.getBuffer();
if(m_additive)
{
@@ -87,7 +73,7 @@
{
for(int channel = 0; channel < specs.channels; channel++)
{
- for(int i = 0; i < length * specs.channels; i++)
+ for(int i = 0; i < length; i++)
{
if(buf[i * CC] > prevs[channel])
sums[channel] += buf[i * CC] - prevs[channel];
Modified: branches/soc-2010-nexyon/intern/audaspace/FX/AUD_AccumulatorReader.h
===================================================================
--- branches/soc-2010-nexyon/intern/audaspace/FX/AUD_AccumulatorReader.h 2010-07-28 08:06:46 UTC (rev 30831)
+++ branches/soc-2010-nexyon/intern/audaspace/FX/AUD_AccumulatorReader.h 2010-07-28 09:36:03 UTC (rev 30832)
@@ -27,7 +27,7 @@
#define AUD_ACCUMULATORREADER
#include "AUD_EffectReader.h"
-class AUD_Buffer;
+#include "AUD_Buffer.h"
/**
* This class represents an accumulator.
@@ -36,39 +36,37 @@
{
private:
/**
+ * Whether the accumulator is additive.
+ */
+ const bool m_additive;
+
+ /**
* The playback buffer.
*/
- AUD_Buffer *m_buffer;
+ AUD_Buffer m_buffer;
/**
* The sums of the specific channels.
*/
- AUD_Buffer *m_sums;
+ AUD_Buffer m_sums;
/**
* The previous results of the specific channels.
*/
- AUD_Buffer *m_prevs;
+ AUD_Buffer m_prevs;
- /**
- * Whether the accumulator is additive.
- */
- bool m_additive;
+ // hide copy constructor and operator=
+ AUD_AccumulatorReader(const AUD_AccumulatorReader&);
+ AUD_AccumulatorReader& operator=(const AUD_AccumulatorReader&);
public:
/**
* Creates a new accumulator reader.
* \param reader The reader to read from.
* \param additive Whether the accumulator is additive.
- * \exception AUD_Exception Thrown if the reader specified is NULL.
*/
AUD_AccumulatorReader(AUD_IReader* reader, bool additive);
- /**
- * Destroys the reader.
- */
- virtual ~AUD_AccumulatorReader();
-
virtual void read(int & length, sample_t* & buffer);
};
Modified: branches/soc-2010-nexyon/intern/audaspace/FX/AUD_ButterworthFactory.cpp
===================================================================
--- branches/soc-2010-nexyon/intern/audaspace/FX/AUD_ButterworthFactory.cpp 2010-07-28 08:06:46 UTC (rev 30831)
+++ branches/soc-2010-nexyon/intern/audaspace/FX/AUD_ButterworthFactory.cpp 2010-07-28 09:36:03 UTC (rev 30832)
@@ -29,21 +29,11 @@
AUD_ButterworthFactory::AUD_ButterworthFactory(AUD_IFactory* factory,
float frequency) :
AUD_EffectFactory(factory),
- m_frequency(frequency) {}
-
-AUD_ButterworthFactory::AUD_ButterworthFactory(float frequency) :
- AUD_EffectFactory(0),
- m_frequency(frequency) {}
-
-AUD_IReader* AUD_ButterworthFactory::createReader()
+ m_frequency(frequency)
{
- AUD_IReader* reader = getReader();
+}
- if(reader != 0)
- {
- reader = new AUD_ButterworthReader(reader, m_frequency);
- AUD_NEW("reader")
- }
-
- return reader;
+AUD_IReader* AUD_ButterworthFactory::createReader() const
+{
+ return new AUD_ButterworthReader(getReader(), m_frequency);
}
Modified: branches/soc-2010-nexyon/intern/audaspace/FX/AUD_ButterworthFactory.h
===================================================================
--- branches/soc-2010-nexyon/intern/audaspace/FX/AUD_ButterworthFactory.h 2010-07-28 08:06:46 UTC (rev 30831)
+++ branches/soc-2010-nexyon/intern/audaspace/FX/AUD_ButterworthFactory.h 2010-07-28 09:36:03 UTC (rev 30832)
@@ -37,8 +37,12 @@
/**
* The attack value in seconds.
*/
- float m_frequency;
+ const float m_frequency;
+ // hide copy constructor and operator=
+ AUD_ButterworthFactory(const AUD_ButterworthFactory&);
+ AUD_ButterworthFactory& operator=(const AUD_ButterworthFactory&);
+
public:
/**
* Creates a new butterworth factory.
@@ -47,13 +51,7 @@
*/
AUD_ButterworthFactory(AUD_IFactory* factory, float frequency);
- /**
- * Creates a new butterworth factory.
- * \param frequency The cutoff frequency.
- */
- AUD_ButterworthFactory(float frequency);
-
- virtual AUD_IReader* createReader();
+ virtual AUD_IReader* createReader() const;
};
#endif //AUD_BUTTERWORTHFACTORY
Modified: branches/soc-2010-nexyon/intern/audaspace/FX/AUD_ButterworthReader.cpp
===================================================================
--- branches/soc-2010-nexyon/intern/audaspace/FX/AUD_ButterworthReader.cpp 2010-07-28 08:06:46 UTC (rev 30831)
+++ branches/soc-2010-nexyon/intern/audaspace/FX/AUD_ButterworthReader.cpp 2010-07-28 09:36:03 UTC (rev 30832)
@@ -24,7 +24,6 @@
*/
#include "AUD_ButterworthReader.h"
-#include "AUD_Buffer.h"
#include <cstring>
#include <cmath>
@@ -39,21 +38,15 @@
AUD_ButterworthReader::AUD_ButterworthReader(AUD_IReader* reader,
float frequency) :
- AUD_EffectReader(reader)
+ AUD_EffectReader(reader),
+ m_outvalues(AUD_SAMPLE_SIZE(reader->getSpecs()) * 5),
+ m_invalues(AUD_SAMPLE_SIZE(reader->getSpecs()) * 5),
+ m_position(0)
{
AUD_Specs specs = reader->getSpecs();
- int samplesize = AUD_SAMPLE_SIZE(specs);
+ memset(m_outvalues.getBuffer(), 0, m_outvalues.getSize());
+ memset(m_invalues.getBuffer(), 0, m_invalues.getSize());
- m_buffer = new AUD_Buffer(); AUD_NEW("buffer")
-
- m_outvalues = new AUD_Buffer(samplesize * 5); AUD_NEW("buffer")
- memset(m_outvalues->getBuffer(), 0, samplesize * 5);
-
- m_invalues = new AUD_Buffer(samplesize * 5); AUD_NEW("buffer")
- memset(m_invalues->getBuffer(), 0, samplesize * 5);
-
- m_position = 0;
-
// calculate coefficients
float omega = 2 * tan(frequency * M_PI / specs.rate);
float o2 = omega * omega;
@@ -74,31 +67,23 @@
m_coeff[1][2] = 6 * o4 / norm;
}
-AUD_ButterworthReader::~AUD_ButterworthReader()
-{
- delete m_buffer; AUD_DELETE("buffer")
-
- delete m_outvalues; AUD_DELETE("buffer")
- delete m_invalues; AUD_DELETE("buffer");
-}
-
void AUD_ButterworthReader::read(int & length, sample_t* & buffer)
{
sample_t* buf;
sample_t* outvalues;
sample_t* invalues;
- outvalues = m_outvalues->getBuffer();
- invalues = m_invalues->getBuffer();
+ outvalues = m_outvalues.getBuffer();
+ invalues = m_invalues.getBuffer();
AUD_Specs specs = m_reader->getSpecs();
m_reader->read(length, buf);
- if(m_buffer->getSize() < length * AUD_SAMPLE_SIZE(specs))
- m_buffer->resize(length * AUD_SAMPLE_SIZE(specs));
+ if(m_buffer.getSize() < length * AUD_SAMPLE_SIZE(specs))
+ m_buffer.resize(length * AUD_SAMPLE_SIZE(specs));
- buffer = m_buffer->getBuffer();
+ buffer = m_buffer.getBuffer();
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list