Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoerg Mueller <nexyon@gmail.com>2009-08-10 01:16:39 +0400
committerJoerg Mueller <nexyon@gmail.com>2009-08-10 01:16:39 +0400
commit6c5c58e05799f2b593cd81fcff57e6ef72ad57fb (patch)
tree8add929ef94d03fc69aecce6ef2baf283505782f /intern/audaspace/FX
parentc1ca2ab5dceb8d5355215a3c7a80b171f394e487 (diff)
2.5: Sound branch merge!
See mailing list for additional information.
Diffstat (limited to 'intern/audaspace/FX')
-rw-r--r--intern/audaspace/FX/AUD_DelayFactory.cpp58
-rw-r--r--intern/audaspace/FX/AUD_DelayFactory.h70
-rw-r--r--intern/audaspace/FX/AUD_DelayReader.cpp111
-rw-r--r--intern/audaspace/FX/AUD_DelayReader.h73
-rw-r--r--intern/audaspace/FX/AUD_DoubleReader.cpp158
-rw-r--r--intern/audaspace/FX/AUD_DoubleReader.h83
-rw-r--r--intern/audaspace/FX/AUD_EffectFactory.cpp50
-rw-r--r--intern/audaspace/FX/AUD_EffectFactory.h76
-rw-r--r--intern/audaspace/FX/AUD_EffectReader.cpp78
-rw-r--r--intern/audaspace/FX/AUD_EffectReader.h66
-rw-r--r--intern/audaspace/FX/AUD_FaderFactory.cpp84
-rw-r--r--intern/audaspace/FX/AUD_FaderFactory.h111
-rw-r--r--intern/audaspace/FX/AUD_FaderReader.cpp133
-rw-r--r--intern/audaspace/FX/AUD_FaderReader.h86
-rw-r--r--intern/audaspace/FX/AUD_LimiterFactory.cpp67
-rw-r--r--intern/audaspace/FX/AUD_LimiterFactory.h84
-rw-r--r--intern/audaspace/FX/AUD_LimiterReader.cpp95
-rw-r--r--intern/audaspace/FX/AUD_LimiterReader.h64
-rw-r--r--intern/audaspace/FX/AUD_LoopFactory.cpp57
-rw-r--r--intern/audaspace/FX/AUD_LoopFactory.h74
-rw-r--r--intern/audaspace/FX/AUD_LoopReader.cpp107
-rw-r--r--intern/audaspace/FX/AUD_LoopReader.h69
-rw-r--r--intern/audaspace/FX/AUD_PingPongFactory.cpp67
-rw-r--r--intern/audaspace/FX/AUD_PingPongFactory.h51
-rw-r--r--intern/audaspace/FX/AUD_PitchFactory.cpp48
-rw-r--r--intern/audaspace/FX/AUD_PitchFactory.h70
-rw-r--r--intern/audaspace/FX/AUD_PitchReader.cpp39
-rw-r--r--intern/audaspace/FX/AUD_PitchReader.h54
-rw-r--r--intern/audaspace/FX/AUD_ReverseFactory.cpp43
-rw-r--r--intern/audaspace/FX/AUD_ReverseFactory.h50
-rw-r--r--intern/audaspace/FX/AUD_ReverseReader.cpp111
-rw-r--r--intern/audaspace/FX/AUD_ReverseReader.h74
-rw-r--r--intern/audaspace/FX/AUD_VolumeFactory.cpp57
-rw-r--r--intern/audaspace/FX/AUD_VolumeFactory.h72
-rw-r--r--intern/audaspace/FX/AUD_VolumeReader.cpp97
-rw-r--r--intern/audaspace/FX/AUD_VolumeReader.h72
36 files changed, 2759 insertions, 0 deletions
diff --git a/intern/audaspace/FX/AUD_DelayFactory.cpp b/intern/audaspace/FX/AUD_DelayFactory.cpp
new file mode 100644
index 00000000000..25ce4faed4c
--- /dev/null
+++ b/intern/audaspace/FX/AUD_DelayFactory.cpp
@@ -0,0 +1,58 @@
+/*
+ * $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_DelayFactory.h"
+#include "AUD_DelayReader.h"
+#include "AUD_Space.h"
+
+AUD_DelayFactory::AUD_DelayFactory(AUD_IFactory* factory, float delay) :
+ AUD_EffectFactory(factory),
+ m_delay(delay) {}
+
+AUD_DelayFactory::AUD_DelayFactory(float delay) :
+ AUD_EffectFactory(0),
+ m_delay(delay) {}
+
+float AUD_DelayFactory::getDelay()
+{
+ return m_delay;
+}
+
+void AUD_DelayFactory::setDelay(float delay)
+{
+ m_delay = delay;
+}
+
+AUD_IReader* AUD_DelayFactory::createReader()
+{
+ AUD_IReader* reader = getReader();
+
+ if(reader != 0)
+ {
+ reader = new AUD_DelayReader(reader, m_delay); AUD_NEW("reader")
+ }
+
+ return reader;
+}
diff --git a/intern/audaspace/FX/AUD_DelayFactory.h b/intern/audaspace/FX/AUD_DelayFactory.h
new file mode 100644
index 00000000000..5ad4b9ab996
--- /dev/null
+++ b/intern/audaspace/FX/AUD_DelayFactory.h
@@ -0,0 +1,70 @@
+/*
+ * $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_DELAYFACTORY
+#define AUD_DELAYFACTORY
+
+#include "AUD_EffectFactory.h"
+
+/**
+ * This factory plays another factory delayed.
+ */
+class AUD_DelayFactory : public AUD_EffectFactory
+{
+private:
+ /**
+ * The delay in samples.
+ */
+ float m_delay;
+
+public:
+ /**
+ * Creates a new delay factory.
+ * \param factory The input factory.
+ * \param delay The desired delay in seconds.
+ */
+ AUD_DelayFactory(AUD_IFactory* factory = 0, float delay = 0);
+
+ /**
+ * Creates a new delay factory.
+ * \param delay The desired delay in seconds.
+ */
+ AUD_DelayFactory(float delay);
+
+ /**
+ * Returns the delay in seconds.
+ */
+ float getDelay();
+
+ /**
+ * Sets the delay.
+ * \param delay The new delay value in seconds.
+ */
+ void setDelay(float delay);
+
+ virtual AUD_IReader* createReader();
+};
+
+#endif //AUD_DELAYFACTORY
diff --git a/intern/audaspace/FX/AUD_DelayReader.cpp b/intern/audaspace/FX/AUD_DelayReader.cpp
new file mode 100644
index 00000000000..38d3b893b5c
--- /dev/null
+++ b/intern/audaspace/FX/AUD_DelayReader.cpp
@@ -0,0 +1,111 @@
+/*
+ * $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_DelayReader.h"
+#include "AUD_Buffer.h"
+
+#include <cstring>
+
+AUD_DelayReader::AUD_DelayReader(AUD_IReader* reader, float delay) :
+ AUD_EffectReader(reader)
+{
+ m_delay = (int)(delay * reader->getSpecs().rate);
+ m_remdelay = m_delay;
+ m_buffer = new AUD_Buffer(); AUD_NEW("buffer")
+}
+
+AUD_DelayReader::~AUD_DelayReader()
+{
+ delete m_buffer; AUD_DELETE("buffer")
+}
+
+void AUD_DelayReader::seek(int position)
+{
+ if(position < 0)
+ return;
+
+ if(position < m_delay)
+ {
+ m_remdelay = m_delay - position;
+ m_reader->seek(0);
+ }
+ else
+ {
+ m_remdelay = 0;
+ m_reader->seek(position - m_delay);
+ }
+}
+
+int AUD_DelayReader::getLength()
+{
+ int len = m_reader->getLength();
+ if(len < 0)
+ return len;
+ return len+m_delay;
+}
+
+int AUD_DelayReader::getPosition()
+{
+ if(m_remdelay > 0)
+ return m_delay-m_remdelay;
+ return m_reader->getPosition() + m_delay;
+}
+
+void AUD_DelayReader::read(int & length, sample_t* & buffer)
+{
+ if(m_remdelay > 0)
+ {
+ int samplesize = AUD_SAMPLE_SIZE(m_reader->getSpecs());
+
+ if(m_buffer->getSize() < length*samplesize)
+ m_buffer->resize(length*samplesize);
+
+ if(length > m_remdelay)
+ {
+ if(getSpecs().format == AUD_FORMAT_U8)
+ memset(m_buffer->getBuffer(), 0x80, m_remdelay*samplesize);
+ else
+ memset(m_buffer->getBuffer(), 0, m_remdelay*samplesize);
+ int len = length - m_remdelay;
+ m_reader->read(len, buffer);
+ memcpy(m_buffer->getBuffer()+m_remdelay*samplesize,
+ buffer, len*samplesize);
+ if(len < length-m_remdelay)
+ length = m_remdelay + len;
+ m_remdelay = 0;
+ }
+ else
+ {
+ if(getSpecs().format == AUD_FORMAT_U8)
+ memset(m_buffer->getBuffer(), 0x80, length*samplesize);
+ else
+ memset(m_buffer->getBuffer(), 0, length*samplesize);
+ m_remdelay -= length;
+ }
+ buffer = m_buffer->getBuffer();
+ }
+ else
+ m_reader->read(length, buffer);
+}
diff --git a/intern/audaspace/FX/AUD_DelayReader.h b/intern/audaspace/FX/AUD_DelayReader.h
new file mode 100644
index 00000000000..4662b455dfc
--- /dev/null
+++ b/intern/audaspace/FX/AUD_DelayReader.h
@@ -0,0 +1,73 @@
+/*
+ * $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_DELAYREADER
+#define AUD_DELAYREADER
+
+#include "AUD_EffectReader.h"
+class AUD_Buffer;
+
+/**
+ * This class reads another reader and changes it's delay.
+ */
+class AUD_DelayReader : public AUD_EffectReader
+{
+private:
+ /**
+ * The playback buffer.
+ */
+ AUD_Buffer *m_buffer;
+
+ /**
+ * The delay level.
+ */
+ int m_delay;
+
+ /**
+ * The remaining delay for playback.
+ */
+ int m_remdelay;
+
+public:
+ /**
+ * Creates a new delay reader.
+ * \param reader The reader to read from.
+ * \param delay The delay in seconds.
+ * \exception AUD_Exception Thrown if the reader specified is NULL.
+ */
+ AUD_DelayReader(AUD_IReader* reader, float delay);
+
+ /**
+ * Destroys the reader.
+ */
+ virtual ~AUD_DelayReader();
+
+ virtual void seek(int position);
+ virtual int getLength();
+ virtual int getPosition();
+ virtual void read(int & length, sample_t* & buffer);
+};
+
+#endif //AUD_DELAYREADER
diff --git a/intern/audaspace/FX/AUD_DoubleReader.cpp b/intern/audaspace/FX/AUD_DoubleReader.cpp
new file mode 100644
index 00000000000..181e394da98
--- /dev/null
+++ b/intern/audaspace/FX/AUD_DoubleReader.cpp
@@ -0,0 +1,158 @@
+/*
+ * $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_DoubleReader.h"
+#include "AUD_Buffer.h"
+
+#include <cstring>
+
+AUD_DoubleReader::AUD_DoubleReader(AUD_IReader* reader1,
+ AUD_IReader* reader2) :
+ m_reader1(reader1), m_reader2(reader2)
+{
+ try
+ {
+ if(!reader1)
+ AUD_THROW(AUD_ERROR_READER);
+
+ if(!reader2)
+ AUD_THROW(AUD_ERROR_READER);
+
+ AUD_Specs s1, s2;
+ s1 = reader1->getSpecs();
+ s2 = reader2->getSpecs();
+ if(memcmp(&s1, &s2, sizeof(AUD_Specs)) != 0)
+ AUD_THROW(AUD_ERROR_READER);
+ }
+
+ catch(AUD_Exception e)
+ {
+ if(reader1)
+ {
+ delete reader1; AUD_DELETE("reader")
+ }
+ if(reader2)
+ {
+ delete reader2; AUD_DELETE("reader")
+ }
+
+ throw;
+ }
+
+ m_buffer = new AUD_Buffer(); AUD_NEW("buffer")
+ m_finished1 = false;
+}
+
+AUD_DoubleReader::~AUD_DoubleReader()
+{
+ delete m_reader1; AUD_DELETE("reader")
+ delete m_reader2; AUD_DELETE("reader")
+ delete m_buffer; AUD_DELETE("buffer")
+}
+
+bool AUD_DoubleReader::isSeekable()
+{
+ return false;
+}
+
+void AUD_DoubleReader::seek(int position)
+{
+ int length1 = m_reader1->getLength();
+
+ if(position < 0)
+ position = 0;
+
+ if(position < length1)
+ {
+ m_reader1->seek(position);
+ m_reader2->seek(0);
+ m_finished1 = false;
+ }
+ else
+ {
+ m_reader2->seek(position-length1);
+ m_finished1 = true;
+ }
+}
+
+int AUD_DoubleReader::getLength()
+{
+ int len1 = m_reader1->getLength();
+ int len2 = m_reader2->getLength();
+ if(len1 < 0 || len2 < 0)
+ return -1;
+ return len1 + len2;
+}
+
+int AUD_DoubleReader::getPosition()
+{
+ return m_reader1->getPosition() + m_reader2->getPosition();
+}
+
+AUD_Specs AUD_DoubleReader::getSpecs()
+{
+ return m_reader1->getSpecs();
+}
+
+AUD_ReaderType AUD_DoubleReader::getType()
+{
+ if(m_reader1->getType() == AUD_TYPE_BUFFER &&
+ m_reader2->getType() == AUD_TYPE_BUFFER)
+ return AUD_TYPE_BUFFER;
+ return AUD_TYPE_STREAM;
+}
+
+bool AUD_DoubleReader::notify(AUD_Message &message)
+{
+ return m_reader1->notify(message) | m_reader2->notify(message);
+}
+
+void AUD_DoubleReader::read(int & length, sample_t* & buffer)
+{
+ if(!m_finished1)
+ {
+ int len = length;
+ m_reader1->read(len, buffer);
+ if(len < length)
+ {
+ int samplesize = AUD_SAMPLE_SIZE(m_reader1->getSpecs());
+ if(m_buffer->getSize() < length * samplesize)
+ m_buffer->resize(length * samplesize);
+ memcpy(m_buffer->getBuffer(), buffer, len*samplesize);
+ len = length - len;
+ length -= len;
+ m_reader2->read(len, buffer);
+ memcpy(m_buffer->getBuffer() + length*samplesize,
+ buffer, len*samplesize);
+ length += len;
+ buffer = m_buffer->getBuffer();
+ m_finished1 = true;
+ }
+ }
+ else
+ {
+ m_reader2->read(length, buffer);
+ }
+}
diff --git a/intern/audaspace/FX/AUD_DoubleReader.h b/intern/audaspace/FX/AUD_DoubleReader.h
new file mode 100644
index 00000000000..d82b81ec0ba
--- /dev/null
+++ b/intern/audaspace/FX/AUD_DoubleReader.h
@@ -0,0 +1,83 @@
+/*
+ * $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_DOUBLEREADER
+#define AUD_DOUBLEREADER
+
+#include "AUD_IReader.h"
+class AUD_Buffer;
+
+/**
+ * This reader plays two readers with the same specs sequently.
+ */
+class AUD_DoubleReader : public AUD_IReader
+{
+private:
+ /**
+ * The first reader.
+ */
+ AUD_IReader* m_reader1;
+
+ /**
+ * The second reader.
+ */
+ AUD_IReader* m_reader2;
+
+ /**
+ * Whether we've reached the end of the first reader.
+ */
+ bool m_finished1;
+
+ /**
+ * The playback buffer for the intersecting part.
+ */
+ AUD_Buffer* m_buffer;
+
+public:
+ /**
+ * Creates a new ping pong reader.
+ * \param reader1 The first reader to read from.
+ * \param reader2 The second reader to read from.
+ * \exception AUD_Exception Thrown if one of the reader specified is NULL
+ * or the specs from the readers differ.
+ */
+ AUD_DoubleReader(AUD_IReader* reader1, AUD_IReader* reader2);
+
+ /**
+ * Destroys the reader.
+ */
+ virtual ~AUD_DoubleReader();
+
+ virtual bool isSeekable();
+ virtual void seek(int position);
+ virtual int getLength();
+ virtual int getPosition();
+ virtual AUD_Specs getSpecs();
+ virtual AUD_ReaderType getType();
+ virtual bool notify(AUD_Message &message);
+ virtual void read(int & length, sample_t* & buffer);
+};
+
+#endif //AUD_DOUBLEREADER
diff --git a/intern/audaspace/FX/AUD_EffectFactory.cpp b/intern/audaspace/FX/AUD_EffectFactory.cpp
new file mode 100644
index 00000000000..882499416b7
--- /dev/null
+++ b/intern/audaspace/FX/AUD_EffectFactory.cpp
@@ -0,0 +1,50 @@
+/*
+ * $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_EffectFactory.h"
+#include "AUD_IReader.h"
+
+AUD_IReader* AUD_EffectFactory::getReader()
+{
+ if(m_factory != 0)
+ return m_factory->createReader();
+
+ return 0;
+}
+
+AUD_EffectFactory::AUD_EffectFactory(AUD_IFactory* factory)
+{
+ m_factory = factory;
+}
+
+void AUD_EffectFactory::setFactory(AUD_IFactory* factory)
+{
+ m_factory = factory;
+}
+
+AUD_IFactory* AUD_EffectFactory::getFactory()
+{
+ return m_factory;
+}
diff --git a/intern/audaspace/FX/AUD_EffectFactory.h b/intern/audaspace/FX/AUD_EffectFactory.h
new file mode 100644
index 00000000000..67259b9e6c3
--- /dev/null
+++ b/intern/audaspace/FX/AUD_EffectFactory.h
@@ -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 *****
+ */
+
+#ifndef AUD_EFFECTFACTORY
+#define AUD_EFFECTFACTORY
+
+#include "AUD_IFactory.h"
+
+/**
+ * This factory is a base class for all effect factories that take one other
+ * factory as input.
+ */
+class AUD_EffectFactory : public AUD_IFactory
+{
+protected:
+ /**
+ * If there is no reader it is created out of this factory.
+ */
+ AUD_IFactory* m_factory;
+
+ /**
+ * Returns the reader created out of the factory.
+ * This method can be used for the createReader function of the implementing
+ * classes.
+ * \return The reader created out of the factory or NULL if there is none.
+ */
+ AUD_IReader* getReader();
+
+public:
+ /**
+ * Creates a new factory.
+ * \param factory The input factory.
+ */
+ AUD_EffectFactory(AUD_IFactory* factory);
+
+ /**
+ * Destroys the factory.
+ */
+ virtual ~AUD_EffectFactory() {}
+
+ /**
+ * Sets the input factory.
+ * \param factory The input factory.
+ */
+ void setFactory(AUD_IFactory* factory);
+
+ /**
+ * Returns the saved factory.
+ * \return The factory or NULL if there has no factory been saved.
+ */
+ AUD_IFactory* getFactory();
+};
+
+#endif //AUD_EFFECTFACTORY
diff --git a/intern/audaspace/FX/AUD_EffectReader.cpp b/intern/audaspace/FX/AUD_EffectReader.cpp
new file mode 100644
index 00000000000..47026b88440
--- /dev/null
+++ b/intern/audaspace/FX/AUD_EffectReader.cpp
@@ -0,0 +1,78 @@
+/*
+ * $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_EffectReader.h"
+
+AUD_EffectReader::AUD_EffectReader(AUD_IReader* reader)
+{
+ if(!reader)
+ AUD_THROW(AUD_ERROR_READER);
+ m_reader = reader;
+}
+
+AUD_EffectReader::~AUD_EffectReader()
+{
+ delete m_reader; AUD_DELETE("reader")
+}
+
+bool AUD_EffectReader::isSeekable()
+{
+ return m_reader->isSeekable();
+}
+
+void AUD_EffectReader::seek(int position)
+{
+ m_reader->seek(position);
+}
+
+int AUD_EffectReader::getLength()
+{
+ return m_reader->getLength();
+}
+
+int AUD_EffectReader::getPosition()
+{
+ return m_reader->getPosition();
+}
+
+AUD_Specs AUD_EffectReader::getSpecs()
+{
+ return m_reader->getSpecs();
+}
+
+AUD_ReaderType AUD_EffectReader::getType()
+{
+ return m_reader->getType();
+}
+
+bool AUD_EffectReader::notify(AUD_Message &message)
+{
+ return m_reader->notify(message);
+}
+
+void AUD_EffectReader::read(int & length, sample_t* & buffer)
+{
+ m_reader->read(length, buffer);
+}
diff --git a/intern/audaspace/FX/AUD_EffectReader.h b/intern/audaspace/FX/AUD_EffectReader.h
new file mode 100644
index 00000000000..f64bf34077d
--- /dev/null
+++ b/intern/audaspace/FX/AUD_EffectReader.h
@@ -0,0 +1,66 @@
+/*
+ * $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_EFFECTREADER
+#define AUD_EFFECTREADER
+
+#include "AUD_IReader.h"
+
+/**
+ * This reader is a base class for all effect readers that take one other reader
+ * as input.
+ */
+class AUD_EffectReader : public AUD_IReader
+{
+protected:
+ /**
+ * The reader to read from.
+ */
+ AUD_IReader* m_reader;
+
+public:
+ /**
+ * Creates a new effect reader.
+ * \param reader The reader to read from.
+ * \exception AUD_Exception Thrown if the reader specified is NULL.
+ */
+ AUD_EffectReader(AUD_IReader* reader);
+
+ /**
+ * Destroys the reader.
+ */
+ virtual ~AUD_EffectReader();
+
+ virtual bool isSeekable();
+ virtual void seek(int position);
+ virtual int getLength();
+ virtual int getPosition();
+ virtual AUD_Specs getSpecs();
+ virtual AUD_ReaderType getType();
+ virtual bool notify(AUD_Message &message);
+ virtual void read(int & length, sample_t* & buffer);
+};
+
+#endif //AUD_EFFECTREADER
diff --git a/intern/audaspace/FX/AUD_FaderFactory.cpp b/intern/audaspace/FX/AUD_FaderFactory.cpp
new file mode 100644
index 00000000000..4357e11bd43
--- /dev/null
+++ b/intern/audaspace/FX/AUD_FaderFactory.cpp
@@ -0,0 +1,84 @@
+/*
+ * $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_FaderFactory.h"
+#include "AUD_FaderReader.h"
+
+AUD_FaderFactory::AUD_FaderFactory(AUD_IFactory* factory, AUD_FadeType type,
+ float start, float length) :
+ AUD_EffectFactory(factory),
+ m_type(type),
+ m_start(start),
+ m_length(length) {}
+
+AUD_FaderFactory::AUD_FaderFactory(AUD_FadeType type,
+ float start, float length) :
+ AUD_EffectFactory(0),
+ m_type(type),
+ m_start(start),
+ m_length(length) {}
+
+AUD_FadeType AUD_FaderFactory::getType()
+{
+ return m_type;
+}
+
+void AUD_FaderFactory::setType(AUD_FadeType type)
+{
+ m_type = type;
+}
+
+float AUD_FaderFactory::getStart()
+{
+ return m_start;
+}
+
+void AUD_FaderFactory::setStart(float start)
+{
+ m_start = start;
+}
+
+float AUD_FaderFactory::getLength()
+{
+ return m_length;
+}
+
+void AUD_FaderFactory::setLength(float length)
+{
+ m_length = length;
+}
+
+AUD_IReader* AUD_FaderFactory::createReader()
+{
+ AUD_IReader* reader = getReader();
+
+ if(reader != 0)
+ {
+ reader = new AUD_FaderReader(reader, m_type, m_start, m_length);
+ AUD_NEW("reader")
+ }
+
+ return reader;
+}
diff --git a/intern/audaspace/FX/AUD_FaderFactory.h b/intern/audaspace/FX/AUD_FaderFactory.h
new file mode 100644
index 00000000000..4999ccac8f1
--- /dev/null
+++ b/intern/audaspace/FX/AUD_FaderFactory.h
@@ -0,0 +1,111 @@
+/*
+ * $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_FADERFACTORY
+#define AUD_FADERFACTORY
+
+#include "AUD_EffectFactory.h"
+
+/**
+ * This factory fades another factory.
+ * If the fading type is AUD_FADE_IN, everything before the fading start will be
+ * silenced, for AUD_FADE_OUT that's true for everything after fading ends.
+ */
+class AUD_FaderFactory : public AUD_EffectFactory
+{
+private:
+ /**
+ * The fading type.
+ */
+ AUD_FadeType m_type;
+
+ /**
+ * The fading start.
+ */
+ float m_start;
+
+ /**
+ * The fading length.
+ */
+ float m_length;
+
+public:
+ /**
+ * Creates a new fader factory.
+ * \param factory The input factory.
+ * \param type The fading type.
+ * \param start The time where fading should start in seconds.
+ * \param length How long fading should last in seconds.
+ */
+ AUD_FaderFactory(AUD_IFactory* factory = 0,
+ AUD_FadeType type = AUD_FADE_IN,
+ float start = 0.0f, float length = 1.0f);
+
+ /**
+ * Creates a new fader factory.
+ * \param type The fading type.
+ * \param start The time where fading should start in seconds.
+ * \param length How long fading should last in seconds.
+ */
+ AUD_FaderFactory(AUD_FadeType type = AUD_FADE_IN,
+ float start = 0.0f, float length = 1.0f);
+
+ /**
+ * Returns the fading type.
+ */
+ AUD_FadeType getType();
+
+ /**
+ * Sets the fading type.
+ * \param type The new fading type: AUD_FADE_IN or AUD_FADE_OUT.
+ */
+ void setType(AUD_FadeType type);
+
+ /**
+ * Returns the fading start.
+ */
+ float getStart();
+
+ /**
+ * Sets the fading start.
+ * \param start The new fading start.
+ */
+ void setStart(float start);
+
+ /**
+ * Returns the fading length.
+ */
+ float getLength();
+
+ /**
+ * Sets the fading length.
+ * \param start The new fading length.
+ */
+ void setLength(float length);
+
+ virtual AUD_IReader* createReader();
+};
+
+#endif //AUD_FADERFACTORY
diff --git a/intern/audaspace/FX/AUD_FaderReader.cpp b/intern/audaspace/FX/AUD_FaderReader.cpp
new file mode 100644
index 00000000000..d5096e7fae1
--- /dev/null
+++ b/intern/audaspace/FX/AUD_FaderReader.cpp
@@ -0,0 +1,133 @@
+/*
+ * $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_FaderReader.h"
+#include "AUD_Buffer.h"
+
+#include <cstring>
+
+AUD_FaderReader::AUD_FaderReader(AUD_IReader* reader, AUD_FadeType type,
+ float start,float length) :
+ AUD_EffectReader(reader),
+ m_type(type),
+ m_start(start),
+ m_length(length)
+{
+ int bigendian = 1;
+ bigendian = (((char*)&bigendian)[0]) ? 0: 1; // 1 if Big Endian
+
+ switch(m_reader->getSpecs().format)
+ {
+ case AUD_FORMAT_S16:
+ m_adjust = AUD_volume_adjust<int16_t>;
+ break;
+ case AUD_FORMAT_S32:
+ m_adjust = AUD_volume_adjust<int32_t>;
+ break;
+ case AUD_FORMAT_FLOAT32:
+ m_adjust = AUD_volume_adjust<float>;
+ break;
+ case AUD_FORMAT_FLOAT64:
+ m_adjust = AUD_volume_adjust<double>;
+ break;
+ case AUD_FORMAT_U8:
+ m_adjust = AUD_volume_adjust_u8;
+ break;
+ case AUD_FORMAT_S24:
+ m_adjust = bigendian ? AUD_volume_adjust_s24_be :
+ AUD_volume_adjust_s24_le;
+ break;
+ default:
+ delete m_reader;
+ AUD_THROW(AUD_ERROR_READER);
+ }
+
+ m_buffer = new AUD_Buffer(); AUD_NEW("buffer")
+}
+
+AUD_FaderReader::~AUD_FaderReader()
+{
+ delete m_buffer; AUD_DELETE("buffer")
+}
+
+bool AUD_FaderReader::notify(AUD_Message &message)
+{
+ return m_reader->notify(message);
+}
+
+void AUD_FaderReader::read(int & length, sample_t* & buffer)
+{
+ int position = m_reader->getPosition();
+ AUD_Specs specs = m_reader->getSpecs();
+ int samplesize = AUD_SAMPLE_SIZE(specs);
+
+ m_reader->read(length, buffer);
+
+ if(m_buffer->getSize() < length * samplesize)
+ m_buffer->resize(length * samplesize);
+
+ if((position + length) / (float)specs.rate <= m_start)
+ {
+ if(m_type != AUD_FADE_OUT)
+ {
+ buffer = m_buffer->getBuffer();
+ memset(buffer,
+ specs.format == AUD_FORMAT_U8 ? 0x80 : 0,
+ length * samplesize);
+ }
+ }
+ else if(position / (float)specs.rate >= m_start+m_length)
+ {
+ if(m_type == AUD_FADE_OUT)
+ {
+ buffer = m_buffer->getBuffer();
+ memset(buffer,
+ specs.format == AUD_FORMAT_U8 ? 0x80 : 0,
+ length * samplesize);
+ }
+ }
+ else
+ {
+ sample_t* buf = m_buffer->getBuffer();
+ float volume;
+
+ for(int i = 0; i < length; i++)
+ {
+ volume = (((position+i)/(float)specs.rate)-m_start) / m_length;
+ if(volume > 1.0f)
+ volume = 1.0f;
+ else if(volume < 0.0f)
+ volume = 0.0f;
+
+ if(m_type == AUD_FADE_OUT)
+ volume = 1.0f - volume;
+
+ m_adjust(buf + i * samplesize, buffer + i * samplesize,
+ specs.channels, volume);
+ }
+
+ buffer = buf;
+ }
+}
diff --git a/intern/audaspace/FX/AUD_FaderReader.h b/intern/audaspace/FX/AUD_FaderReader.h
new file mode 100644
index 00000000000..773643b2f5d
--- /dev/null
+++ b/intern/audaspace/FX/AUD_FaderReader.h
@@ -0,0 +1,86 @@
+/*
+ * $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_FADERREADER
+#define AUD_FADERREADER
+
+#include "AUD_EffectReader.h"
+#include "AUD_ConverterFunctions.h"
+class AUD_Buffer;
+
+/**
+ * This class fades another reader.
+ * If the fading type is AUD_FADE_IN, everything before the fading start will be
+ * silenced, for AUD_FADE_OUT that's true for everything after fading ends.
+ */
+class AUD_FaderReader : public AUD_EffectReader
+{
+private:
+ /**
+ * The playback buffer.
+ */
+ AUD_Buffer *m_buffer;
+
+ /**
+ * The fading type.
+ */
+ AUD_FadeType m_type;
+
+ /**
+ * The fading start.
+ */
+ float m_start;
+
+ /**
+ * The fading length.
+ */
+ float m_length;
+
+ /**
+ * Volume adjustment function.
+ */
+ AUD_volume_adjust_f m_adjust;
+
+public:
+ /**
+ * Creates a new fader reader.
+ * \param type The fading type.
+ * \param start The time where fading should start in seconds.
+ * \param length How long fading should last in seconds.
+ * \exception AUD_Exception Thrown if the reader specified is NULL.
+ */
+ AUD_FaderReader(AUD_IReader* reader, AUD_FadeType type,
+ float start,float length);
+
+ /**
+ * Destroys the reader.
+ */
+ virtual ~AUD_FaderReader();
+
+ virtual bool notify(AUD_Message &message);
+ virtual void read(int & length, sample_t* & buffer);
+};
+
+#endif //AUD_FADERREADER
diff --git a/intern/audaspace/FX/AUD_LimiterFactory.cpp b/intern/audaspace/FX/AUD_LimiterFactory.cpp
new file mode 100644
index 00000000000..6f19575240a
--- /dev/null
+++ b/intern/audaspace/FX/AUD_LimiterFactory.cpp
@@ -0,0 +1,67 @@
+/*
+ * $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_LimiterFactory.h"
+#include "AUD_LimiterReader.h"
+#include "AUD_Space.h"
+
+AUD_LimiterFactory::AUD_LimiterFactory(AUD_IFactory* factory,
+ float start, float end) :
+ AUD_EffectFactory(factory),
+ m_start(start),
+ m_end(end) {}
+
+float AUD_LimiterFactory::getStart()
+{
+ return m_start;
+}
+
+void AUD_LimiterFactory::setStart(float start)
+{
+ m_start = start;
+}
+
+float AUD_LimiterFactory::getEnd()
+{
+ return m_end;
+}
+
+void AUD_LimiterFactory::setEnd(float end)
+{
+ m_end = end;
+}
+
+AUD_IReader* AUD_LimiterFactory::createReader()
+{
+ AUD_IReader* reader = getReader();
+
+ if(reader != 0)
+ {
+ reader = new AUD_LimiterReader(reader, m_start, m_end);
+ AUD_NEW("reader")
+ }
+
+ return reader;
+}
diff --git a/intern/audaspace/FX/AUD_LimiterFactory.h b/intern/audaspace/FX/AUD_LimiterFactory.h
new file mode 100644
index 00000000000..588fea6eb4b
--- /dev/null
+++ b/intern/audaspace/FX/AUD_LimiterFactory.h
@@ -0,0 +1,84 @@
+/*
+ * $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_LIMITERFACTORY
+#define AUD_LIMITERFACTORY
+
+#include "AUD_EffectFactory.h"
+
+/**
+ * This factory limits another factory in start and end time.
+ */
+class AUD_LimiterFactory : public AUD_EffectFactory
+{
+private:
+ /**
+ * The start time.
+ */
+ float m_start;
+
+ /**
+ * The end time.
+ */
+ float m_end;
+
+public:
+ /**
+ * Creates a new limiter factory.
+ * \param factory The input factory.
+ * \param start The desired start time.
+ * \param end The desired end time, a negative value signals that it should
+ * play to the end.
+ */
+ AUD_LimiterFactory(AUD_IFactory* factory = 0,
+ float start = 0, float end = -1);
+
+ /**
+ * Returns the start time.
+ */
+ float getStart();
+
+ /**
+ * Sets the start time.
+ * \param start The new start time.
+ */
+ void setStart(float start);
+
+ /**
+ * Returns the end time.
+ */
+ float getEnd();
+
+ /**
+ * Sets the end time.
+ * \param end The new end time, a negative value signals that it should play
+ * to the end.
+ */
+ void setEnd(float end);
+
+ virtual AUD_IReader* createReader();
+};
+
+#endif //AUD_LIMITERFACTORY
diff --git a/intern/audaspace/FX/AUD_LimiterReader.cpp b/intern/audaspace/FX/AUD_LimiterReader.cpp
new file mode 100644
index 00000000000..05882369001
--- /dev/null
+++ b/intern/audaspace/FX/AUD_LimiterReader.cpp
@@ -0,0 +1,95 @@
+/*
+ * $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_LimiterReader.h"
+#include "AUD_Buffer.h"
+
+#include <iostream>
+
+AUD_LimiterReader::AUD_LimiterReader(AUD_IReader* reader,
+ float start, float end) :
+ AUD_EffectReader(reader)
+{
+ m_end = (int)(end * reader->getSpecs().rate);
+
+ if(start <= 0)
+ m_start = 0;
+ else
+ {
+ m_start = (int)(start * reader->getSpecs().rate);
+ if(m_reader->isSeekable())
+ m_reader->seek(m_start);
+ else
+ {
+ // skip first m_start samples by reading them
+ int length;
+ sample_t* buffer;
+ for(int i = m_start;
+ i >= AUD_DEFAULT_BUFFER_SIZE;
+ i -= AUD_DEFAULT_BUFFER_SIZE)
+ {
+ length = AUD_DEFAULT_BUFFER_SIZE;
+ m_reader->read(length, buffer);
+ length = i;
+ }
+ m_reader->read(length, buffer);
+ }
+ }
+}
+
+void AUD_LimiterReader::seek(int position)
+{
+ m_reader->seek(position + m_start);
+}
+
+int AUD_LimiterReader::getLength()
+{
+ int len = m_reader->getLength();
+ if(m_reader->getType() != AUD_TYPE_BUFFER || len < 0 ||
+ (len > m_end && m_end >= 0))
+ len = m_end;
+ return len - m_start;
+}
+
+int AUD_LimiterReader::getPosition()
+{
+ return m_reader->getPosition() - m_start;
+}
+
+void AUD_LimiterReader::read(int & length, sample_t* & buffer)
+{
+ if(m_end >= 0)
+ {
+ int position = m_reader->getPosition();
+ if(position+length > m_end)
+ length = m_end - position;
+ if(length < 0)
+ {
+ length = 0;
+ return;
+ }
+ }
+ m_reader->read(length, buffer);
+}
diff --git a/intern/audaspace/FX/AUD_LimiterReader.h b/intern/audaspace/FX/AUD_LimiterReader.h
new file mode 100644
index 00000000000..9921f5ee1b0
--- /dev/null
+++ b/intern/audaspace/FX/AUD_LimiterReader.h
@@ -0,0 +1,64 @@
+/*
+ * $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_LIMITERREADER
+#define AUD_LIMITERREADER
+
+#include "AUD_EffectReader.h"
+
+/**
+ * This reader limits another reader in start and end sample.
+ */
+class AUD_LimiterReader : public AUD_EffectReader
+{
+private:
+ /**
+ * The start sample: inclusive.
+ */
+ int m_start;
+
+ /**
+ * The end sample: exlusive.
+ */
+ int m_end;
+
+public:
+ /**
+ * Creates a new limiter reader.
+ * \param reader The reader to read from.
+ * \param start The desired start sample (inclusive).
+ * \param end The desired end sample (exklusive), a negative value signals
+ * that it should play to the end.
+ * \exception AUD_Exception Thrown if the reader specified is NULL.
+ */
+ AUD_LimiterReader(AUD_IReader* reader, float start = 0, float end = -1);
+
+ virtual void seek(int position);
+ virtual int getLength();
+ virtual int getPosition();
+ virtual void read(int & length, sample_t* & buffer);
+};
+
+#endif //AUD_LIMITERREADER
diff --git a/intern/audaspace/FX/AUD_LoopFactory.cpp b/intern/audaspace/FX/AUD_LoopFactory.cpp
new file mode 100644
index 00000000000..90186f623ff
--- /dev/null
+++ b/intern/audaspace/FX/AUD_LoopFactory.cpp
@@ -0,0 +1,57 @@
+/*
+ * $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_LoopFactory.h"
+#include "AUD_LoopReader.h"
+
+AUD_LoopFactory::AUD_LoopFactory(AUD_IFactory* factory, int loop) :
+ AUD_EffectFactory(factory),
+ m_loop(loop) {}
+
+AUD_LoopFactory::AUD_LoopFactory(int loop) :
+ AUD_EffectFactory(0),
+ m_loop(loop) {}
+
+int AUD_LoopFactory::getLoop()
+{
+ return m_loop;
+}
+
+void AUD_LoopFactory::setLoop(int loop)
+{
+ m_loop = loop;
+}
+
+AUD_IReader* AUD_LoopFactory::createReader()
+{
+ AUD_IReader* reader = getReader();
+
+ if(reader != 0)
+ {
+ reader = new AUD_LoopReader(reader, m_loop); AUD_NEW("reader")
+ }
+
+ return reader;
+}
diff --git a/intern/audaspace/FX/AUD_LoopFactory.h b/intern/audaspace/FX/AUD_LoopFactory.h
new file mode 100644
index 00000000000..461d8c9ab69
--- /dev/null
+++ b/intern/audaspace/FX/AUD_LoopFactory.h
@@ -0,0 +1,74 @@
+/*
+ * $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_LOOPFACTORY
+#define AUD_LOOPFACTORY
+
+#include "AUD_EffectFactory.h"
+
+/**
+ * This factory loops another factory.
+ * \note The reader has to be seekable.
+ */
+class AUD_LoopFactory : public AUD_EffectFactory
+{
+private:
+ /**
+ * The loop count.
+ */
+ float m_loop;
+
+public:
+ /**
+ * Creates a new loop factory.
+ * \param factory The input factory.
+ * \param loop The desired loop count, negative values result in endless
+ * looping.
+ */
+ AUD_LoopFactory(AUD_IFactory* factory = 0, int loop = -1);
+
+ /**
+ * Creates a new loop factory.
+ * \param loop The desired loop count, negative values result in endless
+ * looping.
+ */
+ AUD_LoopFactory(int loop);
+
+ /**
+ * Returns the loop count.
+ */
+ int getLoop();
+
+ /**
+ * Sets the loop count.
+ * \param loop The desired loop count, negative values result in endless
+ * looping.
+ */
+ void setLoop(int loop);
+
+ virtual AUD_IReader* createReader();
+};
+
+#endif //AUD_LOOPFACTORY
diff --git a/intern/audaspace/FX/AUD_LoopReader.cpp b/intern/audaspace/FX/AUD_LoopReader.cpp
new file mode 100644
index 00000000000..9e270321013
--- /dev/null
+++ b/intern/audaspace/FX/AUD_LoopReader.cpp
@@ -0,0 +1,107 @@
+/*
+ * $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_LoopReader.h"
+#include "AUD_Buffer.h"
+
+#include <cstring>
+#include <stdio.h>
+
+AUD_LoopReader::AUD_LoopReader(AUD_IReader* reader, int loop) :
+ AUD_EffectReader(reader), m_loop(loop)
+{
+ m_buffer = new AUD_Buffer(); AUD_NEW("buffer")
+}
+
+AUD_LoopReader::~AUD_LoopReader()
+{
+ delete m_buffer; AUD_DELETE("buffer")
+}
+
+AUD_ReaderType AUD_LoopReader::getType()
+{
+ if(m_loop < 0)
+ return AUD_TYPE_STREAM;
+ return m_reader->getType();
+}
+
+bool AUD_LoopReader::notify(AUD_Message &message)
+{
+ if(message.type == AUD_MSG_LOOP)
+ {
+ m_loop = message.loopcount;
+
+ m_reader->notify(message);
+
+ return true;
+ }
+ return m_reader->notify(message);
+}
+
+void AUD_LoopReader::read(int & length, sample_t* & buffer)
+{
+ int samplesize = AUD_SAMPLE_SIZE(m_reader->getSpecs());
+
+ int len = length;
+
+ m_reader->read(len, buffer);
+
+ if(len < length && m_loop != 0)
+ {
+ int pos = 0;
+
+ if(m_buffer->getSize() < length*samplesize)
+ m_buffer->resize(length*samplesize);
+
+ memcpy(m_buffer->getBuffer() + pos * samplesize,
+ buffer, len * samplesize);
+
+ pos += len;
+
+ while(pos < length && m_loop != 0)
+ {
+ if(m_loop > 0)
+ m_loop--;
+
+ m_reader->seek(0);
+
+ len = length - pos;
+ m_reader->read(len, buffer);
+ // prevent endless loop
+ if(!len)
+ break;
+
+ memcpy(m_buffer->getBuffer() + pos * samplesize,
+ buffer, len * samplesize);
+
+ pos += len;
+ }
+
+ length = pos;
+ buffer = m_buffer->getBuffer();
+ }
+ else
+ length = len;
+}
diff --git a/intern/audaspace/FX/AUD_LoopReader.h b/intern/audaspace/FX/AUD_LoopReader.h
new file mode 100644
index 00000000000..621ee3493ab
--- /dev/null
+++ b/intern/audaspace/FX/AUD_LoopReader.h
@@ -0,0 +1,69 @@
+/*
+ * $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_LOOPREADER
+#define AUD_LOOPREADER
+
+#include "AUD_EffectReader.h"
+class AUD_Buffer;
+
+/**
+ * This class reads another reader and loops it.
+ * \note The other reader must be seekable.
+ */
+class AUD_LoopReader : public AUD_EffectReader
+{
+private:
+ /**
+ * The playback buffer.
+ */
+ AUD_Buffer *m_buffer;
+
+ /**
+ * The left loop count.
+ */
+ int m_loop;
+
+public:
+ /**
+ * Creates a new loop reader.
+ * \param reader The reader to read from.
+ * \param loop The desired loop count, negative values result in endless
+ * looping.
+ * \exception AUD_Exception Thrown if the reader specified is NULL.
+ */
+ AUD_LoopReader(AUD_IReader* reader, int loop);
+
+ /**
+ * Destroys the reader.
+ */
+ virtual ~AUD_LoopReader();
+
+ virtual AUD_ReaderType getType();
+ virtual bool notify(AUD_Message &message);
+ virtual void read(int & length, sample_t* & buffer);
+};
+
+#endif //AUD_LOOPREADER
diff --git a/intern/audaspace/FX/AUD_PingPongFactory.cpp b/intern/audaspace/FX/AUD_PingPongFactory.cpp
new file mode 100644
index 00000000000..a030d581b1a
--- /dev/null
+++ b/intern/audaspace/FX/AUD_PingPongFactory.cpp
@@ -0,0 +1,67 @@
+/*
+ * $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_PingPongFactory.h"
+#include "AUD_DoubleReader.h"
+#include "AUD_ReverseFactory.h"
+
+AUD_PingPongFactory::AUD_PingPongFactory(AUD_IFactory* factory) :
+ AUD_EffectFactory(factory) {}
+
+AUD_IReader* AUD_PingPongFactory::createReader()
+{
+ if(m_factory == 0)
+ return 0;
+
+ AUD_IReader* reader = m_factory->createReader();
+
+ if(reader != 0)
+ {
+ AUD_IReader* reader2;
+ AUD_ReverseFactory factory(m_factory);
+
+ try
+ {
+ reader2 = factory.createReader();
+ }
+ catch(AUD_Exception e)
+ {
+ reader2 = 0;
+ }
+
+ if(reader2 != 0)
+ {
+ reader = new AUD_DoubleReader(reader, reader2);
+ AUD_NEW("reader")
+ }
+ else
+ {
+ delete reader; AUD_DELETE("reader")
+ reader = 0;
+ }
+ }
+
+ return reader;
+}
diff --git a/intern/audaspace/FX/AUD_PingPongFactory.h b/intern/audaspace/FX/AUD_PingPongFactory.h
new file mode 100644
index 00000000000..b8854da550a
--- /dev/null
+++ b/intern/audaspace/FX/AUD_PingPongFactory.h
@@ -0,0 +1,51 @@
+/*
+ * $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_PINGPONGFACTORY
+#define AUD_PINGPONGFACTORY
+
+#include "AUD_EffectFactory.h"
+
+/**
+ * This factory plays another factory first normal, then reversed.
+ * \note Readers from the underlying factory must be from the buffer type.
+ */
+class AUD_PingPongFactory : public AUD_EffectFactory
+{
+public:
+ /**
+ * Creates a new ping pong factory.
+ * \param factory The input factory.
+ */
+ AUD_PingPongFactory(AUD_IFactory* factory = 0);
+
+ /**
+ * Destroys the factory.
+ */
+
+ virtual AUD_IReader* createReader();
+};
+
+#endif //AUD_PINGPONGFACTORY
diff --git a/intern/audaspace/FX/AUD_PitchFactory.cpp b/intern/audaspace/FX/AUD_PitchFactory.cpp
new file mode 100644
index 00000000000..5f814283c12
--- /dev/null
+++ b/intern/audaspace/FX/AUD_PitchFactory.cpp
@@ -0,0 +1,48 @@
+/*
+ * $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_PitchFactory.h"
+#include "AUD_PitchReader.h"
+#include "AUD_Space.h"
+
+AUD_PitchFactory::AUD_PitchFactory(AUD_IFactory* factory, float pitch) :
+ AUD_EffectFactory(factory),
+ m_pitch(pitch) {}
+
+AUD_PitchFactory::AUD_PitchFactory(float pitch) :
+ AUD_EffectFactory(0),
+ m_pitch(pitch) {}
+
+AUD_IReader* AUD_PitchFactory::createReader()
+{
+ AUD_IReader* reader = getReader();
+
+ if(reader != 0)
+ {
+ reader = new AUD_PitchReader(reader, m_pitch); AUD_NEW("reader")
+ }
+
+ return reader;
+}
diff --git a/intern/audaspace/FX/AUD_PitchFactory.h b/intern/audaspace/FX/AUD_PitchFactory.h
new file mode 100644
index 00000000000..3209aa46983
--- /dev/null
+++ b/intern/audaspace/FX/AUD_PitchFactory.h
@@ -0,0 +1,70 @@
+/*
+ * $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_PITCHFACTORY
+#define AUD_PITCHFACTORY
+
+#include "AUD_EffectFactory.h"
+
+/**
+ * This factory changes the pitch of another factory.
+ */
+class AUD_PitchFactory : public AUD_EffectFactory
+{
+private:
+ /**
+ * The pitch.
+ */
+ float m_pitch;
+
+public:
+ /**
+ * Creates a new pitch factory.
+ * \param factory The input factory.
+ * \param pitch The desired pitch.
+ */
+ AUD_PitchFactory(AUD_IFactory* factory = 0, float pitch = 1.0);
+
+ /**
+ * Creates a new pitch factory.
+ * \param pitch The desired pitch.
+ */
+ AUD_PitchFactory(float pitch);
+
+ /**
+ * Returns the pitch.
+ */
+ float getPitch();
+
+ /**
+ * Sets the pitch.
+ * \param pitch The new pitch value. Should be between 0.0 and 1.0.
+ */
+ void setPitch(float pitch);
+
+ virtual AUD_IReader* createReader();
+};
+
+#endif //AUD_PITCHFACTORY
diff --git a/intern/audaspace/FX/AUD_PitchReader.cpp b/intern/audaspace/FX/AUD_PitchReader.cpp
new file mode 100644
index 00000000000..c53264e1350
--- /dev/null
+++ b/intern/audaspace/FX/AUD_PitchReader.cpp
@@ -0,0 +1,39 @@
+/*
+ * $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_PitchReader.h"
+
+AUD_PitchReader::AUD_PitchReader(AUD_IReader* reader, float pitch) :
+ AUD_EffectReader(reader)
+{
+ m_pitch = pitch;
+}
+
+AUD_Specs AUD_PitchReader::getSpecs()
+{
+ AUD_Specs specs = m_reader->getSpecs();
+ specs.rate = (AUD_SampleRate)((int)(specs.rate * m_pitch));
+ return specs;
+}
diff --git a/intern/audaspace/FX/AUD_PitchReader.h b/intern/audaspace/FX/AUD_PitchReader.h
new file mode 100644
index 00000000000..440e9cc843c
--- /dev/null
+++ b/intern/audaspace/FX/AUD_PitchReader.h
@@ -0,0 +1,54 @@
+/*
+ * $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_PITCHREADER
+#define AUD_PITCHREADER
+
+#include "AUD_EffectReader.h"
+
+/**
+ * This class reads another reader and changes it's pitch.
+ */
+class AUD_PitchReader : public AUD_EffectReader
+{
+private:
+ /**
+ * The pitch level.
+ */
+ float m_pitch;
+
+public:
+ /**
+ * Creates a new pitch reader.
+ * \param reader The reader to read from.
+ * \param pitch The size of the buffer.
+ * \exception AUD_Exception Thrown if the reader specified is NULL.
+ */
+ AUD_PitchReader(AUD_IReader* reader, float pitch);
+
+ virtual AUD_Specs getSpecs();
+};
+
+#endif //AUD_PITCHREADER
diff --git a/intern/audaspace/FX/AUD_ReverseFactory.cpp b/intern/audaspace/FX/AUD_ReverseFactory.cpp
new file mode 100644
index 00000000000..1242641c350
--- /dev/null
+++ b/intern/audaspace/FX/AUD_ReverseFactory.cpp
@@ -0,0 +1,43 @@
+/*
+ * $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_ReverseFactory.h"
+#include "AUD_ReverseReader.h"
+#include "AUD_Space.h"
+
+AUD_ReverseFactory::AUD_ReverseFactory(AUD_IFactory* factory) :
+ AUD_EffectFactory(factory) {}
+
+AUD_IReader* AUD_ReverseFactory::createReader()
+{
+ AUD_IReader* reader = getReader();
+
+ if(reader != 0)
+ {
+ reader = new AUD_ReverseReader(reader); AUD_NEW("reader")
+ }
+
+ return reader;
+}
diff --git a/intern/audaspace/FX/AUD_ReverseFactory.h b/intern/audaspace/FX/AUD_ReverseFactory.h
new file mode 100644
index 00000000000..4b664c47281
--- /dev/null
+++ b/intern/audaspace/FX/AUD_ReverseFactory.h
@@ -0,0 +1,50 @@
+/*
+ * $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_REVERSEFACTORY
+#define AUD_REVERSEFACTORY
+
+#include "AUD_EffectFactory.h"
+
+/**
+ * This factory reads another factory reverted.
+ * \note Readers from the underlying factory must be from the buffer type.
+ */
+class AUD_ReverseFactory : public AUD_EffectFactory
+{
+public:
+ /**
+ * Creates a new reverse factory.
+ * \param factory The input factory.
+ */
+ AUD_ReverseFactory(AUD_IFactory* factory = 0);
+
+ /**
+ * Destroys the factory.
+ */
+ virtual AUD_IReader* createReader();
+};
+
+#endif //AUD_REVERSEFACTORY
diff --git a/intern/audaspace/FX/AUD_ReverseReader.cpp b/intern/audaspace/FX/AUD_ReverseReader.cpp
new file mode 100644
index 00000000000..043480b91b9
--- /dev/null
+++ b/intern/audaspace/FX/AUD_ReverseReader.cpp
@@ -0,0 +1,111 @@
+/*
+ * $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_ReverseReader.h"
+#include "AUD_Buffer.h"
+
+#include <cstring>
+
+AUD_ReverseReader::AUD_ReverseReader(AUD_IReader* reader) :
+ AUD_EffectReader(reader)
+{
+ if(reader->getType() != AUD_TYPE_BUFFER)
+ AUD_THROW(AUD_ERROR_READER);
+
+ m_length = reader->getLength();
+ if(m_length < 0)
+ AUD_THROW(AUD_ERROR_READER);
+
+ m_position = 0;
+ m_buffer = new AUD_Buffer(); AUD_NEW("buffer")
+}
+
+AUD_ReverseReader::~AUD_ReverseReader()
+{
+ delete m_buffer; AUD_DELETE("buffer")
+}
+
+void AUD_ReverseReader::seek(int position)
+{
+ m_position = position;
+}
+
+int AUD_ReverseReader::getLength()
+{
+ return m_length;
+}
+
+int AUD_ReverseReader::getPosition()
+{
+ return m_position;
+}
+
+void AUD_ReverseReader::read(int & length, sample_t* & buffer)
+{
+ // first correct the length
+ if(m_position+length > m_length)
+ length = m_length-m_position;
+
+ if(length <= 0)
+ {
+ length = 0;
+ return;
+ }
+
+ int samplesize = AUD_SAMPLE_SIZE(getSpecs());
+
+ // resize buffer if needed
+ if(m_buffer->getSize() < length * samplesize)
+ m_buffer->resize(length * samplesize);
+
+ buffer = m_buffer->getBuffer();
+
+ sample_t* buf;
+ int len = length;
+
+ // read from reader
+ m_reader->seek(m_length-m_position-len);
+ m_reader->read(len, buf);
+
+ // set null if reader didn't give enough data
+ if(len < length)
+ {
+ if(getSpecs().format == AUD_FORMAT_U8)
+ memset(buffer, 0x80, (length-len)*samplesize);
+ else
+ memset(buffer, 0, (length-len)*samplesize);
+ buffer += length-len;
+ }
+
+ // copy the samples reverted
+ for(int i = 0; i < len; i++)
+ memcpy(buffer + i * samplesize,
+ buf + (len - 1 - i) * samplesize,
+ samplesize);
+
+ m_position += length;
+
+ buffer = m_buffer->getBuffer();
+}
diff --git a/intern/audaspace/FX/AUD_ReverseReader.h b/intern/audaspace/FX/AUD_ReverseReader.h
new file mode 100644
index 00000000000..045d2ac5a8e
--- /dev/null
+++ b/intern/audaspace/FX/AUD_ReverseReader.h
@@ -0,0 +1,74 @@
+/*
+ * $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_REVERSEREADER
+#define AUD_REVERSEREADER
+
+#include "AUD_EffectReader.h"
+class AUD_Buffer;
+
+/**
+ * This class reads another reader from back to front.
+ * \note The underlying reader must be a buffer.
+ */
+class AUD_ReverseReader : public AUD_EffectReader
+{
+private:
+ /**
+ * The current position.
+ */
+ int m_position;
+
+ /**
+ * The sample count.
+ */
+ int m_length;
+
+ /**
+ * The playback buffer.
+ */
+ AUD_Buffer* m_buffer;
+
+public:
+ /**
+ * Creates a new reverse reader.
+ * \param reader The reader to read from.
+ * \exception AUD_Exception Thrown if the reader specified is NULL or not
+ * a buffer.
+ */
+ AUD_ReverseReader(AUD_IReader* reader);
+
+ /**
+ * Destroys the reader.
+ */
+ virtual ~AUD_ReverseReader();
+
+ virtual void seek(int position);
+ virtual int getLength();
+ virtual int getPosition();
+ virtual void read(int & length, sample_t* & buffer);
+};
+
+#endif //AUD_REVERSEREADER
diff --git a/intern/audaspace/FX/AUD_VolumeFactory.cpp b/intern/audaspace/FX/AUD_VolumeFactory.cpp
new file mode 100644
index 00000000000..fbde608aa12
--- /dev/null
+++ b/intern/audaspace/FX/AUD_VolumeFactory.cpp
@@ -0,0 +1,57 @@
+/*
+ * $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_VolumeFactory.h"
+#include "AUD_VolumeReader.h"
+
+AUD_VolumeFactory::AUD_VolumeFactory(AUD_IFactory* factory, float volume) :
+ AUD_EffectFactory(factory),
+ m_volume(volume) {}
+
+AUD_VolumeFactory::AUD_VolumeFactory(float volume) :
+ AUD_EffectFactory(0),
+ m_volume(volume) {}
+
+float AUD_VolumeFactory::getVolume()
+{
+ return m_volume;
+}
+
+void AUD_VolumeFactory::setVolume(float volume)
+{
+ m_volume = volume;
+}
+
+AUD_IReader* AUD_VolumeFactory::createReader()
+{
+ AUD_IReader* reader = getReader();
+
+ if(reader != 0)
+ {
+ reader = new AUD_VolumeReader(reader, m_volume); AUD_NEW("reader")
+ }
+
+ return reader;
+}
diff --git a/intern/audaspace/FX/AUD_VolumeFactory.h b/intern/audaspace/FX/AUD_VolumeFactory.h
new file mode 100644
index 00000000000..d2812536d83
--- /dev/null
+++ b/intern/audaspace/FX/AUD_VolumeFactory.h
@@ -0,0 +1,72 @@
+/*
+ * $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_VOLUMEFACTORY
+#define AUD_VOLUMEFACTORY
+
+#include "AUD_EffectFactory.h"
+
+/**
+ * This factory changes the volume of another factory.
+ * The set volume should be a value between 0.0 and 1.0, higher values at your
+ * own risk!
+ */
+class AUD_VolumeFactory : public AUD_EffectFactory
+{
+private:
+ /**
+ * The volume.
+ */
+ float m_volume;
+
+public:
+ /**
+ * Creates a new volume factory.
+ * \param factory The input factory.
+ * \param volume The desired volume.
+ */
+ AUD_VolumeFactory(AUD_IFactory* factory = 0, float volume = 1.0);
+
+ /**
+ * Creates a new volume factory.
+ * \param volume The desired volume.
+ */
+ AUD_VolumeFactory(float volume);
+
+ /**
+ * Returns the volume.
+ */
+ float getVolume();
+
+ /**
+ * Sets the volume.
+ * \param volume The new volume value. Should be between 0.0 and 1.0.
+ */
+ void setVolume(float volume);
+
+ virtual AUD_IReader* createReader();
+};
+
+#endif //AUD_VOLUMEFACTORY
diff --git a/intern/audaspace/FX/AUD_VolumeReader.cpp b/intern/audaspace/FX/AUD_VolumeReader.cpp
new file mode 100644
index 00000000000..fc3f20152a6
--- /dev/null
+++ b/intern/audaspace/FX/AUD_VolumeReader.cpp
@@ -0,0 +1,97 @@
+/*
+ * $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_VolumeReader.h"
+#include "AUD_Buffer.h"
+
+#include <cstring>
+
+AUD_VolumeReader::AUD_VolumeReader(AUD_IReader* reader, float volume) :
+ AUD_EffectReader(reader),
+ m_volume(volume)
+{
+ int bigendian = 1;
+ bigendian = (((char*)&bigendian)[0]) ? 0: 1; // 1 if Big Endian
+
+ switch(m_reader->getSpecs().format)
+ {
+ case AUD_FORMAT_S16:
+ m_adjust = AUD_volume_adjust<int16_t>;
+ break;
+ case AUD_FORMAT_S32:
+ m_adjust = AUD_volume_adjust<int32_t>;
+ break;
+ case AUD_FORMAT_FLOAT32:
+ m_adjust = AUD_volume_adjust<float>;
+ break;
+ case AUD_FORMAT_FLOAT64:
+ m_adjust = AUD_volume_adjust<double>;
+ break;
+ case AUD_FORMAT_U8:
+ m_adjust = AUD_volume_adjust_u8;
+ break;
+ case AUD_FORMAT_S24:
+ m_adjust = bigendian ? AUD_volume_adjust_s24_be :
+ AUD_volume_adjust_s24_le;
+ break;
+ default:
+ delete m_reader;
+ AUD_THROW(AUD_ERROR_READER);
+ }
+
+ m_buffer = new AUD_Buffer(); AUD_NEW("buffer")
+}
+
+AUD_VolumeReader::~AUD_VolumeReader()
+{
+ delete m_buffer; AUD_DELETE("buffer")
+}
+
+bool AUD_VolumeReader::notify(AUD_Message &message)
+{
+ if(message.type == AUD_MSG_VOLUME)
+ {
+ m_volume = message.volume;
+
+ m_reader->notify(message);
+
+ return true;
+ }
+ return m_reader->notify(message);
+}
+
+void AUD_VolumeReader::read(int & length, sample_t* & buffer)
+{
+ sample_t* buf;
+ 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();
+
+ m_adjust(buffer, buf, length * specs.channels, m_volume);
+}
diff --git a/intern/audaspace/FX/AUD_VolumeReader.h b/intern/audaspace/FX/AUD_VolumeReader.h
new file mode 100644
index 00000000000..f38ae4d265c
--- /dev/null
+++ b/intern/audaspace/FX/AUD_VolumeReader.h
@@ -0,0 +1,72 @@
+/*
+ * $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_VOLUMEREADER
+#define AUD_VOLUMEREADER
+
+#include "AUD_EffectReader.h"
+#include "AUD_ConverterFunctions.h"
+class AUD_Buffer;
+
+/**
+ * This class reads another reader and changes it's volume.
+ */
+class AUD_VolumeReader : public AUD_EffectReader
+{
+private:
+ /**
+ * The playback buffer.
+ */
+ AUD_Buffer *m_buffer;
+
+ /**
+ * The volume level.
+ */
+ float m_volume;
+
+ /**
+ * Volume adjustment function.
+ */
+ AUD_volume_adjust_f m_adjust;
+
+public:
+ /**
+ * Creates a new volume reader.
+ * \param reader The reader to read from.
+ * \param volume The size of the buffer.
+ * \exception AUD_Exception Thrown if the reader specified is NULL.
+ */
+ AUD_VolumeReader(AUD_IReader* reader, float volume);
+
+ /**
+ * Destroys the reader.
+ */
+ virtual ~AUD_VolumeReader();
+
+ virtual bool notify(AUD_Message &message);
+ virtual void read(int & length, sample_t* & buffer);
+};
+
+#endif //AUD_VOLUMEREADER