Document Wav class

This commit is contained in:
Dmitry Marakasov 2014-12-17 18:37:36 +03:00
parent 7f059d8a1a
commit 4a48c58f5f

View File

@ -28,30 +28,113 @@ namespace SDL2pp {
class RWops; class RWops;
////////////////////////////////////////////////////////////
/// \brief Chunk of audio data read from a .WAV file
///
/// \headerfile SDL2pp/Wav.hh
///
////////////////////////////////////////////////////////////
class Wav { class Wav {
private: private:
Uint8* audio_buffer_; Uint8* audio_buffer_; ///< Raw audio data
Uint32 audio_length_; Uint32 audio_length_; ///< Raw audio data length in bytes
AudioSpec spec_; AudioSpec spec_; ///< Description of audio data format
public: public:
////////////////////////////////////////////////////////////
/// \brief Load audio from file on disk
///
/// \param file Path to the wav file
///
////////////////////////////////////////////////////////////
Wav(const std::string& file); Wav(const std::string& file);
////////////////////////////////////////////////////////////
/// \brief Load audio using RWops
///
/// \param rwops SDL2pp::RWops used to access wav data
///
////////////////////////////////////////////////////////////
Wav(RWops& rwops); Wav(RWops& rwops);
////////////////////////////////////////////////////////////
/// \brief Destructor
///
////////////////////////////////////////////////////////////
~Wav(); ~Wav();
////////////////////////////////////////////////////////////
/// \brief Move constructor
///
/// \param other SDL2pp::Wav object to move data from
///
////////////////////////////////////////////////////////////
Wav(Wav&& other); Wav(Wav&& other);
////////////////////////////////////////////////////////////
/// \brief Move assignment operator
///
/// \param other SDL2pp::Wav object to move data from
///
/// \returns Reference to self
///
////////////////////////////////////////////////////////////
Wav& operator=(Wav&& other); Wav& operator=(Wav&& other);
// Deleted copy constructor and assignment
Wav(const Wav& other) = delete; Wav(const Wav& other) = delete;
Wav& operator=(const Wav& other) = delete; Wav& operator=(const Wav& other) = delete;
////////////////////////////////////////////////////////////
/// \brief Get length of audio data
///
/// \returns Length of audio data in bytes
///
////////////////////////////////////////////////////////////
Uint32 GetLength() const; Uint32 GetLength() const;
////////////////////////////////////////////////////////////
/// \brief Get pointer to raw audio data
///
/// \returns Pointer to raw audio data
///
////////////////////////////////////////////////////////////
Uint8* GetBuffer(); Uint8* GetBuffer();
////////////////////////////////////////////////////////////
/// \brief Get constant pointer to raw audio data
///
/// \returns Constant pointer to raw audio data
///
////////////////////////////////////////////////////////////
const Uint8* GetBuffer() const; const Uint8* GetBuffer() const;
////////////////////////////////////////////////////////////
/// \brief Get descriptor of audio format
///
/// \returns SDL2pp::AudioSpec describing format of audio data
///
////////////////////////////////////////////////////////////
const AudioSpec& GetSpec() const; const AudioSpec& GetSpec() const;
}; };
} }
#endif #endif
////////////////////////////////////////////////////////////
/// \class SDL2pp::Wav
/// \ingroup Audio
///
/// SDL2pp::Wav is a wrapper around basic SDL2 audio fragment
/// handling functionality, basically SDL_LoadWAV and related
/// functions.
///
/// The class holds raw audio data which is loaded from a disk
/// file or from an arbitrary source with SDL2pp::RWops and
/// may be used in audio playback.
///
/// See audio_wav demo for an example.
///
////////////////////////////////////////////////////////////