You cannot 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
571 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();
bool isPaused() const;
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;
};