7bd43fb4e66bf9a7ea6a2d7e1a2b2d6045a3503d
[blender.git] / intern / SoundSystem / SND_SoundObject.h
1 /*
2  * SND_SoundObject.h
3  *
4  * Implementation of the abstract sound object
5  *
6  * $Id$
7  *
8  * ***** BEGIN GPL LICENSE BLOCK *****
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software Foundation,
22  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
23  *
24  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
25  * All rights reserved.
26  *
27  * The Original Code is: all of this file.
28  *
29  * Contributor(s): none yet.
30  *
31  * ***** END GPL LICENSE BLOCK *****
32  */
33
34 #ifndef __SND_SOUNDOBJECT_H
35 #define __SND_SOUNDOBJECT_H
36
37 #include "SND_Object.h"
38 #include "STR_String.h"
39
40 /**
41  *  SND_SoundObject is a class for api independent sounddata storage conected to an actuator
42  */
43
44 class SND_SoundObject : public SND_Object
45 {
46 private:
47         STR_String                      m_samplename;           /* name of the sample */
48         STR_String                      m_objectname;           /* name of the object */
49         unsigned int            m_buffer;
50         
51         bool                            m_active;                       /* is the object active or not? */
52         int                                     m_id;
53         MT_Scalar                       m_lifespan;                     /* the lifespan of the sound seconds */
54         MT_Scalar                       m_timestamp;
55
56         MT_Scalar                       m_length;                       /* length of the sample in seconds */
57
58         MT_Scalar                       m_gain;                         /* the gain of the object */
59         MT_Scalar                       m_rollofffactor;        /* the scaling factor to increase or decrease the range
60                                                                                                 of a source by decreasing or increasing the
61                                                                                                 attenuation, respectively */
62         MT_Scalar                       m_referencedistance;/* the distance at which the listener will experience
63                                                                                                 gain */
64         MT_Scalar                       m_mingain;                      /* indicates the minimal gain which is always guaranteed
65                                                                                                 for this source */
66         MT_Scalar                       m_maxgain;                      /* indicates the maximal gain which is always guaranteed
67                                                                                                 for this source */
68
69         MT_Scalar                       m_pitch;                        /* the pitch of the object */
70         MT_Vector3                      m_position;                     /* position; left/right, up/down, in/out */
71         MT_Vector3                      m_velocity;                     /* velocity of the object */
72         MT_Matrix3x3            m_orientation;          /* orientation of the object */
73         unsigned int            m_loopmode;                     /* loop normal or bidirectional? */
74         unsigned int            m_loopstart;            /* start of looppoint in samples! */
75         unsigned int            m_loopend;                      /* end of looppoint in samples! */
76         bool                            m_is3d;                         /* is the object 3D or 2D? */
77         int                                     m_playstate;            /* flag for current state of object */
78         bool                            m_modified;
79         unsigned int            m_running;
80         bool                            m_highpriority;         /* may the sound be ditched when we run out of voices? */
81
82 public:
83
84         SND_SoundObject();
85         ~SND_SoundObject();
86
87         void SetBuffer(unsigned int buffer);
88         void SetActive(bool active);
89         
90         void StartSound();
91         void StopSound();
92         void PauseSound();
93         void DeleteWhenFinished();
94
95         void SetObjectName(STR_String objectname);
96         void SetSampleName(STR_String samplename);
97         void SetLength(MT_Scalar length);
98         
99         void SetPitch(MT_Scalar pitch);
100         void SetGain(MT_Scalar gain);
101         void SetMinGain(MT_Scalar mingain);
102         void SetMaxGain(MT_Scalar maxgain);
103         void SetRollOffFactor(MT_Scalar rollofffactor);
104         void SetReferenceDistance(MT_Scalar distance);
105         void SetPosition(const MT_Vector3& pos);
106         void SetVelocity(const MT_Vector3& vel);
107         void SetOrientation(const MT_Matrix3x3& orient);
108         void SetLoopMode(unsigned int loopmode);
109         void SetLoopStart(unsigned int loopstart);
110         void SetLoopEnd(unsigned int loopend);
111         void Set3D(bool threedee);
112         void SetPlaystate(int playstate);
113         void SetHighPriority(bool priority);
114
115         void SetId(int id);
116         void SetLifeSpan();
117         void SetTimeStamp(MT_Scalar timestamp);
118
119         void SetModified(bool modified);
120
121         bool IsLifeSpanOver(MT_Scalar curtime) const;
122         bool IsActive() const;
123         bool IsModified() const;
124         bool IsHighPriority() const;
125
126         void InitRunning();
127         bool IsRunning() const;
128         void AddRunning();
129
130         int                                     GetId() const;
131         MT_Scalar                       GetLifeSpan() const;
132         MT_Scalar                       GetTimestamp() const;
133
134         unsigned int            GetBuffer();
135         const STR_String&       GetSampleName();
136         const STR_String&       GetObjectName();
137
138         MT_Scalar                       GetLength() const;
139         MT_Scalar                       GetGain() const;
140         MT_Scalar                       GetPitch() const;
141
142         MT_Scalar                       GetMinGain() const;
143         MT_Scalar                       GetMaxGain() const;
144         MT_Scalar                       GetRollOffFactor() const;
145         MT_Scalar                       GetReferenceDistance() const;
146         
147         MT_Vector3                      GetPosition() const;
148         MT_Vector3                      GetVelocity() const;
149         MT_Matrix3x3            GetOrientation() const;
150         unsigned int            GetLoopMode() const;
151         unsigned int            GetLoopStart() const;
152         unsigned int            GetLoopEnd() const;
153         bool                            Is3D() const;
154         int                                     GetPlaystate() const;
155         
156 };
157
158 #endif //__SND_SOUNDOBJECT_H
159