dsfml.audio.inputsoundfile

$(U InputSoundFile) decodes audio samples from a sound file. It is used internally by higher-level classes such as $(SOUNDBUFFER_LINK) and $(MUSIC_LINK), but can also be useful if you want to process or analyze audio files without playing them, or if you want to implement your own version of $(MUSIC_LINK) with more specific features.

Public Imports

dsfml.system.time
public import dsfml.system.time;

Members

Classes

InputSoundFile
class InputSoundFile

Provide read access to sound files.

Examples

// Open a sound file
auto file = new InputSoundFile();
if (!file.openFromFile("music.ogg"))
{
     //error
}

// Print the sound attributes
writeln("duration: ", file.getDuration().total!"seconds");
writeln("channels: ", file.getChannelCount());
writeln("sample rate: ", file.getSampleRate());
writeln("sample count: ", file.getSampleCount());

// Read and process batches of samples until the end of file is reached
short samples[1024];
long count;
do
{
    count = file.read(samples, 1024);

    // process, analyze, play, convert, or whatever
    // you want to do with the samples...
}
while (count > 0);

See Also

$(OUTPUTSOUNDFILE_LINK)

Meta