]> git.sesse.net Git - casparcg/blob - SFML-1.6/include/SFML/Audio/Music.hpp
(no commit message)
[casparcg] / SFML-1.6 / include / SFML / Audio / Music.hpp
1 ////////////////////////////////////////////////////////////\r
2 //\r
3 // SFML - Simple and Fast Multimedia Library\r
4 // Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)\r
5 //\r
6 // This software is provided 'as-is', without any express or implied warranty.\r
7 // In no event will the authors be held liable for any damages arising from the use of this software.\r
8 //\r
9 // Permission is granted to anyone to use this software for any purpose,\r
10 // including commercial applications, and to alter it and redistribute it freely,\r
11 // subject to the following restrictions:\r
12 //\r
13 // 1. The origin of this software must not be misrepresented;\r
14 //    you must not claim that you wrote the original software.\r
15 //    If you use this software in a product, an acknowledgment\r
16 //    in the product documentation would be appreciated but is not required.\r
17 //\r
18 // 2. Altered source versions must be plainly marked as such,\r
19 //    and must not be misrepresented as being the original software.\r
20 //\r
21 // 3. This notice may not be removed or altered from any source distribution.\r
22 //\r
23 ////////////////////////////////////////////////////////////\r
24 \r
25 #ifndef SFML_MUSIC_HPP\r
26 #define SFML_MUSIC_HPP\r
27 \r
28 ////////////////////////////////////////////////////////////\r
29 // Headers\r
30 ////////////////////////////////////////////////////////////\r
31 #include <SFML/Audio/SoundStream.hpp>\r
32 #include <string>\r
33 #include <vector>\r
34 \r
35 \r
36 namespace sf\r
37 {\r
38 namespace priv\r
39 {\r
40     class SoundFile;\r
41 }\r
42 \r
43 ////////////////////////////////////////////////////////////\r
44 /// Music defines a big sound played using streaming,\r
45 /// so usually what we call a music :)\r
46 ////////////////////////////////////////////////////////////\r
47 class SFML_API Music : public SoundStream\r
48 {\r
49 public :\r
50 \r
51     ////////////////////////////////////////////////////////////\r
52     /// Construct the music with a buffer size\r
53     ///\r
54     /// \param BufferSize : Size of the internal buffer, expressed in number of samples\r
55     ///                     (ie. size taken by the music in memory) (44100 by default)\r
56     ///\r
57     ////////////////////////////////////////////////////////////\r
58     explicit Music(std::size_t BufferSize = 44100);\r
59 \r
60     ////////////////////////////////////////////////////////////\r
61     /// Destructor\r
62     ///\r
63     ////////////////////////////////////////////////////////////\r
64     ~Music();\r
65 \r
66     ////////////////////////////////////////////////////////////\r
67     /// Open a music file (doesn't play it -- call Play() for that)\r
68     ///\r
69     /// \param Filename : Path of the music file to open\r
70     ///\r
71     /// \return True if loading has been successful\r
72     ///\r
73     ////////////////////////////////////////////////////////////\r
74     bool OpenFromFile(const std::string& Filename);\r
75 \r
76     ////////////////////////////////////////////////////////////\r
77     /// Open a music file from memory (doesn't play it -- call Play() for that)\r
78     ///\r
79     /// \param Data :        Pointer to the file data in memory\r
80     /// \param SizeInBytes : Size of the data to load, in bytes\r
81     ///\r
82     /// \return True if loading has been successful\r
83     ///\r
84     ////////////////////////////////////////////////////////////\r
85     bool OpenFromMemory(const char* Data, std::size_t SizeInBytes);\r
86 \r
87     ////////////////////////////////////////////////////////////\r
88     /// Get the music duration\r
89     ///\r
90     /// \return Music duration, in seconds\r
91     ///\r
92     ////////////////////////////////////////////////////////////\r
93     float GetDuration() const;\r
94 \r
95 private :\r
96 \r
97     ////////////////////////////////////////////////////////////\r
98     /// /see SoundStream::OnStart\r
99     ///\r
100     ////////////////////////////////////////////////////////////\r
101     virtual bool OnStart();\r
102 \r
103     ////////////////////////////////////////////////////////////\r
104     /// /see SoundStream::OnGetData\r
105     ///\r
106     ////////////////////////////////////////////////////////////\r
107     virtual bool OnGetData(Chunk& Data);\r
108 \r
109     ////////////////////////////////////////////////////////////\r
110     // Member data\r
111     ////////////////////////////////////////////////////////////\r
112     priv::SoundFile*   myFile;     ///< Sound file\r
113     float              myDuration; ///< Music duration, in seconds\r
114     std::vector<Int16> mySamples;  ///< Temporary buffer of samples\r
115 };\r
116 \r
117 } // namespace sf\r
118 \r
119 \r
120 #endif // SFML_MUSIC_HPP\r