Skip to content

Commit

Permalink
Corrected offset when converting seconds to ticks
Browse files Browse the repository at this point in the history
Antiloope committed Oct 10, 2020
1 parent ba506cf commit 792fe18
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/interpreter/players/sampleplayer.cpp
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ void SamplePlayer::play(double timeFactor, tick_t startTick, string variableName
void SamplePlayer::loop(double timeFactor,tick_t startTick,string variableName) {
PeriodicSample* newSample = _sample.generate(
timeFactor,
TimeHandler::getInstance()->msToTicks(timeFactor * getDurationInSeconds() * 1000),
TimeHandler::getInstance()->segToTicks(timeFactor * getDurationInSeconds()),
startTick);
_generatedSounds.push_back(newSample);
ExecutorInterface::addSound(newSample,variableName);
@@ -30,7 +30,7 @@ void SamplePlayer::loop(double timeFactor,tick_t startTick,string variableName)
void SamplePlayer::loop(double timeFactor,double period,tick_t startTick,string variableName) {
PeriodicSample* newSample = _sample.generate(
timeFactor,
TimeHandler::getInstance()->msToTicks(period*1000),
TimeHandler::getInstance()->segToTicks(period),
startTick);
_generatedSounds.push_back(newSample);
ExecutorInterface::addSound(newSample,variableName);
2 changes: 1 addition & 1 deletion src/utils/timehandler.cpp
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ tick_t TimeHandler::msToTicks(unsigned long time_ms) const {
}

tick_t TimeHandler::segToTicks(double time_seg) const {
return (tick_t)((double)(time_seg)*1000. / _tickTime);
return (tick_t)((double)(time_seg) * _sampleRate);
}

unsigned long TimeHandler::ticksToMs(tick_t ticks) const {

0 comments on commit 792fe18

Please sign in to comment.