diff options
Diffstat (limited to 'extern/audaspace/include/sequence')
-rw-r--r-- | extern/audaspace/include/sequence/AnimateableProperty.h | 129 | ||||
-rw-r--r-- | extern/audaspace/include/sequence/Double.h | 60 | ||||
-rw-r--r-- | extern/audaspace/include/sequence/DoubleReader.h | 77 | ||||
-rw-r--r-- | extern/audaspace/include/sequence/PingPong.h | 50 | ||||
-rw-r--r-- | extern/audaspace/include/sequence/Sequence.h | 171 | ||||
-rw-r--r-- | extern/audaspace/include/sequence/SequenceData.h | 215 | ||||
-rw-r--r-- | extern/audaspace/include/sequence/SequenceEntry.h | 315 | ||||
-rw-r--r-- | extern/audaspace/include/sequence/SequenceReader.h | 94 | ||||
-rw-r--r-- | extern/audaspace/include/sequence/Superpose.h | 62 | ||||
-rw-r--r-- | extern/audaspace/include/sequence/SuperposeReader.h | 79 |
10 files changed, 1252 insertions, 0 deletions
diff --git a/extern/audaspace/include/sequence/AnimateableProperty.h b/extern/audaspace/include/sequence/AnimateableProperty.h new file mode 100644 index 00000000000..2c3fcf23f8b --- /dev/null +++ b/extern/audaspace/include/sequence/AnimateableProperty.h @@ -0,0 +1,129 @@ +/******************************************************************************* + * Copyright 2009-2016 Jörg Müller + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************/ + +#pragma once + +/** + * @file AnimateableProperty.h + * @ingroup sequence + * Defines the AnimateableProperty class as well as existing property types. + */ + +#include "util/Buffer.h" +#include "util/ILockable.h" + +#include <mutex> +#include <list> + +AUD_NAMESPACE_BEGIN + +/// Possible animatable properties for Sequencer Factories and Entries. +enum AnimateablePropertyType +{ + AP_VOLUME, + AP_PANNING, + AP_PITCH, + AP_LOCATION, + AP_ORIENTATION +}; + +/** + * This class saves animation data for float properties. + */ +class AUD_API AnimateableProperty : private Buffer +{ +private: + struct Unknown { + int start; + int end; + + Unknown(int start, int end) : + start(start), end(end) {} + }; + + /// The count of floats for a single property. + const int m_count; + + /// Whether the property is animated or not. + bool m_isAnimated; + + /// The mutex for locking. + std::recursive_mutex m_mutex; + + /// The list of unknown buffer areas. + std::list<Unknown> m_unknown; + + // delete copy constructor and operator= + AnimateableProperty(const AnimateableProperty&) = delete; + AnimateableProperty& operator=(const AnimateableProperty&) = delete; + + void AUD_LOCAL updateUnknownCache(int start, int end); + +public: + /** + * Creates a new animateable property. + * \param count The count of floats for a single property. + */ + AnimateableProperty(int count = 1); + + /** + * Creates a new animateable property. + * \param count The count of floats for a single property. + * \param value The value that the property should get initialized with. + * All count floats will be initialized to the same value. + */ + AnimateableProperty(int count, float value); + + /** + * Destroys the animateable property. + */ + ~AnimateableProperty(); + + /** + * Returns the count of floats for a single property. + * \return The count of floats stored per frame. + */ + int getCount() const; + + /** + * Writes the properties value and marks it non-animated. + * \param data The new value. + */ + void write(const float* data); + + /** + * Writes the properties value and marks it animated. + * \param data The new value. + * \param position The position in the animation in frames. + * \param count The count of frames to write. + */ + void write(const float* data, int position, int count); + + /** + * Reads the properties value. + * \param position The position in the animation in frames. + * \param[out] out Where to write the value to. + */ + void read(float position, float* out); + + /** + * Returns whether the property is animated. + * \return Whether the property is animated. + */ + bool isAnimated() const; +}; + +AUD_NAMESPACE_END diff --git a/extern/audaspace/include/sequence/Double.h b/extern/audaspace/include/sequence/Double.h new file mode 100644 index 00000000000..dc40ae29e0d --- /dev/null +++ b/extern/audaspace/include/sequence/Double.h @@ -0,0 +1,60 @@ +/******************************************************************************* + * Copyright 2009-2016 Jörg Müller + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************/ + +#pragma once + +/** + * @file Double.h + * @ingroup sequence + * The Double class. + */ + +#include "ISound.h" + +AUD_NAMESPACE_BEGIN + +/** + * This sound plays two other factories behind each other. + */ +class AUD_API Double : public ISound +{ +private: + /** + * First played sound. + */ + std::shared_ptr<ISound> m_sound1; + + /** + * Second played sound. + */ + std::shared_ptr<ISound> m_sound2; + + // delete copy constructor and operator= + Double(const Double&) = delete; + Double& operator=(const Double&) = delete; + +public: + /** + * Creates a new double sound. + * \param sound1 The first input sound. + * \param sound2 The second input sound. + */ + Double(std::shared_ptr<ISound> sound1, std::shared_ptr<ISound> sound2); + + virtual std::shared_ptr<IReader> createReader(); +}; + +AUD_NAMESPACE_END diff --git a/extern/audaspace/include/sequence/DoubleReader.h b/extern/audaspace/include/sequence/DoubleReader.h new file mode 100644 index 00000000000..012dcc8e832 --- /dev/null +++ b/extern/audaspace/include/sequence/DoubleReader.h @@ -0,0 +1,77 @@ +/******************************************************************************* + * Copyright 2009-2016 Jörg Müller + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************/ + +#pragma once + +/** + * @file DoubleReader.h + * @ingroup sequence + * The DoubleReader class. + */ + +#include "IReader.h" + +#include <memory> + +AUD_NAMESPACE_BEGIN + +/** + * This reader plays two readers sequently. + */ +class AUD_API DoubleReader : public IReader +{ +private: + /** + * The first reader. + */ + std::shared_ptr<IReader> m_reader1; + + /** + * The second reader. + */ + std::shared_ptr<IReader> m_reader2; + + /** + * Whether we've reached the end of the first reader. + */ + bool m_finished1; + + // delete copy constructor and operator= + DoubleReader(const DoubleReader&) = delete; + DoubleReader& operator=(const DoubleReader&) = delete; + +public: + /** + * Creates a new double reader. + * \param reader1 The first reader to read from. + * \param reader2 The second reader to read from. + */ + DoubleReader(std::shared_ptr<IReader> reader1, std::shared_ptr<IReader> reader2); + + /** + * Destroys the reader. + */ + virtual ~DoubleReader(); + + virtual bool isSeekable() const; + virtual void seek(int position); + virtual int getLength() const; + virtual int getPosition() const; + virtual Specs getSpecs() const; + virtual void read(int& length, bool& eos, sample_t* buffer); +}; + +AUD_NAMESPACE_END diff --git a/extern/audaspace/include/sequence/PingPong.h b/extern/audaspace/include/sequence/PingPong.h new file mode 100644 index 00000000000..8b1bf792095 --- /dev/null +++ b/extern/audaspace/include/sequence/PingPong.h @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright 2009-2016 Jörg Müller + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************/ + +#pragma once + +/** + * @file PingPong.h + * @ingroup sequence + * The PingPong class. + */ + +#include "fx/Effect.h" + +AUD_NAMESPACE_BEGIN + +/** + * This sound plays another sound first normal, then reversed. + * \note Readers from the underlying sound must be reversable with seeking. + */ +class AUD_API PingPong : public Effect +{ +private: + // delete copy constructor and operator= + PingPong(const PingPong&) = delete; + PingPong& operator=(const PingPong&) = delete; + +public: + /** + * Creates a new ping pong sound. + * \param sound The input sound. + */ + PingPong(std::shared_ptr<ISound> sound); + + virtual std::shared_ptr<IReader> createReader(); +}; + +AUD_NAMESPACE_END diff --git a/extern/audaspace/include/sequence/Sequence.h b/extern/audaspace/include/sequence/Sequence.h new file mode 100644 index 00000000000..7005171e2c8 --- /dev/null +++ b/extern/audaspace/include/sequence/Sequence.h @@ -0,0 +1,171 @@ +/******************************************************************************* + * Copyright 2009-2016 Jörg Müller + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************/ + +#pragma once + +/** + * @file Sequence.h + * @ingroup sequence + * The Sequence class. + */ + +#include "ISound.h" +#include "respec/Specification.h" +#include "devices/I3DDevice.h" +#include "sequence/AnimateableProperty.h" + +#include <list> + +AUD_NAMESPACE_BEGIN + +class SequenceEntry; +class SequenceData; + +/** + * This sound represents sequenced entries to play a sound scene. + */ +class AUD_API Sequence : public ISound +{ + friend class SequenceReader; +private: + /// The sequence. + std::shared_ptr<SequenceData> m_sequence; + + // delete copy constructor and operator= + Sequence(const Sequence&) = delete; + Sequence& operator=(const Sequence&) = delete; + +public: + /** + * Creates a new sound scene. + * \param specs The output audio data specification. + * \param fps The FPS of the scene. + * \param muted Whether the whole scene is muted. + */ + Sequence(Specs specs, float fps, bool muted); + + /** + * Retrieves the audio output specification. + * \return The specification. + */ + Specs getSpecs(); + + /** + * Sets the audio output specification. + * \param specs The new specification. + */ + void setSpecs(Specs specs); + + /** + * Retrieves the scene's FPS. + * \return The scene's FPS. + */ + float getFPS() const; + + /** + * Sets the scene's FPS. + * \param fps The new FPS. + */ + void setFPS(float fps); + + /** + * Sets the muting state of the scene. + * \param muted Whether the scene is muted. + */ + void mute(bool muted); + + /** + * Retrieves the muting state of the scene. + * \return Whether the scene is muted. + */ + bool isMuted() const; + + /** + * Retrieves the speed of sound. + * This value is needed for doppler effect calculation. + * \return The speed of sound. + */ + float getSpeedOfSound() const; + + /** + * Sets the speed of sound. + * This value is needed for doppler effect calculation. + * \param speed The new speed of sound. + */ + void setSpeedOfSound(float speed); + + /** + * Retrieves the doppler factor. + * This value is a scaling factor for the velocity vectors of sources and + * listener which is used while calculating the doppler effect. + * \return The doppler factor. + */ + float getDopplerFactor() const; + + /** + * Sets the doppler factor. + * This value is a scaling factor for the velocity vectors of sources and + * listener which is used while calculating the doppler effect. + * \param factor The new doppler factor. + */ + void setDopplerFactor(float factor); + + /** + * Retrieves the distance model. + * \return The distance model. + */ + DistanceModel getDistanceModel() const; + + /** + * Sets the distance model. + * \param model distance model. + */ + void setDistanceModel(DistanceModel model); + + /** + * Retrieves one of the animated properties of the sound. + * \param type Which animated property to retrieve. + * \return A pointer to the animated property, valid as long as the + * sound is. + */ + AnimateableProperty* getAnimProperty(AnimateablePropertyType type); + + /** + * Adds a new entry to the scene. + * \param sound The sound this entry should play. + * \param begin The start time. + * \param end The end time or a negative value if determined by the sound. + * \param skip How much seconds should be skipped at the beginning. + * \return The entry added. + */ + std::shared_ptr<SequenceEntry> add(std::shared_ptr<ISound> sound, float begin, float end, float skip); + + /** + * Removes an entry from the scene. + * \param entry The entry to remove. + */ + void remove(std::shared_ptr<SequenceEntry> entry); + + /** + * Creates a new reader with high quality resampling. + * \return The new reader. + */ + std::shared_ptr<IReader> createQualityReader(); + + virtual std::shared_ptr<IReader> createReader(); +}; + +AUD_NAMESPACE_END diff --git a/extern/audaspace/include/sequence/SequenceData.h b/extern/audaspace/include/sequence/SequenceData.h new file mode 100644 index 00000000000..b3df0548a4d --- /dev/null +++ b/extern/audaspace/include/sequence/SequenceData.h @@ -0,0 +1,215 @@ +/******************************************************************************* + * Copyright 2009-2016 Jörg Müller + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************/ + +#pragma once + +/** + * @file SequenceData.h + * @ingroup sequence + * The SequenceData class. + */ + +#include "respec/Specification.h" +#include "sequence/AnimateableProperty.h" +#include "devices/I3DDevice.h" +#include "util/ILockable.h" + +#include <list> +#include <memory> +#include <mutex> + +AUD_NAMESPACE_BEGIN + +class SequenceEntry; +class ISound; + +/** + * This class represents sequenced entries to play a sound scene. + */ +class AUD_API SequenceData : public ILockable +{ + friend class SequenceReader; +private: + /// The target specification. + Specs m_specs; + + /// The status of the sequence. Changes every time a non-animated parameter changes. + int m_status; + + /// The entry status. Changes every time an entry is removed or added. + int m_entry_status; + + /// The next unused ID for the entries. + int m_id; + + /// The sequenced entries. + std::list<std::shared_ptr<SequenceEntry> > m_entries; + + /// Whether the whole scene is muted. + bool m_muted; + + /// The FPS of the scene. + float m_fps; + + /// Speed of Sound. + float m_speed_of_sound; + + /// Doppler factor. + float m_doppler_factor; + + /// Distance model. + DistanceModel m_distance_model; + + /// The animated volume. + AnimateableProperty m_volume; + + /// The animated listener location. + AnimateableProperty m_location; + + /// The animated listener orientation. + AnimateableProperty m_orientation; + + /// The mutex for locking. + std::recursive_mutex m_mutex; + + // delete copy constructor and operator= + SequenceData(const SequenceData&) = delete; + SequenceData& operator=(const SequenceData&) = delete; + +public: + /** + * Creates a new sound scene. + * \param specs The output audio data specification. + * \param fps The FPS of the scene. + * \param muted Whether the whole scene is muted. + */ + SequenceData(Specs specs, float fps, bool muted); + virtual ~SequenceData(); + + /** + * Locks the sequence. + */ + virtual void lock(); + + /** + * Unlocks the previously locked sequence. + */ + virtual void unlock(); + + /** + * Retrieves the audio output specification. + * \return The specification. + */ + Specs getSpecs(); + + /** + * Sets the audio output specification. + * \param specs The new specification. + */ + void setSpecs(Specs specs); + + /** + * Retrieves the scene's FPS. + * \return The scene's FPS. + */ + float getFPS() const; + + /** + * Sets the scene's FPS. + * \param fps The new FPS. + */ + void setFPS(float fps); + + /** + * Sets the muting state of the scene. + * \param muted Whether the scene is muted. + */ + void mute(bool muted); + + /** + * Retrieves the muting state of the scene. + * \return Whether the scene is muted. + */ + bool isMuted() const; + + /** + * Retrieves the speed of sound. + * This value is needed for doppler effect calculation. + * \return The speed of sound. + */ + float getSpeedOfSound() const; + + /** + * Sets the speed of sound. + * This value is needed for doppler effect calculation. + * \param speed The new speed of sound. + */ + void setSpeedOfSound(float speed); + + /** + * Retrieves the doppler factor. + * This value is a scaling factor for the velocity vectors of sources and + * listener which is used while calculating the doppler effect. + * \return The doppler factor. + */ + float getDopplerFactor() const; + + /** + * Sets the doppler factor. + * This value is a scaling factor for the velocity vectors of sources and + * listener which is used while calculating the doppler effect. + * \param factor The new doppler factor. + */ + void setDopplerFactor(float factor); + + /** + * Retrieves the distance model. + * \return The distance model. + */ + DistanceModel getDistanceModel() const; + + /** + * Sets the distance model. + * \param model distance model. + */ + void setDistanceModel(DistanceModel model); + + /** + * Retrieves one of the animated properties of the sequence. + * \param type Which animated property to retrieve. + * \return A pointer to the animated property, valid as long as the + * sequence is. + */ + AnimateableProperty* getAnimProperty(AnimateablePropertyType type); + + /** + * Adds a new entry to the scene. + * \param sound The sound this entry should play. + * \param begin The start time. + * \param end The end time or a negative value if determined by the sound. + * \param skip How much seconds should be skipped at the beginning. + * \return The entry added. + */ + std::shared_ptr<SequenceEntry> add(std::shared_ptr<ISound> sound, float begin, float end, float skip); + + /** + * Removes an entry from the scene. + * \param entry The entry to remove. + */ + void remove(std::shared_ptr<SequenceEntry> entry); +}; + +AUD_NAMESPACE_END diff --git a/extern/audaspace/include/sequence/SequenceEntry.h b/extern/audaspace/include/sequence/SequenceEntry.h new file mode 100644 index 00000000000..98f15faf7ff --- /dev/null +++ b/extern/audaspace/include/sequence/SequenceEntry.h @@ -0,0 +1,315 @@ +/******************************************************************************* + * Copyright 2009-2016 Jörg Müller + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************/ + +#pragma once + +/** + * @file SequenceEntry.h + * @ingroup sequence + * The SequenceEntry class. + */ + +#include "sequence/AnimateableProperty.h" +#include "util/ILockable.h" + +#include <mutex> +#include <memory> + +AUD_NAMESPACE_BEGIN + +class ISound; + +/** + * This class represents a sequenced entry in a sequencer sound. + */ +class AUD_API SequenceEntry : public ILockable +{ + friend class SequenceHandle; +private: + /// The status of the entry. Changes every time a non-animated parameter changes. + int m_status; + + /// The positional status of the entry. Changes every time the entry is moved. + int m_pos_status; + + /// The sound status, changed when the sound is changed. + int m_sound_status; + + /// The unique (regarding the sound) ID of the entry. + int m_id; + + /// The sound this entry plays. + std::shared_ptr<ISound> m_sound; + + /// The begin time. + float m_begin; + + /// The end time. + float m_end; + + /// How many seconds are skipped at the beginning. + float m_skip; + + /// Whether the entry is muted. + bool m_muted; + + /// Whether the position to the listener is relative or absolute + bool m_relative; + + /// Maximum volume. + float m_volume_max; + + /// Minimum volume. + float m_volume_min; + + /// Maximum distance. + float m_distance_max; + + /// Reference distance; + float m_distance_reference; + + /// Attenuation + float m_attenuation; + + /// Cone outer angle. + float m_cone_angle_outer; + + /// Cone inner angle. + float m_cone_angle_inner; + + /// Cone outer volume. + float m_cone_volume_outer; + + /// The mutex for locking. + std::recursive_mutex m_mutex; + + /// The animated volume. + AnimateableProperty m_volume; + + /// The animated panning. + AnimateableProperty m_panning; + + /// The animated pitch. + AnimateableProperty m_pitch; + + /// The animated location. + AnimateableProperty m_location; + + /// The animated orientation. + AnimateableProperty m_orientation; + + // delete copy constructor and operator= + SequenceEntry(const SequenceEntry&) = delete; + SequenceEntry& operator=(const SequenceEntry&) = delete; + +public: + /** + * Creates a new sequenced entry. + * \param sound The sound this entry should play. + * \param begin The start time. + * \param end The end time or a negative value if determined by the sound. + * \param skip How much seconds should be skipped at the beginning. + * \param id The ID of the entry. + */ + SequenceEntry(std::shared_ptr<ISound> sound, float begin, float end, float skip, int id); + virtual ~SequenceEntry(); + + /** + * Locks the entry. + */ + virtual void lock(); + + /** + * Unlocks the previously locked entry. + */ + virtual void unlock(); + + /** + * Retrieves the sound of the entry. + * \return The sound. + */ + std::shared_ptr<ISound> getSound(); + + /** + * Sets the sound of the entry. + * \param sound The new sound. + */ + void setSound(std::shared_ptr<ISound> sound); + + /** + * Moves the entry. + * \param begin The new start time. + * \param end The new end time or a negative value if unknown. + * \param skip How many seconds to skip at the beginning. + */ + void move(float begin, float end, float skip); + + /** + * Retrieves the muting state of the entry. + * \return Whether the entry should is muted or not. + */ + bool isMuted(); + + /** + * Sets the muting state of the entry. + * \param mute Whether the entry should be muted or not. + */ + void mute(bool mute); + + /** + * Retrieves the ID of the entry. + * \return The ID of the entry. + */ + int getID() const; + + /** + * Retrieves one of the animated properties of the entry. + * \param type Which animated property to retrieve. + * \return A pointer to the animated property, valid as long as the + * entry is. + */ + AnimateableProperty* getAnimProperty(AnimateablePropertyType type); + + /** + * Checks whether the source location, velocity and orientation are relative + * to the listener. + * \return Whether the source is relative. + */ + bool isRelative(); + + /** + * Sets whether the source location, velocity and orientation are relative + * to the listener. + * \param relative Whether the source is relative. + * \return Whether the action succeeded. + */ + void setRelative(bool relative); + + /** + * Retrieves the maximum volume of a source. + * \return The maximum volume. + */ + float getVolumeMaximum(); + + /** + * Sets the maximum volume of a source. + * \param volume The new maximum volume. + * \return Whether the action succeeded. + */ + void setVolumeMaximum(float volume); + + /** + * Retrieves the minimum volume of a source. + * \return The minimum volume. + */ + float getVolumeMinimum(); + + /** + * Sets the minimum volume of a source. + * \param volume The new minimum volume. + * \return Whether the action succeeded. + */ + void setVolumeMinimum(float volume); + + /** + * Retrieves the maximum distance of a source. + * If a source is further away from the reader than this distance, the + * volume will automatically be set to 0. + * \return The maximum distance. + */ + float getDistanceMaximum(); + + /** + * Sets the maximum distance of a source. + * If a source is further away from the reader than this distance, the + * volume will automatically be set to 0. + * \param distance The new maximum distance. + * \return Whether the action succeeded. + */ + void setDistanceMaximum(float distance); + + /** + * Retrieves the reference distance of a source. + * \return The reference distance. + */ + float getDistanceReference(); + + /** + * Sets the reference distance of a source. + * \param distance The new reference distance. + * \return Whether the action succeeded. + */ + void setDistanceReference(float distance); + + /** + * Retrieves the attenuation of a source. + * \return The attenuation. + */ + float getAttenuation(); + + /** + * Sets the attenuation of a source. + * This value is used for distance calculation. + * \param factor The new attenuation. + * \return Whether the action succeeded. + */ + void setAttenuation(float factor); + + /** + * Retrieves the outer angle of the cone of a source. + * \return The outer angle of the cone. + */ + float getConeAngleOuter(); + + /** + * Sets the outer angle of the cone of a source. + * \param angle The new outer angle of the cone. + * \return Whether the action succeeded. + */ + void setConeAngleOuter(float angle); + + /** + * Retrieves the inner angle of the cone of a source. + * \return The inner angle of the cone. + */ + float getConeAngleInner(); + + /** + * Sets the inner angle of the cone of a source. + * \param angle The new inner angle of the cone. + * \return Whether the action succeeded. + */ + void setConeAngleInner(float angle); + + /** + * Retrieves the outer volume of the cone of a source. + * The volume between inner and outer angle is interpolated between inner + * volume and this value. + * \return The outer volume of the cone. + */ + float getConeVolumeOuter(); + + /** + * Sets the outer volume of the cone of a source. + * The volume between inner and outer angle is interpolated between inner + * volume and this value. + * \param volume The new outer volume of the cone. + * \return Whether the action succeeded. + */ + void setConeVolumeOuter(float volume); +}; + +AUD_NAMESPACE_END diff --git a/extern/audaspace/include/sequence/SequenceReader.h b/extern/audaspace/include/sequence/SequenceReader.h new file mode 100644 index 00000000000..196d969e102 --- /dev/null +++ b/extern/audaspace/include/sequence/SequenceReader.h @@ -0,0 +1,94 @@ +/******************************************************************************* + * Copyright 2009-2016 Jörg Müller + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************/ + +#pragma once + +/** + * @file SequenceReader.h + * @ingroup sequence + * The SequenceReader class. + */ + +#include "IReader.h" +#include "devices/ReadDevice.h" + +AUD_NAMESPACE_BEGIN + +class SequenceHandle; +class SequenceData; + +/** + * This reader plays back sequenced entries. + */ +class AUD_API SequenceReader : public IReader +{ +private: + /** + * The current position. + */ + int m_position; + + /** + * The read device used to mix the sounds correctly. + */ + ReadDevice m_device; + + /** + * Saves the sequence the reader belongs to. + */ + std::shared_ptr<SequenceData> m_sequence; + + /** + * The list of playback handles for the entries. + */ + std::list<std::shared_ptr<SequenceHandle> > m_handles; + + /** + * Last status read from the sequence. + */ + int m_status; + + /** + * Last entry status read from the sequence. + */ + int m_entry_status; + + // delete copy constructor and operator= + SequenceReader(const SequenceReader&) = delete; + SequenceReader& operator=(const SequenceReader&) = delete; + +public: + /** + * Creates a resampling reader. + * \param sequence The sequence data. + * \param quality Whether a high quality resample should be used for resampling. + */ + SequenceReader(std::shared_ptr<SequenceData> sequence, bool quality = false); + + /** + * Destroys the reader. + */ + ~SequenceReader(); + + virtual bool isSeekable() const; + virtual void seek(int position); + virtual int getLength() const; + virtual int getPosition() const; + virtual Specs getSpecs() const; + virtual void read(int& length, bool& eos, sample_t* buffer); +}; + +AUD_NAMESPACE_END diff --git a/extern/audaspace/include/sequence/Superpose.h b/extern/audaspace/include/sequence/Superpose.h new file mode 100644 index 00000000000..2a3a6166b3b --- /dev/null +++ b/extern/audaspace/include/sequence/Superpose.h @@ -0,0 +1,62 @@ +/******************************************************************************* + * Copyright 2009-2016 Jörg Müller + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************/ + +#pragma once + +/** + * @file Superpose.h + * @ingroup sequence + * The Superpose class. + */ + +#include "ISound.h" + +AUD_NAMESPACE_BEGIN + +/** + * This sound mixes two other factories, playing them the same time. + * \note Readers from the underlying factories must have the same sample rate + * and channel count. + */ +class AUD_API Superpose : public ISound +{ +private: + /** + * First played sound. + */ + std::shared_ptr<ISound> m_sound1; + + /** + * Second played sound. + */ + std::shared_ptr<ISound> m_sound2; + + // delete copy constructor and operator= + Superpose(const Superpose&) = delete; + Superpose& operator=(const Superpose&) = delete; + +public: + /** + * Creates a new superpose sound. + * \param sound1 The first input sound. + * \param sound2 The second input sound. + */ + Superpose(std::shared_ptr<ISound> sound1, std::shared_ptr<ISound> sound2); + + virtual std::shared_ptr<IReader> createReader(); +}; + +AUD_NAMESPACE_END diff --git a/extern/audaspace/include/sequence/SuperposeReader.h b/extern/audaspace/include/sequence/SuperposeReader.h new file mode 100644 index 00000000000..8bd38ade4c3 --- /dev/null +++ b/extern/audaspace/include/sequence/SuperposeReader.h @@ -0,0 +1,79 @@ +/******************************************************************************* + * Copyright 2009-2016 Jörg Müller + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************/ + +#pragma once + +/** + * @file SuperposeReader.h + * @ingroup sequence + * The SuperposeReader class. + */ + +#include "IReader.h" +#include "util/Buffer.h" + +#include <memory> + +AUD_NAMESPACE_BEGIN + +/** + * This reader plays two readers with the same specs in parallel. + */ +class AUD_API SuperposeReader : public IReader +{ +private: + /** + * The first reader. + */ + std::shared_ptr<IReader> m_reader1; + + /** + * The second reader. + */ + std::shared_ptr<IReader> m_reader2; + + /** + * Buffer used for mixing. + */ + Buffer m_buffer; + + // delete copy constructor and operator= + SuperposeReader(const SuperposeReader&) = delete; + SuperposeReader& operator=(const SuperposeReader&) = delete; + +public: + /** + * Creates a new superpose reader. + * \param reader1 The first reader to read from. + * \param reader2 The second reader to read from. + * \exception Exception Thrown if the specs from the readers differ. + */ + SuperposeReader(std::shared_ptr<IReader> reader1, std::shared_ptr<IReader> reader2); + + /** + * Destroys the reader. + */ + virtual ~SuperposeReader(); + + virtual bool isSeekable() const; + virtual void seek(int position); + virtual int getLength() const; + virtual int getPosition() const; + virtual Specs getSpecs() const; + virtual void read(int& length, bool& eos, sample_t* buffer); +}; + +AUD_NAMESPACE_END |