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:
Diffstat (limited to 'intern/audaspace/intern/AUD_SoftwareDevice.h')
-rw-r--r--intern/audaspace/intern/AUD_SoftwareDevice.h260
1 files changed, 231 insertions, 29 deletions
diff --git a/intern/audaspace/intern/AUD_SoftwareDevice.h b/intern/audaspace/intern/AUD_SoftwareDevice.h
index 1f6a5ead6e0..57ca445595b 100644
--- a/intern/audaspace/intern/AUD_SoftwareDevice.h
+++ b/intern/audaspace/intern/AUD_SoftwareDevice.h
@@ -33,9 +33,14 @@
#define AUD_SOFTWAREDEVICE
#include "AUD_IDevice.h"
-struct AUD_SoftwareHandle;
-class AUD_Mixer;
-class AUD_Buffer;
+#include "AUD_IHandle.h"
+#include "AUD_I3DDevice.h"
+#include "AUD_I3DHandle.h"
+#include "AUD_Mixer.h"
+#include "AUD_Buffer.h"
+#include "AUD_PitchReader.h"
+#include "AUD_ResampleReader.h"
+#include "AUD_ChannelMapperReader.h"
#include <list>
#include <pthread.h>
@@ -48,9 +53,163 @@ class AUD_Buffer;
* - Call the create and destroy functions.
* - Call the mix function to retrieve their audio data.
*/
-class AUD_SoftwareDevice : public AUD_IDevice
+class AUD_SoftwareDevice : public AUD_IDevice, public AUD_I3DDevice
{
protected:
+ /// Saves the data for playback.
+ class AUD_SoftwareHandle : public AUD_IHandle, public AUD_I3DHandle
+ {
+ public:
+ /// The reader source.
+ AUD_Reference<AUD_IReader> m_reader;
+
+ /// The pitch reader in between.
+ AUD_Reference<AUD_PitchReader> m_pitch;
+
+ /// The resample reader in between.
+ AUD_Reference<AUD_ResampleReader> m_resampler;
+
+ /// The channel mapper reader in between.
+ AUD_Reference<AUD_ChannelMapperReader> m_mapper;
+
+ /// Whether to keep the source if end of it is reached.
+ bool m_keep;
+
+ /// The user set pitch of the source.
+ float m_user_pitch;
+
+ /// The user set volume of the source.
+ float m_user_volume;
+
+ /// The user set panning for non-3D sources
+ float m_user_pan;
+
+ /// The calculated final volume of the source.
+ float m_volume;
+
+ /// The loop count of the source.
+ int m_loopcount;
+
+ /// Location in 3D Space.
+ AUD_Vector3 m_location;
+
+ /// Velocity in 3D Space.
+ AUD_Vector3 m_velocity;
+
+ /// Orientation in 3D Space.
+ AUD_Quaternion m_orientation;
+
+ /// 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;
+
+ /// Rendering flags
+ int m_flags;
+
+ /// The stop callback.
+ stopCallback m_stop;
+
+ /// Stop callback data.
+ void* m_stop_data;
+
+ /// Current status of the handle
+ AUD_Status m_status;
+
+ /// Own device.
+ AUD_SoftwareDevice* m_device;
+
+ public:
+
+ /**
+ * Creates a new software handle.
+ * \param device The device this handle is from.
+ * \param reader The reader to play.
+ * \param pitch The pitch reader.
+ * \param resampler The resampling reader.
+ * \param mapper The channel mapping reader.
+ * \param keep Whether to keep the handle when the sound ends.
+ */
+ AUD_SoftwareHandle(AUD_SoftwareDevice* device, AUD_Reference<AUD_IReader> reader, AUD_Reference<AUD_PitchReader> pitch, AUD_Reference<AUD_ResampleReader> resampler, AUD_Reference<AUD_ChannelMapperReader> mapper, bool keep);
+
+ /**
+ * Updates the handle's playback parameters.
+ */
+ void update();
+
+ /**
+ * Sets the audio output specification of the readers.
+ * \param sepcs The output specification.
+ */
+ void setSpecs(AUD_Specs specs);
+
+ virtual ~AUD_SoftwareHandle() {}
+ virtual bool pause();
+ virtual bool resume();
+ virtual bool stop();
+ virtual bool getKeep();
+ virtual bool setKeep(bool keep);
+ virtual bool seek(float position);
+ virtual float getPosition();
+ virtual AUD_Status getStatus();
+ virtual float getVolume();
+ virtual bool setVolume(float volume);
+ virtual float getPitch();
+ virtual bool setPitch(float pitch);
+ virtual int getLoopCount();
+ virtual bool setLoopCount(int count);
+ virtual bool setStopCallback(stopCallback callback = 0, void* data = 0);
+
+ virtual AUD_Vector3 getSourceLocation();
+ virtual bool setSourceLocation(const AUD_Vector3& location);
+ virtual AUD_Vector3 getSourceVelocity();
+ virtual bool setSourceVelocity(const AUD_Vector3& velocity);
+ virtual AUD_Quaternion getSourceOrientation();
+ virtual bool setSourceOrientation(const AUD_Quaternion& orientation);
+ virtual bool isRelative();
+ virtual bool setRelative(bool relative);
+ virtual float getVolumeMaximum();
+ virtual bool setVolumeMaximum(float volume);
+ virtual float getVolumeMinimum();
+ virtual bool setVolumeMinimum(float volume);
+ virtual float getDistanceMaximum();
+ virtual bool setDistanceMaximum(float distance);
+ virtual float getDistanceReference();
+ virtual bool setDistanceReference(float distance);
+ virtual float getAttenuation();
+ virtual bool setAttenuation(float factor);
+ virtual float getConeAngleOuter();
+ virtual bool setConeAngleOuter(float angle);
+ virtual float getConeAngleInner();
+ virtual bool setConeAngleInner(float angle);
+ virtual float getConeVolumeOuter();
+ virtual bool setConeVolumeOuter(float volume);
+ };
+
+ typedef std::list<AUD_Reference<AUD_SoftwareHandle> >::iterator AUD_HandleIterator;
+
/**
* The specification of the device.
*/
@@ -59,7 +218,12 @@ protected:
/**
* The mixer.
*/
- AUD_Mixer* m_mixer;
+ AUD_Reference<AUD_Mixer> m_mixer;
+
+ /**
+ * Whether to do high or low quality resampling.
+ */
+ bool m_quality;
/**
* Initializes member variables.
@@ -84,16 +248,27 @@ protected:
*/
virtual void playing(bool playing)=0;
+ /**
+ * Sets the audio output specification of the device.
+ * \param sepcs The output specification.
+ */
+ void setSpecs(AUD_Specs specs);
+
private:
/**
+ * The reading buffer.
+ */
+ AUD_Buffer m_buffer;
+
+ /**
* The list of sounds that are currently playing.
*/
- std::list<AUD_SoftwareHandle*> m_playingSounds;
+ std::list<AUD_Reference<AUD_SoftwareHandle> > m_playingSounds;
/**
* The list of sounds that are currently paused.
*/
- std::list<AUD_SoftwareHandle*> m_pausedSounds;
+ std::list<AUD_Reference<AUD_SoftwareHandle> > m_pausedSounds;
/**
* Whether there is currently playback.
@@ -110,36 +285,63 @@ private:
*/
float m_volume;
+ /// Listener location.
+ AUD_Vector3 m_location;
+
+ /// Listener velocity.
+ AUD_Vector3 m_velocity;
+
+ /// Listener orientation.
+ AUD_Quaternion m_orientation;
+
+ /// Speed of Sound.
+ float m_speed_of_sound;
+
+ /// Doppler factor.
+ float m_doppler_factor;
+
+ /// Distance model.
+ AUD_DistanceModel m_distance_model;
+
+ /// Rendering flags
+ int m_flags;
+
+public:
+
/**
- * Checks if a handle is valid.
- * \param handle The handle to check.
- * \return Whether the handle is valid.
+ * Sets the panning of a specific handle.
+ * \param handle The handle to set the panning from.
+ * \param pan The new panning value, should be in the range [-2, 2].
*/
- bool isValid(AUD_Handle* handle);
+ static void setPanning(AUD_IHandle* handle, float pan);
+
+ /**
+ * Sets the resampling quality.
+ * \param quality Low (false) or high (true) quality.
+ */
+ void setQuality(bool quality);
-public:
virtual AUD_DeviceSpecs getSpecs() const;
- virtual AUD_Handle* play(AUD_IReader* reader, bool keep = false);
- virtual AUD_Handle* play(AUD_IFactory* factory, bool keep = false);
- virtual bool pause(AUD_Handle* handle);
- virtual bool resume(AUD_Handle* handle);
- virtual bool stop(AUD_Handle* handle);
- virtual bool getKeep(AUD_Handle* handle);
- virtual bool setKeep(AUD_Handle* handle, bool keep);
- virtual bool seek(AUD_Handle* handle, float position);
- virtual float getPosition(AUD_Handle* handle);
- virtual AUD_Status getStatus(AUD_Handle* handle);
+ virtual AUD_Reference<AUD_IHandle> play(AUD_Reference<AUD_IReader> reader, bool keep = false);
+ virtual AUD_Reference<AUD_IHandle> play(AUD_Reference<AUD_IFactory> factory, bool keep = false);
+ virtual void stopAll();
virtual void lock();
virtual void unlock();
virtual float getVolume() const;
virtual void setVolume(float volume);
- virtual float getVolume(AUD_Handle* handle);
- virtual bool setVolume(AUD_Handle* handle, float volume);
- virtual float getPitch(AUD_Handle* handle);
- virtual bool setPitch(AUD_Handle* handle, float pitch);
- virtual int getLoopCount(AUD_Handle* handle);
- virtual bool setLoopCount(AUD_Handle* handle, int count);
- virtual bool setStopCallback(AUD_Handle* handle, stopCallback callback = NULL, void* data = NULL);
+
+ virtual AUD_Vector3 getListenerLocation() const;
+ virtual void setListenerLocation(const AUD_Vector3& location);
+ virtual AUD_Vector3 getListenerVelocity() const;
+ virtual void setListenerVelocity(const AUD_Vector3& velocity);
+ virtual AUD_Quaternion getListenerOrientation() const;
+ virtual void setListenerOrientation(const AUD_Quaternion& orientation);
+ virtual float getSpeedOfSound() const;
+ virtual void setSpeedOfSound(float speed);
+ virtual float getDopplerFactor() const;
+ virtual void setDopplerFactor(float factor);
+ virtual AUD_DistanceModel getDistanceModel() const;
+ virtual void setDistanceModel(AUD_DistanceModel model);
};
#endif //AUD_SOFTWAREDEVICE