From f430ebab009fcad54e6340d0952bdc11b8188f32 Mon Sep 17 00:00:00 2001 From: zetaPRIME Date: Mon, 21 Mar 2022 22:27:27 -0400 Subject: [PATCH] fix missing opening notes on non-first play per session (!) --- notes | 7 ------- xybrid/audio/audioengine.cpp | 8 ++++++++ xybrid/nodelib/instrumentcore.cpp | 2 +- xybrid/settingsdialog.cpp | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/notes b/notes index 1238178..aee4bb0 100644 --- a/notes +++ b/notes @@ -33,11 +33,6 @@ parameters { TODO { settings dialog { about-license info - - probably some audio engine settings { - working sample rate - buffer sizes and such - } } revert-to-saved menu action @@ -87,8 +82,6 @@ TODO { does NOT break preview mode?? seems to be only with the Maybe sample??? idk } - playback after stopping immediately after a note in the first pattern played sometimes skips that note - ^ probably due to note IDs; randomize starting point on each playback start? or fix something in InstrumentCore things can apparently be hooked up cyclically, which completely breaks the queue pattern switching is slow when changing (especially increasing) number of rows; set fixed page size to avoid reallocation? diff --git a/xybrid/audio/audioengine.cpp b/xybrid/audio/audioengine.cpp index a746791..0bdaa52 100644 --- a/xybrid/audio/audioengine.cpp +++ b/xybrid/audio/audioengine.cpp @@ -168,6 +168,10 @@ void AudioEngine::play(std::shared_ptr p, int fromPos) { tempo = project->tempo; tickAcc = 0; + // properly initialize note tracking to prevent + chTrack.clear(); // overwritten starting notes + chTrack.resize(findPattern()->channels.size()); + startOutput(); mode = Playing; @@ -271,6 +275,10 @@ void AudioEngine::render(std::shared_ptr p, QString fileName) { tempo = project->tempo; tickAcc = 0; + // properly initialize note tracking to prevent + chTrack.clear(); // overwritten starting notes + chTrack.resize(findPattern()->channels.size()); + initAudio(); // we actually need the period size. whoops. QFileInfo fi(fileName); diff --git a/xybrid/nodelib/instrumentcore.cpp b/xybrid/nodelib/instrumentcore.cpp index 381f20d..c86ccf7 100644 --- a/xybrid/nodelib/instrumentcore.cpp +++ b/xybrid/nodelib/instrumentcore.cpp @@ -209,7 +209,7 @@ void InstrumentCore::process(CommandPort* i, AudioPort* o) { // then do the thing if (o) o->pull(); - double tickTime = smpTime * audioEngine->curTickSize(); + double tickTime = smpTime * static_cast(audioEngine->curTickSize()); if (processNote) { for (auto p = activeNotes.begin(); p != activeNotes.end(); ) { diff --git a/xybrid/settingsdialog.cpp b/xybrid/settingsdialog.cpp index 9eb80cc..354c2d9 100644 --- a/xybrid/settingsdialog.cpp +++ b/xybrid/settingsdialog.cpp @@ -70,7 +70,7 @@ SettingsDialog::SettingsDialog(QWidget *parent) : // audio page QStringList sampleRates = { qs("44100Hz"), qs("48000Hz"), qs("96000Hz") }; - const constexpr int minBufMs = 5, maxBufMs = 250; + const constexpr int minBufMs = 25, maxBufMs = 250; const QString ms = qs("ms"); bind(ui->playbackSampleRate, AudioConfig::playbackSampleRate, sampleRates);