[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30953] branches/soc-2010-nexyon: Audaspace:

Joerg Mueller nexyon at gmail.com
Mon Aug 2 00:33:50 CEST 2010


Revision: 30953
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30953
Author:   nexyon
Date:     2010-08-02 00:33:50 +0200 (Mon, 02 Aug 2010)

Log Message:
-----------
Audaspace:
* Created awesome filter classes :)
* Made all filter effects use the filter classes instead of having the same implementation everywhere.
* Added a Python API for LTI IIR filters.
* Fixed a warning in creator.c that was introduced when adding game autoplay.

Modified Paths:
--------------
    branches/soc-2010-nexyon/intern/audaspace/FX/AUD_AccumulatorFactory.cpp
    branches/soc-2010-nexyon/intern/audaspace/FX/AUD_ButterworthFactory.cpp
    branches/soc-2010-nexyon/intern/audaspace/FX/AUD_EnvelopeFactory.cpp
    branches/soc-2010-nexyon/intern/audaspace/FX/AUD_HighpassFactory.cpp
    branches/soc-2010-nexyon/intern/audaspace/FX/AUD_LowpassFactory.cpp
    branches/soc-2010-nexyon/intern/audaspace/FX/AUD_RectifyFactory.cpp
    branches/soc-2010-nexyon/intern/audaspace/FX/AUD_SquareFactory.cpp
    branches/soc-2010-nexyon/intern/audaspace/FX/AUD_SumFactory.cpp
    branches/soc-2010-nexyon/intern/audaspace/FX/AUD_VolumeFactory.cpp
    branches/soc-2010-nexyon/intern/audaspace/Python/AUD_PyAPI.cpp
    branches/soc-2010-nexyon/source/creator/creator.c

Added Paths:
-----------
    branches/soc-2010-nexyon/intern/audaspace/FX/AUD_BaseIIRFilterReader.cpp
    branches/soc-2010-nexyon/intern/audaspace/FX/AUD_BaseIIRFilterReader.h
    branches/soc-2010-nexyon/intern/audaspace/FX/AUD_CallbackIIRFilterReader.cpp
    branches/soc-2010-nexyon/intern/audaspace/FX/AUD_CallbackIIRFilterReader.h
    branches/soc-2010-nexyon/intern/audaspace/FX/AUD_IIRFilterFactory.cpp
    branches/soc-2010-nexyon/intern/audaspace/FX/AUD_IIRFilterFactory.h
    branches/soc-2010-nexyon/intern/audaspace/FX/AUD_IIRFilterReader.cpp
    branches/soc-2010-nexyon/intern/audaspace/FX/AUD_IIRFilterReader.h

Removed Paths:
-------------
    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_ButterworthReader.cpp
    branches/soc-2010-nexyon/intern/audaspace/FX/AUD_ButterworthReader.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_HighpassReader.cpp
    branches/soc-2010-nexyon/intern/audaspace/FX/AUD_HighpassReader.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_RectifyReader.cpp
    branches/soc-2010-nexyon/intern/audaspace/FX/AUD_RectifyReader.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_SumReader.cpp
    branches/soc-2010-nexyon/intern/audaspace/FX/AUD_SumReader.h
    branches/soc-2010-nexyon/intern/audaspace/FX/AUD_VolumeReader.cpp
    branches/soc-2010-nexyon/intern/audaspace/FX/AUD_VolumeReader.h

Modified: branches/soc-2010-nexyon/intern/audaspace/FX/AUD_AccumulatorFactory.cpp
===================================================================
--- branches/soc-2010-nexyon/intern/audaspace/FX/AUD_AccumulatorFactory.cpp	2010-08-01 22:20:45 UTC (rev 30952)
+++ branches/soc-2010-nexyon/intern/audaspace/FX/AUD_AccumulatorFactory.cpp	2010-08-01 22:33:50 UTC (rev 30953)
@@ -24,8 +24,28 @@
  */
 
 #include "AUD_AccumulatorFactory.h"
-#include "AUD_AccumulatorReader.h"
+#include "AUD_CallbackIIRFilterReader.h"
 
+sample_t accumulatorFilterAdditive(AUD_CallbackIIRFilterReader* reader, void* useless)
+{
+	float in = reader->x(0);
+	float lastin = reader->x(-1);
+	float out = reader->y(-1) + in - lastin;
+	if(in > lastin)
+		out += in - lastin;
+	return out;
+}
+
+sample_t accumulatorFilter(AUD_CallbackIIRFilterReader* reader, void* useless)
+{
+	float in = reader->x(0);
+	float lastin = reader->x(-1);
+	float out = reader->y(-1);
+	if(in > lastin)
+		out += in - lastin;
+	return out;
+}
+
 AUD_AccumulatorFactory::AUD_AccumulatorFactory(AUD_IFactory* factory,
 											   bool additive) :
 		AUD_EffectFactory(factory),
@@ -35,5 +55,6 @@
 
 AUD_IReader* AUD_AccumulatorFactory::createReader() const
 {
-	return new AUD_AccumulatorReader(getReader(), m_additive);
+	return new AUD_CallbackIIRFilterReader(getReader(), 2, 2,
+							m_additive ? accumulatorFilterAdditive : accumulatorFilter);
 }

Deleted: branches/soc-2010-nexyon/intern/audaspace/FX/AUD_AccumulatorReader.cpp
===================================================================
--- branches/soc-2010-nexyon/intern/audaspace/FX/AUD_AccumulatorReader.cpp	2010-08-01 22:20:45 UTC (rev 30952)
+++ branches/soc-2010-nexyon/intern/audaspace/FX/AUD_AccumulatorReader.cpp	2010-08-01 22:33:50 UTC (rev 30953)
@@ -1,85 +0,0 @@
-/*
- * $Id$
- *
- * ***** BEGIN LGPL LICENSE BLOCK *****
- *
- * Copyright 2009 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 Lesser General Public License as published by
- * the Free Software Foundation, either version 3 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with AudaSpace.  If not, see <http://www.gnu.org/licenses/>.
- *
- * ***** END LGPL LICENSE BLOCK *****
- */
-
-#include "AUD_AccumulatorReader.h"
-
-#include <cstring>
-
-#define CC specs.channels + channel
-
-AUD_AccumulatorReader::AUD_AccumulatorReader(AUD_IReader* reader,
-											 bool additive) :
-		AUD_EffectReader(reader),
-		m_additive(additive),
-		m_sums(AUD_SAMPLE_SIZE(reader->getSpecs())),
-		m_prevs(AUD_SAMPLE_SIZE(reader->getSpecs()))
-{
-	memset(m_sums.getBuffer(), 0, m_sums.getSize());
-	memset(m_prevs.getBuffer(), 0, m_prevs.getSize());
-}
-
-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();
-
-	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));
-
-	buffer = m_buffer.getBuffer();
-
-	if(m_additive)
-	{
-		for(int channel = 0; channel < specs.channels; channel++)
-		{
-			for(int i = 0; i < length; i++)
-			{
-				if(buf[i * CC] > prevs[channel])
-					sums[channel] += buf[i * CC] - prevs[channel];
-				buffer[i * CC] = sums[channel] + buf[i * CC];
-				prevs[channel] = buf[i * CC];
-			}
-		}
-	}
-	else
-	{
-		for(int channel = 0; channel < specs.channels; channel++)
-		{
-			for(int i = 0; i < length; i++)
-			{
-				if(buf[i * CC] > prevs[channel])
-					sums[channel] += buf[i * CC] - prevs[channel];
-				buffer[i * CC] = sums[channel];
-				prevs[channel] = buf[i * CC];
-			}
-		}
-	}
-}

Deleted: branches/soc-2010-nexyon/intern/audaspace/FX/AUD_AccumulatorReader.h
===================================================================
--- branches/soc-2010-nexyon/intern/audaspace/FX/AUD_AccumulatorReader.h	2010-08-01 22:20:45 UTC (rev 30952)
+++ branches/soc-2010-nexyon/intern/audaspace/FX/AUD_AccumulatorReader.h	2010-08-01 22:33:50 UTC (rev 30953)
@@ -1,73 +0,0 @@
-/*
- * $Id$
- *
- * ***** BEGIN LGPL LICENSE BLOCK *****
- *
- * Copyright 2009 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 Lesser General Public License as published by
- * the Free Software Foundation, either version 3 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with AudaSpace.  If not, see <http://www.gnu.org/licenses/>.
- *
- * ***** END LGPL LICENSE BLOCK *****
- */
-
-#ifndef AUD_ACCUMULATORREADER
-#define AUD_ACCUMULATORREADER
-
-#include "AUD_EffectReader.h"
-#include "AUD_Buffer.h"
-
-/**
- * This class represents an accumulator.
- */
-class AUD_AccumulatorReader : public AUD_EffectReader
-{
-private:
-	/**
-	 * Whether the accumulator is additive.
-	 */
-	const bool m_additive;
-
-	/**
-	 * The playback buffer.
-	 */
-	AUD_Buffer m_buffer;
-
-	/**
-	 * The sums of the specific channels.
-	 */
-	AUD_Buffer m_sums;
-
-	/**
-	 * The previous results of the specific channels.
-	 */
-	AUD_Buffer m_prevs;
-
-	// 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.
-	 */
-	AUD_AccumulatorReader(AUD_IReader* reader, bool additive);
-
-	virtual void read(int & length, sample_t* & buffer);
-};
-
-#endif //AUD_ACCUMULATORREADER

Copied: branches/soc-2010-nexyon/intern/audaspace/FX/AUD_BaseIIRFilterReader.cpp (from rev 30922, branches/soc-2010-nexyon/intern/audaspace/FX/AUD_LowpassReader.cpp)
===================================================================
--- branches/soc-2010-nexyon/intern/audaspace/FX/AUD_BaseIIRFilterReader.cpp	                        (rev 0)
+++ branches/soc-2010-nexyon/intern/audaspace/FX/AUD_BaseIIRFilterReader.cpp	2010-08-01 22:33:50 UTC (rev 30953)
@@ -0,0 +1,76 @@
+/*
+ * $Id$
+ *
+ * ***** BEGIN LGPL LICENSE BLOCK *****
+ *
+ * Copyright 2009 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 Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with AudaSpace.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * ***** END LGPL LICENSE BLOCK *****
+ */
+
+#include "AUD_BaseIIRFilterReader.h"
+
+#include <cstring>
+
+#define CC m_channels + m_channel
+
+AUD_BaseIIRFilterReader::AUD_BaseIIRFilterReader(AUD_IReader* reader, int in,
+												 int out) :
+		AUD_EffectReader(reader),
+		m_channels(reader->getSpecs().channels),
+		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];
+
+	memset(m_x, 0, sizeof(sample_t) * in * m_channels);
+	memset(m_y, 0, sizeof(sample_t) * out * m_channels);
+}
+
+AUD_BaseIIRFilterReader::~AUD_BaseIIRFilterReader()
+{
+	delete[] m_x;
+	delete[] m_y;
+}
+
+void AUD_BaseIIRFilterReader::read(int & length, sample_t* & buffer)
+{
+	sample_t* buf;
+
+	int samplesize = AUD_SAMPLE_SIZE(m_reader->getSpecs());
+
+	m_reader->read(length, buf);
+
+	if(m_buffer.getSize() < length * samplesize)
+		m_buffer.resize(length * samplesize);
+
+	buffer = m_buffer.getBuffer();
+
+	for(m_channel = 0; m_channel < m_channels; m_channel++)
+	{
+		for(int i = 0; i < length; i++)
+		{
+			m_x[m_xpos * CC] = buf[i * CC];
+			m_y[m_ypos * CC] = buffer[i * CC] = filter();
+
+			m_xpos = (m_xpos + 1) % m_xlen;
+			m_ypos = (m_ypos + 1) % m_ylen;
+		}
+	}
+}

Copied: branches/soc-2010-nexyon/intern/audaspace/FX/AUD_BaseIIRFilterReader.h (from rev 30922, branches/soc-2010-nexyon/intern/audaspace/FX/AUD_LowpassReader.h)
===================================================================
--- branches/soc-2010-nexyon/intern/audaspace/FX/AUD_BaseIIRFilterReader.h	                        (rev 0)
+++ branches/soc-2010-nexyon/intern/audaspace/FX/AUD_BaseIIRFilterReader.h	2010-08-01 22:33:50 UTC (rev 30953)
@@ -0,0 +1,114 @@
+/*
+ * $Id$
+ *
+ * ***** BEGIN LGPL LICENSE BLOCK *****
+ *
+ * Copyright 2009 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 Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with AudaSpace.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * ***** END LGPL LICENSE BLOCK *****
+ */
+
+#ifndef AUD_BASEIIRFILTERREADER
+#define AUD_BASEIIRFILTERREADER
+
+#include "AUD_EffectReader.h"
+#include "AUD_Buffer.h"
+
+/**
+ * This class is a base class for infinite impulse response filters.
+ */

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list