Warning
This page refers to an old version of SFML. Click here to switch to the latest version.
Warning
This page refers to an old version of SFML. Click here to switch to the latest version.
Provide write access to sound files. More...
#include <SFML/Audio/OutputSoundFile.hpp>
Public Member Functions | |
OutputSoundFile ()=default | |
Default constructor. | |
OutputSoundFile (const std::filesystem::path &filename, unsigned int sampleRate, unsigned int channelCount, const std::vector< SoundChannel > &channelMap) | |
Construct the sound file from the disk for writing. | |
bool | openFromFile (const std::filesystem::path &filename, unsigned int sampleRate, unsigned int channelCount, const std::vector< SoundChannel > &channelMap) |
Open the sound file from the disk for writing. | |
void | write (const std::int16_t *samples, std::uint64_t count) |
Write audio samples to the file. | |
void | close () |
Close the current file. |
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 sf::SoundBuffer, but can also be useful if you want to create audio files from custom data sources, like generated audio samples.
Usage example:
Definition at line 48 of file OutputSoundFile.hpp.
|
default |
Default constructor.
Construct an output sound file that is not associated with a file to write.
sf::OutputSoundFile::OutputSoundFile | ( | const std::filesystem::path & | filename, |
unsigned int | sampleRate, | ||
unsigned int | channelCount, | ||
const std::vector< SoundChannel > & | channelMap ) |
Construct the sound file from the disk for writing.
The supported audio formats are: WAV, OGG/Vorbis, FLAC.
filename | Path of the sound file to write |
sampleRate | Sample rate of the sound |
channelCount | Number of channels in the sound |
channelMap | Map of position in sample frame to sound channel |
sf::Exception | if the file could not be opened successfully |
void sf::OutputSoundFile::close | ( | ) |
Close the current file.
|
nodiscard |
Open the sound file from the disk for writing.
The supported audio formats are: WAV, OGG/Vorbis, FLAC.
filename | Path of the sound file to write |
sampleRate | Sample rate of the sound |
channelCount | Number of channels in the sound |
channelMap | Map of position in sample frame to sound channel |
void sf::OutputSoundFile::write | ( | const std::int16_t * | samples, |
std::uint64_t | count ) |
Write audio samples to the file.
samples | Pointer to the sample array to write |
count | Number of samples to write |