.. index:: pair: class; EE::Audio::OutputSoundFile .. _doxid-class_e_e_1_1_audio_1_1_output_sound_file: class EE::Audio::OutputSoundFile ================================ .. toctree:: :hidden: Overview ~~~~~~~~ Provide write access to sound files. :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block #include class OutputSoundFile: private :ref:`EE::NonCopyable` { public: // construction :target:`~OutputSoundFile`(); // methods bool :ref:`openFromFile`(const std::string& filename, unsigned int sampleRate, unsigned int channelCount); void :ref:`write`(const :ref:`Int16`* samples, :ref:`Uint64` count); }; .. _details-class_e_e_1_1_audio_1_1_output_sound_file: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ Provide write access to sound files. This class encodes audio samples to a sound file. It is used internally by higher-level classes such as :ref:`SoundBuffer `, but can also be useful if you want to create audio files from custom data sources, like generated audio samples. Usage example: .. ref-code-block:: cpp // Create a sound file, ogg/vorbis format, 44100 Hz, stereo OutputSoundFile file; if (!file.openFromFile("music.ogg", 44100, 2)) /* error */; while (...) { // Read or generate audio samples from your custom source std::vector samples = ...; // Write them to the file file.write(samples.data(), samples.size()); } .. rubric:: See also: :ref:`SoundFileWriter `, :ref:`InputSoundFile ` Methods ------- .. index:: pair: function; openFromFile .. _doxid-class_e_e_1_1_audio_1_1_output_sound_file_1a310b970dd2b442afef479e77053c43f8: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool openFromFile(const std::string& filename, unsigned int sampleRate, unsigned int channelCount) Open the sound file from the disk for writing. The supported audio formats are: WAV, OGG/Vorbis, FLAC. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - filename - Path of the sound file to write * - sampleRate - Sample rate of the sound * - channelCount - Number of channels in the sound .. rubric:: Returns: True if the file was successfully opened .. index:: pair: function; write .. _doxid-class_e_e_1_1_audio_1_1_output_sound_file_1a6dcf3de2ff0c3e72043dd57f471d8719: .. ref-code-block:: cpp :class: doxyrest-title-code-block void write(const :ref:`Int16`* samples, :ref:`Uint64` count) Write audio samples to the file. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - samples - Pointer to the sample array to write * - count - Number of samples to write