bugfix: loading more than 4 wavetables
This commit is contained in:
@@ -14,6 +14,9 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
MainWindow window; // entry point goes to MainWindow::MainWindow()
|
||||
window.show();
|
||||
|
||||
// TODO: logging
|
||||
// i made a good debug filtering setup in ouros so could probably improt that into this project
|
||||
|
||||
int status = app.exec(); // app execution; blocks until window close
|
||||
|
||||
|
||||
@@ -11,13 +11,9 @@ void ScopeBuffer::push(float sample) {
|
||||
buffer_[w % buffer_.size()] = sample;
|
||||
}
|
||||
|
||||
// TODO: needs a mutex/spinlock to prevent flickering
|
||||
// outputs value from the scope buffer, called by the scope widget
|
||||
void ScopeBuffer::read(std::vector<float>& out) const {
|
||||
|
||||
// yeah this didn't work, maybe it needs to be atomic or something
|
||||
//while(!spinLock_) { int x = 1 + 1; }
|
||||
|
||||
size_t w = writeIndex_.load(std::memory_order_relaxed);
|
||||
for (size_t i = 0; i < out.size(); i++) {
|
||||
size_t idx = (w + trigger_ + i * wavelength_ / out.size()) % buffer_.size();
|
||||
|
||||
@@ -6,12 +6,10 @@
|
||||
#include <fstream>
|
||||
|
||||
WavetableController::WavetableController() {
|
||||
// load from files
|
||||
|
||||
|
||||
// load from files
|
||||
init();
|
||||
|
||||
//std::cout << "wavetable init" << std::endl;
|
||||
|
||||
}
|
||||
|
||||
void WavetableController::init() {
|
||||
@@ -23,11 +21,11 @@ void WavetableController::init() {
|
||||
wavetableFiles.push_back(entry.path());
|
||||
}
|
||||
}
|
||||
uint32_t wavetableCount = wavetableFiles.size();
|
||||
wavetables_.resize(wavetableCount);
|
||||
wavetableCount_ = wavetableFiles.size();
|
||||
wavetables_.resize(wavetableCount_);
|
||||
|
||||
// load the wavetable files
|
||||
for(int i = 0; i < wavetableCount; i++) {
|
||||
for(int i = 0; i < wavetableCount_; i++) {
|
||||
std::cout << "loading wavetable file [" << i << "]: " << wavetableFiles[i] << std::endl;
|
||||
std::ifstream inputFile(wavetableFiles[i], std::ios::in | std::ios::binary);
|
||||
if(!inputFile) std::cout << "error opening file" << std::endl;
|
||||
@@ -56,8 +54,8 @@ float WavetableController::sample(uint8_t wavetableIndex, float phase) {
|
||||
uint32_t index = static_cast<uint32_t>(round(scaledPhase));
|
||||
if(index >= SYNTH_WAVETABLE_SIZE) index = SYNTH_WAVETABLE_SIZE - 1;
|
||||
|
||||
if(wavetableIndex >= 4) {
|
||||
wavetableIndex = 3;
|
||||
if(wavetableIndex >= wavetableCount_) {
|
||||
wavetableIndex = wavetableCount_ - 1;
|
||||
} else if(wavetableIndex < 0) {
|
||||
wavetableIndex = 0;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ public:
|
||||
private:
|
||||
|
||||
std::vector<Wavetable> wavetables_;
|
||||
uint32_t wavetableCount_;
|
||||
|
||||
const std::filesystem::path wavetablesRoot_ = "./config/wavetables";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user