project-kyoku/tools/shared/tools/music.h

32 lines
543 B
C++

#pragma once
#include <SFML/Audio/Music.hpp>
#include <SFML/System/Clock.hpp>
#include "tools/mathutils.h"
class Music
{
public:
explicit Music();
bool openFromFile(const std::string& filepath);
void play();
void pause();
void stop();
void setVolume(int volume);
void setOffset(const microsec& offset);
microsec fetchOffset();
private:
sf::Music _music;
sf::Clock _offset_interpolator;
microsec _sfml_music_offset;
microsec _previous_frame_offset;
microsec _absolute_offset;
};