You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
695 B
34 lines
695 B
3 months ago
|
#include <SFML/Audio.hpp>
|
||
|
#include <thread> // for sleep_for
|
||
|
#include <iostream>
|
||
|
#include <fmt/core.h>
|
||
|
#include <chrono>
|
||
|
|
||
|
int main(int argc, char *argv[]) {
|
||
|
sf::SoundBuffer buffer;
|
||
3 months ago
|
sf::Sound sound;
|
||
3 months ago
|
|
||
|
if(argc != 2) {
|
||
3 months ago
|
fmt::println("USAGE: audiotest [FILE]");
|
||
3 months ago
|
return 0;
|
||
|
}
|
||
|
|
||
|
const char *in_file = argv[1];
|
||
|
|
||
|
if(!buffer.loadFromFile(in_file)) {
|
||
|
fmt::println("Failed to load {}", in_file);
|
||
3 months ago
|
return 0;
|
||
3 months ago
|
}
|
||
|
|
||
3 months ago
|
sound.setBuffer(buffer);
|
||
3 months ago
|
|
||
|
fmt::println("Playing {}. Hit ctrl-c to exit.", in_file);
|
||
|
|
||
3 months ago
|
sound.play();
|
||
|
while(sound.getStatus() != sf::SoundSource::Status::Stopped) {
|
||
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||
3 months ago
|
}
|
||
|
|
||
|
return 0;
|
||
|
}
|