1 /*
2 DSFML - The Simple and Fast Multimedia Library for D
3 
4 Copyright (c) 2013 - 2015 Jeremy DeHaan (dehaan.jeremiah@gmail.com)
5 
6 This software is provided 'as-is', without any express or implied warranty.
7 In no event will the authors be held liable for any damages arising from the use of this software.
8 
9 Permission is granted to anyone to use this software for any purpose, including commercial applications,
10 and to alter it and redistribute it freely, subject to the following restrictions:
11 
12 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software.
13 If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
14 
15 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
16 
17 3. This notice may not be removed or altered from any source distribution
18 */
19 
20 module dsfml.audio.soundsource;
21 
22 import dsfml.system.vector3;
23 
24 import dsfml.system.err;
25 
26 /++
27  + Base class defining a sound's properties.
28  + 
29  + SoundSource is not meant to be used directly, it only serves as a common base for all audio objects that can live in the audio environment.
30  + 
31  + It defines several properties for the sound: pitch, volume, position, attenuation, etc. All of them can be changed at any time with no impact on performances.
32  + 
33  + See_Also: http://sfml-dev.org/documentation/2.0/classsf_1_1SoundSource.php#details
34  + Authors: Laurent Gomila, Jeremy DeHaan
35  +/
36 interface SoundSource
37 {
38 	/// Enumeration of the sound source states.
39 	enum Status
40 	{
41 		/// Sound is not playing.
42 		Stopped,
43 		/// Sound is paused.
44 		Paused,
45 		/// Sound is playing.
46 		Playing
47 	}
48 
49 	/**
50 	 * The pitch of the sound.
51 	 * 
52 	 * The pitch represents the perceived fundamental frequency of a sound; thus you can make a sound more acute or grave by changing its pitch. A side effect of changing the pitch is to modify the playing speed of the sound as well. The default value for the pitch is 1.
53 	 */
54 	@property
55 	{
56 		void pitch(float newPitch);
57 		
58 		float pitch();
59 	}
60 
61 	/**
62 	 * The volume of the sound.
63 	 * 
64 	 * The volume is a vlue between 0 (mute) and 100 (full volume). The default value for the volume is 100.
65 	 */
66 	@property
67 	{
68 		void volume(float newVolume);
69 
70 		float volume();
71 	}
72 
73 	/**
74 	 * The 3D position of the sound in the audio scene.
75 	 * 
76 	 * Only sounds with one channel (mono sounds) can be spatialized. The default position of a sound is (0, 0, 0).
77 	 */
78 	@property
79 	{
80 		void position(Vector3f newPosition);
81 
82 		Vector3f position();
83 	}
84 
85 	/**
86 	 * Make the sound's position relative to the listener (true) or absolute (false).
87 	 * 
88 	 * Making a sound relative to the listener will ensure that it will always be played the same way regardless the position of the listener.  This can be useful for non-spatialized sounds, sounds that are produced by the listener, or sounds attached to it. The default value is false (position is absolute).
89 	 */
90 	@property
91 	{
92 		void relativeToListener(bool relative);
93 
94 		bool relativeToListener();
95 	}
96 	
97 	/**
98 	 * The minimum distance of the sound.
99 	 * 
100 	 * The "minimum distance" of a sound is the maximum distance at which it is heard at its maximum volume. Further than the minimum distance, it will start to fade out according to its attenuation factor. A value of 0 ("inside the head of the listener") is an invalid value and is forbidden. The default value of the minimum distance is 1.
101 	 */
102 	@property
103 	{
104 		void minDistance(float distance);
105 
106 		float minDistance();
107 	}
108 	
109 	/**
110 	 * The attenuation factor of the sound.
111 	 * 
112 	 * The attenuation is a multiplicative factor which makes the sound more or less loud according to its distance from the listener. An attenuation of 0 will produce a non-attenuated sound, i.e. its volume will always be the same whether it is heard from near or from far. 
113 	 * 
114 	 * On the other hand, an attenuation value such as 100 will make the sound fade out very quickly as it gets further from the listener. The default value of the attenuation is 1.
115 	 */
116 	@property
117 	{
118 		void attenuation(float newAttenuation);
119 
120 		float attenuation();
121 	}
122 
123 }
124 
125 private extern(C):
126 
127 const(char)* sfErrAudio_getOutput();
128