Provide read access to sound files.
1 // Open a sound file 2 auto file = new InputSoundFile(); 3 if (!file.openFromFile("music.ogg")) 4 { 5 //error 6 } 7 8 // Print the sound attributes 9 writeln("duration: ", file.getDuration().total!"seconds"); 10 writeln("channels: ", file.getChannelCount()); 11 writeln("sample rate: ", file.getSampleRate()); 12 writeln("sample count: ", file.getSampleCount()); 13 14 // Read and process batches of samples until the end of file is reached 15 short samples[1024]; 16 long count; 17 do 18 { 19 count = file.read(samples, 1024); 20 21 // process, analyze, play, convert, or whatever 22 // you want to do with the samples... 23 } 24 while (count > 0);
$(OUTPUTSOUNDFILE_LINK)
$(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.