3D Audio GSoC:
authorJoerg Mueller <nexyon@gmail.com>
Tue, 21 Jun 2011 20:32:25 +0000 (20:32 +0000)
committerJoerg Mueller <nexyon@gmail.com>
Tue, 21 Jun 2011 20:32:25 +0000 (20:32 +0000)
Removing unneeded AUD_ResampleFactory.

intern/audaspace/CMakeLists.txt
intern/audaspace/FX/AUD_PitchReader.cpp
intern/audaspace/FX/AUD_PitchReader.h
intern/audaspace/SRC/AUD_SRCResampleFactory.cpp
intern/audaspace/SRC/AUD_SRCResampleFactory.h
intern/audaspace/intern/AUD_LinearResampleFactory.cpp
intern/audaspace/intern/AUD_LinearResampleFactory.h
intern/audaspace/intern/AUD_ResampleFactory.h [deleted file]
intern/audaspace/intern/AUD_SoftwareDevice.cpp
intern/audaspace/intern/AUD_SoftwareDevice.h

index df9597612d5d5f14b2f563458b08cccce91dbe8b..a8f30bcf35cdb8dfba62753c2c48cc3c93e54364 100644 (file)
@@ -105,7 +105,6 @@ set(SRC
        intern/AUD_ReadDevice.h
        intern/AUD_Reference.h
        intern/AUD_ReferenceHandler.cpp
-       intern/AUD_ResampleFactory.h
        intern/AUD_ResampleReader.cpp
        intern/AUD_ResampleReader.h
        intern/AUD_SequencerFactory.cpp
index 84a76c64ef914792532ba8677813cebbf770a51c..81dd6e4355cbc366da0c2b60665c4f6d8e2b880d 100644 (file)
@@ -42,3 +42,13 @@ AUD_Specs AUD_PitchReader::getSpecs() const
        specs.rate *= m_pitch;
        return specs;
 }
+
+float AUD_PitchReader::getPitch() const
+{
+       return m_pitch;
+}
+
+void AUD_PitchReader::setPitch(float pitch)
+{
+       m_pitch = pitch;
+}
index 7939027dca9601d75bba05c4f8fa06578b850fbe..7418531ca55a3f4c9326385bfb19bcdad674573d 100644 (file)
@@ -43,7 +43,7 @@ private:
        /**
         * The pitch level.
         */
-       const float m_pitch;
+       float m_pitch;
 
        // hide copy constructor and operator=
        AUD_PitchReader(const AUD_PitchReader&);
@@ -58,6 +58,9 @@ public:
        AUD_PitchReader(AUD_Reference<AUD_IReader> reader, float pitch);
 
        virtual AUD_Specs getSpecs() const;
+
+       float getPitch() const;
+       void setPitch(float pitch);
 };
 
 #endif //AUD_PITCHREADER
index 3ae2c4fbd06b6aa6944d8714071bf425ddd4b95a..c4402e88c656b5d9cace29272a3fe447a41eae8f 100644 (file)
@@ -34,7 +34,7 @@
 
 AUD_SRCResampleFactory::AUD_SRCResampleFactory(AUD_Reference<AUD_IFactory> factory,
                                                                                           AUD_DeviceSpecs specs) :
-               AUD_ResampleFactory(factory, specs)
+               AUD_MixerFactory(factory, specs)
 {
 }
 
index d3e7acf0d955677b5172d2eac140c03d294174e7..2f5fe30ac471283823dab75cd7af2ad21f80d800 100644 (file)
 #ifndef AUD_SRCRESAMPLEFACTORY
 #define AUD_SRCRESAMPLEFACTORY
 
-#include "AUD_ResampleFactory.h"
+#include "AUD_MixerFactory.h"
 
 /**
  * This factory creates a resampling reader that uses libsamplerate for
  * resampling.
  */
-class AUD_SRCResampleFactory : public AUD_ResampleFactory
+class AUD_SRCResampleFactory : public AUD_MixerFactory
 {
 private:
        // hide copy constructor and operator=
index de23869441f7cb23cd9d5b02f14bea772783af16..7bedd93b7d50344b64e1b6abb909401c0aefb94f 100644 (file)
@@ -34,7 +34,7 @@
 
 AUD_LinearResampleFactory::AUD_LinearResampleFactory(AUD_Reference<AUD_IFactory> factory,
                                                                                                         AUD_DeviceSpecs specs) :
-               AUD_ResampleFactory(factory, specs)
+               AUD_MixerFactory(factory, specs)
 {
 }
 
index 9f4e9e10abac98b393706a4cc7207f7f3b0e876c..de015610a73e41dc5d32e61bd727b53cad9dbc02 100644 (file)
 #ifndef AUD_LINEARRESAMPLEFACTORY
 #define AUD_LINEARRESAMPLEFACTORY
 
-#include "AUD_ResampleFactory.h"
+#include "AUD_MixerFactory.h"
 
 /**
  * This factory creates a resampling reader that does simple linear resampling.
  */
-class AUD_LinearResampleFactory : public AUD_ResampleFactory
+class AUD_LinearResampleFactory : public AUD_MixerFactory
 {
 private:
        // hide copy constructor and operator=
diff --git a/intern/audaspace/intern/AUD_ResampleFactory.h b/intern/audaspace/intern/AUD_ResampleFactory.h
deleted file mode 100644 (file)
index 634b82b..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * Copyright 2009-2011 Jörg Hermann Müller
- *
- * This file is part of AudaSpace.
- *
- * Audaspace is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * AudaSpace is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Audaspace; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file audaspace/intern/AUD_ResampleFactory.h
- *  \ingroup audaspaceintern
- */
-
-
-#ifndef AUD_RESAMPLEFACTORY
-#define AUD_RESAMPLEFACTORY
-
-#include "AUD_MixerFactory.h"
-
-typedef AUD_MixerFactory AUD_ResampleFactory;
-
-#endif //AUD_RESAMPLEFACTORY
index 836fbd724d0b920acf3aedb604d39080235f85db..e22a4f56328bb35726f02213077fcfbf93ec0ac8 100644 (file)
@@ -45,8 +45,8 @@
 
 typedef std::list<AUD_Reference<AUD_SoftwareDevice::AUD_SoftwareHandle> >::iterator AUD_HandleIterator;
 
-AUD_SoftwareDevice::AUD_SoftwareHandle::AUD_SoftwareHandle(AUD_SoftwareDevice* device, AUD_Reference<AUD_IReader> reader, bool keep) :
-       m_reader(reader), m_keep(keep), m_volume(1.0f), m_loopcount(0),
+AUD_SoftwareDevice::AUD_SoftwareHandle::AUD_SoftwareHandle(AUD_SoftwareDevice* device, AUD_Reference<AUD_IReader> reader, AUD_Reference<AUD_PitchReader> pitch, bool keep) :
+       m_reader(reader), m_pitch(pitch), m_keep(keep), m_volume(1.0f), m_loopcount(0),
        m_stop(NULL), m_stop_data(NULL), m_status(AUD_STATUS_PLAYING), m_device(device)
 {
 }
@@ -192,12 +192,13 @@ bool AUD_SoftwareDevice::AUD_SoftwareHandle::setVolume(float volume)
 
 float AUD_SoftwareDevice::AUD_SoftwareHandle::getPitch()
 {
-       return std::numeric_limits<float>::quiet_NaN();
+       return m_pitch->getPitch();
 }
 
 bool AUD_SoftwareDevice::AUD_SoftwareHandle::setPitch(float pitch)
 {
-       return false;
+       m_pitch->setPitch(pitch);
+       return true;
 }
 
 int AUD_SoftwareDevice::AUD_SoftwareHandle::getLoopCount()
@@ -358,6 +359,11 @@ AUD_DeviceSpecs AUD_SoftwareDevice::getSpecs() const
 AUD_Reference<AUD_IHandle> AUD_SoftwareDevice::play(AUD_Reference<AUD_IReader> reader, bool keep)
 {
        // prepare the reader
+       // pitch
+
+       AUD_Reference<AUD_PitchReader> pitch = new AUD_PitchReader(reader, 1);
+       reader = AUD_Reference<AUD_IReader>(pitch);
+
        // resample
        #ifdef WITH_SAMPLERATE
                reader = new AUD_SRCResampleReader(reader, m_specs.specs);
@@ -372,7 +378,7 @@ AUD_Reference<AUD_IHandle> AUD_SoftwareDevice::play(AUD_Reference<AUD_IReader> r
                return NULL;
 
        // play sound
-       AUD_Reference<AUD_SoftwareDevice::AUD_SoftwareHandle> sound = new AUD_SoftwareDevice::AUD_SoftwareHandle(this, reader, keep);
+       AUD_Reference<AUD_SoftwareDevice::AUD_SoftwareHandle> sound = new AUD_SoftwareDevice::AUD_SoftwareHandle(this, reader, pitch, keep);
 
        lock();
        m_playingSounds.push_back(sound);
index 45df48d12be2ddae548067186052cd8d483283a6..571e2a7e5829ad85cd995cba90a6cc76934f2929 100644 (file)
@@ -36,6 +36,7 @@
 #include "AUD_IHandle.h"
 #include "AUD_Mixer.h"
 #include "AUD_Buffer.h"
+#include "AUD_PitchReader.h"
 
 #include <list>
 #include <pthread.h>
@@ -58,6 +59,9 @@ protected:
                /// The reader source.
                AUD_Reference<AUD_IReader> m_reader;
 
+               /// The pitch reader in between.
+               AUD_Reference<AUD_PitchReader> m_pitch;
+
                /// Whether to keep the source if end of it is reached.
                bool m_keep;
 
@@ -81,7 +85,7 @@ protected:
 
        public:
 
-               AUD_SoftwareHandle(AUD_SoftwareDevice* device, AUD_Reference<AUD_IReader> reader, bool keep);
+               AUD_SoftwareHandle(AUD_SoftwareDevice* device, AUD_Reference<AUD_IReader> reader, AUD_Reference<AUD_PitchReader> pitch, bool keep);
 
                virtual ~AUD_SoftwareHandle() {}
                virtual bool pause();