Added a FLAC file to the Sound example to cover all three supported formats.
This commit is contained in:
parent
23cc8cfe3f
commit
20f213bfac
3
.gitattributes
vendored
3
.gitattributes
vendored
@ -7,6 +7,7 @@ cmake/toolchains/android.toolchain.cmake -text -eol
|
|||||||
*.jpg -text -eol
|
*.jpg -text -eol
|
||||||
*.wav -text -eol
|
*.wav -text -eol
|
||||||
*.ogg -text -eol
|
*.ogg -text -eol
|
||||||
|
*.flac -text -eol
|
||||||
*.tff -text -eol
|
*.tff -text -eol
|
||||||
*.icns -text -eol
|
*.icns -text -eol
|
||||||
*.rtf -text -eol
|
*.rtf -text -eol
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include <SFML/Audio.hpp>
|
#include <SFML/Audio.hpp>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
@ -46,15 +47,15 @@ void playSound()
|
|||||||
/// Play a music
|
/// Play a music
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void playMusic()
|
void playMusic(const std::string& filename)
|
||||||
{
|
{
|
||||||
// Load an ogg music file
|
// Load an ogg music file
|
||||||
sf::Music music;
|
sf::Music music;
|
||||||
if (!music.openFromFile("resources/orchestral.ogg"))
|
if (!music.openFromFile("resources/" + filename))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Display music informations
|
// 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.getDuration().asSeconds() << " seconds" << std::endl;
|
||||||
std::cout << " " << music.getSampleRate() << " samples / sec" << std::endl;
|
std::cout << " " << music.getSampleRate() << " samples / sec" << std::endl;
|
||||||
std::cout << " " << music.getChannelCount() << " channels" << 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 << "\rPlaying... " << std::fixed << std::setprecision(2) << music.getPlayingOffset().asSeconds() << " sec ";
|
||||||
std::cout << std::flush;
|
std::cout << std::flush;
|
||||||
}
|
}
|
||||||
std::cout << std::endl;
|
std::cout << std::endl << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -87,8 +88,11 @@ int main()
|
|||||||
// Play a sound
|
// Play a sound
|
||||||
playSound();
|
playSound();
|
||||||
|
|
||||||
// Play a music
|
// Play music from an ogg file
|
||||||
playMusic();
|
playMusic("orchestral.ogg");
|
||||||
|
|
||||||
|
// Play music from a flac file
|
||||||
|
playMusic("ding.flac");
|
||||||
|
|
||||||
// Wait until the user presses 'enter' key
|
// Wait until the user presses 'enter' key
|
||||||
std::cout << "Press enter to exit..." << std::endl;
|
std::cout << "Press enter to exit..." << std::endl;
|
||||||
|
BIN
examples/sound/resources/ding.flac
Normal file
BIN
examples/sound/resources/ding.flac
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user