From 6d5b224184bbd891b40fb0a313e2cc0e9d96a778 Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Tue, 21 Jun 2011 20:32:25 +0000 Subject: 3D Audio GSoC: Removing unneeded AUD_ResampleFactory. --- intern/audaspace/CMakeLists.txt | 1 - intern/audaspace/FX/AUD_PitchReader.cpp | 10 ++++++ intern/audaspace/FX/AUD_PitchReader.h | 5 ++- intern/audaspace/SRC/AUD_SRCResampleFactory.cpp | 2 +- intern/audaspace/SRC/AUD_SRCResampleFactory.h | 4 +-- .../audaspace/intern/AUD_LinearResampleFactory.cpp | 2 +- .../audaspace/intern/AUD_LinearResampleFactory.h | 4 +-- intern/audaspace/intern/AUD_ResampleFactory.h | 39 ---------------------- intern/audaspace/intern/AUD_SoftwareDevice.cpp | 16 ++++++--- intern/audaspace/intern/AUD_SoftwareDevice.h | 6 +++- 10 files changed, 36 insertions(+), 53 deletions(-) delete mode 100644 intern/audaspace/intern/AUD_ResampleFactory.h (limited to 'intern/audaspace') diff --git a/intern/audaspace/CMakeLists.txt b/intern/audaspace/CMakeLists.txt index df9597612d5..a8f30bcf35c 100644 --- a/intern/audaspace/CMakeLists.txt +++ b/intern/audaspace/CMakeLists.txt @@ -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 diff --git a/intern/audaspace/FX/AUD_PitchReader.cpp b/intern/audaspace/FX/AUD_PitchReader.cpp index 84a76c64ef9..81dd6e4355c 100644 --- a/intern/audaspace/FX/AUD_PitchReader.cpp +++ b/intern/audaspace/FX/AUD_PitchReader.cpp @@ -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; +} diff --git a/intern/audaspace/FX/AUD_PitchReader.h b/intern/audaspace/FX/AUD_PitchReader.h index 7939027dca9..7418531ca55 100644 --- a/intern/audaspace/FX/AUD_PitchReader.h +++ b/intern/audaspace/FX/AUD_PitchReader.h @@ -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 reader, float pitch); virtual AUD_Specs getSpecs() const; + + float getPitch() const; + void setPitch(float pitch); }; #endif //AUD_PITCHREADER diff --git a/intern/audaspace/SRC/AUD_SRCResampleFactory.cpp b/intern/audaspace/SRC/AUD_SRCResampleFactory.cpp index 3ae2c4fbd06..c4402e88c65 100644 --- a/intern/audaspace/SRC/AUD_SRCResampleFactory.cpp +++ b/intern/audaspace/SRC/AUD_SRCResampleFactory.cpp @@ -34,7 +34,7 @@ AUD_SRCResampleFactory::AUD_SRCResampleFactory(AUD_Reference factory, AUD_DeviceSpecs specs) : - AUD_ResampleFactory(factory, specs) + AUD_MixerFactory(factory, specs) { } diff --git a/intern/audaspace/SRC/AUD_SRCResampleFactory.h b/intern/audaspace/SRC/AUD_SRCResampleFactory.h index d3e7acf0d95..2f5fe30ac47 100644 --- a/intern/audaspace/SRC/AUD_SRCResampleFactory.h +++ b/intern/audaspace/SRC/AUD_SRCResampleFactory.h @@ -32,13 +32,13 @@ #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= diff --git a/intern/audaspace/intern/AUD_LinearResampleFactory.cpp b/intern/audaspace/intern/AUD_LinearResampleFactory.cpp index de23869441f..7bedd93b7d5 100644 --- a/intern/audaspace/intern/AUD_LinearResampleFactory.cpp +++ b/intern/audaspace/intern/AUD_LinearResampleFactory.cpp @@ -34,7 +34,7 @@ AUD_LinearResampleFactory::AUD_LinearResampleFactory(AUD_Reference factory, AUD_DeviceSpecs specs) : - AUD_ResampleFactory(factory, specs) + AUD_MixerFactory(factory, specs) { } diff --git a/intern/audaspace/intern/AUD_LinearResampleFactory.h b/intern/audaspace/intern/AUD_LinearResampleFactory.h index 9f4e9e10aba..de015610a73 100644 --- a/intern/audaspace/intern/AUD_LinearResampleFactory.h +++ b/intern/audaspace/intern/AUD_LinearResampleFactory.h @@ -32,12 +32,12 @@ #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 index 634b82b3c96..00000000000 --- a/intern/audaspace/intern/AUD_ResampleFactory.h +++ /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 diff --git a/intern/audaspace/intern/AUD_SoftwareDevice.cpp b/intern/audaspace/intern/AUD_SoftwareDevice.cpp index 836fbd724d0..e22a4f56328 100644 --- a/intern/audaspace/intern/AUD_SoftwareDevice.cpp +++ b/intern/audaspace/intern/AUD_SoftwareDevice.cpp @@ -45,8 +45,8 @@ typedef std::list >::iterator AUD_HandleIterator; -AUD_SoftwareDevice::AUD_SoftwareHandle::AUD_SoftwareHandle(AUD_SoftwareDevice* device, AUD_Reference 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 reader, AUD_Reference 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::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_SoftwareDevice::play(AUD_Reference reader, bool keep) { // prepare the reader + // pitch + + AUD_Reference pitch = new AUD_PitchReader(reader, 1); + reader = AUD_Reference(pitch); + // resample #ifdef WITH_SAMPLERATE reader = new AUD_SRCResampleReader(reader, m_specs.specs); @@ -372,7 +378,7 @@ AUD_Reference AUD_SoftwareDevice::play(AUD_Reference r return NULL; // play sound - AUD_Reference sound = new AUD_SoftwareDevice::AUD_SoftwareHandle(this, reader, keep); + AUD_Reference sound = new AUD_SoftwareDevice::AUD_SoftwareHandle(this, reader, pitch, keep); lock(); m_playingSounds.push_back(sound); diff --git a/intern/audaspace/intern/AUD_SoftwareDevice.h b/intern/audaspace/intern/AUD_SoftwareDevice.h index 45df48d12be..571e2a7e582 100644 --- a/intern/audaspace/intern/AUD_SoftwareDevice.h +++ b/intern/audaspace/intern/AUD_SoftwareDevice.h @@ -36,6 +36,7 @@ #include "AUD_IHandle.h" #include "AUD_Mixer.h" #include "AUD_Buffer.h" +#include "AUD_PitchReader.h" #include #include @@ -58,6 +59,9 @@ protected: /// The reader source. AUD_Reference m_reader; + /// The pitch reader in between. + AUD_Reference 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 reader, bool keep); + AUD_SoftwareHandle(AUD_SoftwareDevice* device, AUD_Reference reader, AUD_Reference pitch, bool keep); virtual ~AUD_SoftwareHandle() {} virtual bool pause(); -- cgit v1.2.3