diff --git a/.gitattributes b/.gitattributes index 7095658cd..2f88beae1 100644 --- a/.gitattributes +++ b/.gitattributes @@ -7,6 +7,7 @@ cmake/toolchains/android.toolchain.cmake -text -eol *.jpg -text -eol *.wav -text -eol *.ogg -text -eol +*.flac -text -eol *.tff -text -eol *.icns -text -eol -*.rtf -text -eol \ No newline at end of file +*.rtf -text -eol diff --git a/examples/sound/Sound.cpp b/examples/sound/Sound.cpp index 7005f648e..4de8946ce 100644 --- a/examples/sound/Sound.cpp +++ b/examples/sound/Sound.cpp @@ -5,6 +5,7 @@ #include #include #include +#include //////////////////////////////////////////////////////////// @@ -46,15 +47,15 @@ void playSound() /// Play a music /// //////////////////////////////////////////////////////////// -void playMusic() +void playMusic(const std::string& filename) { // Load an ogg music file sf::Music music; - if (!music.openFromFile("resources/orchestral.ogg")) + if (!music.openFromFile("resources/" + filename)) return; // Display music informations - std::cout << "orchestral.ogg:" << std::endl; + std::cout << filename << ":" << std::endl; std::cout << " " << music.getDuration().asSeconds() << " seconds" << std::endl; std::cout << " " << music.getSampleRate() << " samples / sec" << std::endl; std::cout << " " << music.getChannelCount() << " channels" << std::endl; @@ -72,7 +73,7 @@ void playMusic() std::cout << "\rPlaying... " << std::fixed << std::setprecision(2) << music.getPlayingOffset().asSeconds() << " sec "; std::cout << std::flush; } - std::cout << std::endl; + std::cout << std::endl << std::endl; } @@ -87,8 +88,11 @@ int main() // Play a sound playSound(); - // Play a music - playMusic(); + // Play music from an ogg file + playMusic("orchestral.ogg"); + + // Play music from a flac file + playMusic("ding.flac"); // Wait until the user presses 'enter' key std::cout << "Press enter to exit..." << std::endl; diff --git a/examples/sound/resources/ding.flac b/examples/sound/resources/ding.flac new file mode 100644 index 000000000..4e62c7866 Binary files /dev/null and b/examples/sound/resources/ding.flac differ