Skip to content

Commit

Permalink
Fixing compiler errors for Arduino-IDE with TeensyDuino. (#60)
Browse files Browse the repository at this point in the history
Co-authored-by: Holger Wirtz <wirtz@parasitstudio.de>
  • Loading branch information
dcoredump and Holger Wirtz authored Jun 22, 2024
1 parent 67dfc14 commit d37fab1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
28 changes: 14 additions & 14 deletions src/IndexableFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ constexpr bool isPowerOf2(size_t value){

template<size_t BUFFER_SIZE, size_t MAX_NUM_BUFFERS, class TFile> // BUFFER_SIZE needs to be a power of two
class IndexableFile {
protected:
TFile _file;
char *_filename;
std::vector<indexedbuffer*> _buffers;

indexedbuffer* find_with_index(uint32_t i) {
for (auto && x : _buffers){
if (x->index == i) {
return x;
}
}
return nullptr;
}

public:
static_assert(isPowerOf2(BUFFER_SIZE), "BUFFER_SIZE must be a power of 2");

Expand Down Expand Up @@ -85,20 +99,6 @@ class IndexableFile {
_filename = nullptr;
}
}

protected:
TFile _file;
char *_filename;
std::vector<indexedbuffer*> _buffers;

indexedbuffer* find_with_index(uint32_t i) {
for (auto && x : _buffers){
if (x->index == i) {
return x;
}
}
return nullptr;
}
};

}
Expand Down
12 changes: 6 additions & 6 deletions src/ResamplingReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,11 @@ class ResamplingReader {
}
} else {
if (_playbackRate >= 0.0) {
if (_crossfade == 0.0 && _bufferPosition1 > (_loop_finish - _numChannels) - _crossfadeDurationInSamples) {
if (_crossfade == 0.0 && _bufferPosition1 > int32_t((_loop_finish - _numChannels) - _crossfadeDurationInSamples)) {
_bufferPosition2 = _loop_start;
_crossfade = 1.0 - (( (_loop_finish-_numChannels) - _bufferPosition1 ) / static_cast<double>(_crossfadeDurationInSamples));
_crossfadeState = 1;
} else if (_crossfade == 1.0 && _bufferPosition2 > (_loop_finish - _numChannels)- _crossfadeDurationInSamples) {
} else if (_crossfade == 1.0 && _bufferPosition2 > int32_t((_loop_finish - _numChannels)- _crossfadeDurationInSamples)) {
_bufferPosition1 = _loop_start;
_crossfade = ((_loop_finish - _numChannels) - _bufferPosition2) / static_cast<double>(_crossfadeDurationInSamples);
_crossfadeState = 2;
Expand All @@ -290,11 +290,11 @@ class ResamplingReader {
}
}
} else {
if (_crossfade == 0.0 && _bufferPosition1 < _crossfadeDurationInSamples + _header_offset) {
if (_crossfade == 0.0 && _bufferPosition1 < int32_t(_crossfadeDurationInSamples + _header_offset)) {
_bufferPosition2 = _loop_finish - _numChannels;
_crossfade = 1.0 - (_bufferPosition1 - _header_offset) / static_cast<double>(_crossfadeDurationInSamples);
_crossfadeState = 1;
} else if (_crossfade == 1.0 && _bufferPosition2 < _crossfadeDurationInSamples + _header_offset) {
} else if (_crossfade == 1.0 && _bufferPosition2 < int32_t(_crossfadeDurationInSamples + _header_offset)) {
_bufferPosition1 = _loop_finish - _numChannels;
_crossfade = (_bufferPosition2 - _header_offset) / static_cast<double>(_crossfadeDurationInSamples);
_crossfadeState = 2;
Expand Down Expand Up @@ -659,8 +659,8 @@ class ResamplingReader {
double _remainder = 0.0;
loop_type _loopType = loop_type::looptype_none;
play_start _play_start = play_start::play_start_sample;
int _bufferPosition1 = 0;
int _bufferPosition2 = 0;
int32_t _bufferPosition1 = 0;
int32_t _bufferPosition2 = 0;
double _crossfade = 0.0;
bool _useDualPlaybackHead = false;
unsigned int _crossfadeDurationInSamples = 256;
Expand Down

0 comments on commit d37fab1

Please sign in to comment.