.. index:: pair: class; EE::Audio::SoundFileWriter .. _doxid-class_e_e_1_1_audio_1_1_sound_file_writer: class EE::Audio::SoundFileWriter ================================ .. toctree:: :hidden: Overview ~~~~~~~~ Abstract base class for sound file encoding. :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block #include class SoundFileWriter { public: // construction virtual :target:`~SoundFileWriter`(); // methods virtual bool :ref:`open`(const std::string& filename, unsigned int sampleRate, unsigned int channelCount) = 0; virtual void :ref:`write`(const :ref:`Int16`* samples, :ref:`Uint64` count) = 0; }; .. _details-class_e_e_1_1_audio_1_1_sound_file_writer: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ Abstract base class for sound file encoding. This class allows users to write audio file formats not natively supported by EEPP, and thus extend the set of supported writable audio formats. A valid sound file writer must override the open and write functions, as well as providing a static check function; the latter is used by EEPP to find a suitable writer for a given filename. To register a new writer, use the :ref:`SoundFileFactory::registerWriter ` template function. Usage example: .. ref-code-block:: cpp class MySoundFileWriter : public SoundFileWriter { public: static bool check(const std::string& filename) { // typically, check the extension // return true if the writer can handle the format } virtual bool open(const std::string& filename, unsigned int sampleRate, unsigned int channelCount) { // open the file 'filename' for writing, // write the given sample rate and channel count to the file header // return true on success } virtual void write(const Int16* samples, Uint64 count) { // write 'count' samples stored at address 'samples', // convert them (for example to normalized float) if the format requires it } }; SoundFileFactory::registerWriter(); .. rubric:: See also: :ref:`OutputSoundFile `, :ref:`SoundFileFactory `, :ref:`SoundFileReader ` Methods ------- .. index:: pair: function; open .. _doxid-class_e_e_1_1_audio_1_1_sound_file_writer_1a0e59c27225307b516b52a69326b5d610: .. ref-code-block:: cpp :class: doxyrest-title-code-block virtual bool open(const std::string& filename, unsigned int sampleRate, unsigned int channelCount) = 0 Open a sound file for writing. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - filename - Path of the file to open * - sampleRate - Sample rate of the sound * - channelCount - Number of channels of the sound .. rubric:: Returns: True if the file was successfully opened .. index:: pair: function; write .. _doxid-class_e_e_1_1_audio_1_1_sound_file_writer_1a679c2da514f35162116c1e6a54a478c2: .. ref-code-block:: cpp :class: doxyrest-title-code-block virtual void write(const :ref:`Int16`* samples, :ref:`Uint64` count) = 0 Write audio samples to the open file. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - samples - Pointer to the sample array to write * - count - Number of samples to write