Skip to content

Commit

Permalink
Update tempo after patch load if desired and ensure we calculate time…
Browse files Browse the repository at this point in the history
…_data.ppqPos while processing (#7738)
  • Loading branch information
dhatadi authored Aug 5, 2024
1 parent b409c18 commit af631b5
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/surge-python/surgepy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,15 @@ class SurgeSynthesizerWithPythonExtensions : public SurgeSynthesizer
throw std::invalid_argument((std::string("File not found: ") + s).c_str());
}

return loadPatchByPath(s.c_str(), -1, path.filename().c_str());
bool result = loadPatchByPath(s.c_str(), -1, path.filename().c_str());

// update tempo if we want to change it on patch load
if (storage.unstreamedTempo > -1.f)
{
time_data.tempo = storage.unstreamedTempo;
}

return result;
}

void savePatchPy(const std::string &s) { savePatchToPath(string_to_path(s)); }
Expand Down Expand Up @@ -748,6 +756,7 @@ class SurgeSynthesizerWithPythonExtensions : public SurgeSynthesizer
for (auto i = 0; i < blockIterations; ++i)
{
process();
time_data.ppqPos += (double)BLOCK_SIZE * time_data.tempo / (60. * storage.samplerate);
memcpy((void *)dL, (void *)(output[0]), BLOCK_SIZE * sizeof(float));
memcpy((void *)dR, (void *)(output[1]), BLOCK_SIZE * sizeof(float));

Expand Down Expand Up @@ -848,6 +857,7 @@ class SurgeSynthesizerWithPythonExtensions : public SurgeSynthesizer
memcpy((void *)(input[0]), (void *)iL, BLOCK_SIZE * sizeof(float));
memcpy((void *)(input[1]), (void *)iR, BLOCK_SIZE * sizeof(float));
process();
time_data.ppqPos += (double)BLOCK_SIZE * time_data.tempo / (60. * storage.samplerate);
memcpy((void *)oL, (void *)(output[0]), BLOCK_SIZE * sizeof(float));
memcpy((void *)oR, (void *)(output[1]), BLOCK_SIZE * sizeof(float));

Expand Down

0 comments on commit af631b5

Please sign in to comment.