Skip to content

Commit

Permalink
Critical Bugfix: microsecond loop points using reverse conversion met…
Browse files Browse the repository at this point in the history
…hod LMAO this went unnoticed for 7 months how???
  • Loading branch information
gheskett committed Mar 25, 2022
1 parent 02daaaa commit 68a7d21
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ char get_num_to_hex(uint8_t num) {
return ret;
}

int64_t sample_to_us(int64_t sampleRate, int64_t sampleOffset) {
return (int64_t) (((long double) sampleOffset / (long double) sampleRate) * 1000000.0 + 0.5);
int64_t us_to_samples(int64_t sampleRate, int64_t timeOffset) {
return (int64_t) ((((long double) timeOffset / 1000000.0) * (long double) sampleRate) + 0.5);
}

int AudioOutData::check_properties(string newFilename) {
Expand Down Expand Up @@ -231,7 +231,7 @@ int AudioOutData::check_properties(string newFilename) {
}
// Overridden total sample count / end loop point, represented in microseconds
else if (ovrdLoopEndMicro != MAX_INT64_T) {
int64_t tmpNumSamples = sample_to_us(sampleRate, ovrdLoopEndMicro);
int64_t tmpNumSamples = us_to_samples(sampleRate, ovrdLoopEndMicro);
if (tmpNumSamples > 0) {
if (numSamples > tmpNumSamples)
numSamples = (int32_t) tmpNumSamples;
Expand Down Expand Up @@ -262,7 +262,7 @@ int AudioOutData::check_properties(string newFilename) {
}
// Overridden start loop point, represented in microseconds
else if (ovrdLoopStartMicro != MAX_INT64_T) {
int64_t tmpNumSamples = sample_to_us(sampleRate, ovrdLoopStartMicro);
int64_t tmpNumSamples = us_to_samples(sampleRate, ovrdLoopStartMicro);
if (tmpNumSamples >= 0)
loopStartSamples = (int32_t) tmpNumSamples;
else
Expand Down

0 comments on commit 68a7d21

Please sign in to comment.