|
|
|||
File indexing completed on 2026-06-02 08:58:13
0001 //////////////////////////////////////////////////////////// 0002 // 0003 // SFML - Simple and Fast Multimedia Library 0004 // Copyright (C) 2007-2023 Laurent Gomila (laurent@sfml-dev.org) 0005 // 0006 // This software is provided 'as-is', without any express or implied warranty. 0007 // In no event will the authors be held liable for any damages arising from the use of this software. 0008 // 0009 // Permission is granted to anyone to use this software for any purpose, 0010 // including commercial applications, and to alter it and redistribute it freely, 0011 // subject to the following restrictions: 0012 // 0013 // 1. The origin of this software must not be misrepresented; 0014 // you must not claim that you wrote the original software. 0015 // If you use this software in a product, an acknowledgment 0016 // in the product documentation would be appreciated but is not required. 0017 // 0018 // 2. Altered source versions must be plainly marked as such, 0019 // and must not be misrepresented as being the original software. 0020 // 0021 // 3. This notice may not be removed or altered from any source distribution. 0022 // 0023 //////////////////////////////////////////////////////////// 0024 0025 #ifndef SFML_SOUNDFILEWRITER_HPP 0026 #define SFML_SOUNDFILEWRITER_HPP 0027 0028 //////////////////////////////////////////////////////////// 0029 // Headers 0030 //////////////////////////////////////////////////////////// 0031 #include <SFML/Audio/Export.hpp> 0032 #include <string> 0033 0034 0035 namespace sf 0036 { 0037 //////////////////////////////////////////////////////////// 0038 /// \brief Abstract base class for sound file encoding 0039 /// 0040 //////////////////////////////////////////////////////////// 0041 class SFML_AUDIO_API SoundFileWriter 0042 { 0043 public: 0044 0045 //////////////////////////////////////////////////////////// 0046 /// \brief Virtual destructor 0047 /// 0048 //////////////////////////////////////////////////////////// 0049 virtual ~SoundFileWriter() {} 0050 0051 //////////////////////////////////////////////////////////// 0052 /// \brief Open a sound file for writing 0053 /// 0054 /// \param filename Path of the file to open 0055 /// \param sampleRate Sample rate of the sound 0056 /// \param channelCount Number of channels of the sound 0057 /// 0058 /// \return True if the file was successfully opened 0059 /// 0060 //////////////////////////////////////////////////////////// 0061 virtual bool open(const std::string& filename, unsigned int sampleRate, unsigned int channelCount) = 0; 0062 0063 //////////////////////////////////////////////////////////// 0064 /// \brief Write audio samples to the open file 0065 /// 0066 /// \param samples Pointer to the sample array to write 0067 /// \param count Number of samples to write 0068 /// 0069 //////////////////////////////////////////////////////////// 0070 virtual void write(const Int16* samples, Uint64 count) = 0; 0071 }; 0072 0073 } // namespace sf 0074 0075 0076 #endif // SFML_SOUNDFILEWRITER_HPP 0077 0078 0079 //////////////////////////////////////////////////////////// 0080 /// \class sf::SoundFileWriter 0081 /// \ingroup audio 0082 /// 0083 /// This class allows users to write audio file formats not natively 0084 /// supported by SFML, and thus extend the set of supported writable 0085 /// audio formats. 0086 /// 0087 /// A valid sound file writer must override the open and write functions, 0088 /// as well as providing a static check function; the latter is used by 0089 /// SFML to find a suitable writer for a given filename. 0090 /// 0091 /// To register a new writer, use the sf::SoundFileFactory::registerWriter 0092 /// template function. 0093 /// 0094 /// Usage example: 0095 /// \code 0096 /// class MySoundFileWriter : public sf::SoundFileWriter 0097 /// { 0098 /// public: 0099 /// 0100 /// static bool check(const std::string& filename) 0101 /// { 0102 /// // typically, check the extension 0103 /// // return true if the writer can handle the format 0104 /// } 0105 /// 0106 /// virtual bool open(const std::string& filename, unsigned int sampleRate, unsigned int channelCount) 0107 /// { 0108 /// // open the file 'filename' for writing, 0109 /// // write the given sample rate and channel count to the file header 0110 /// // return true on success 0111 /// } 0112 /// 0113 /// virtual void write(const sf::Int16* samples, sf::Uint64 count) 0114 /// { 0115 /// // write 'count' samples stored at address 'samples', 0116 /// // convert them (for example to normalized float) if the format requires it 0117 /// } 0118 /// }; 0119 /// 0120 /// sf::SoundFileFactory::registerWriter<MySoundFileWriter>(); 0121 /// \endcode 0122 /// 0123 /// \see sf::OutputSoundFile, sf::SoundFileFactory, sf::SoundFileReader 0124 /// 0125 ////////////////////////////////////////////////////////////
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|