|
|
@@ -0,0 +1,409 @@
|
|
|
+// Round 190ud (issue #375, HalanoSiblee: "changing the sampler's pitch while it plays is only heard after a seek"): FL 2026
|
|
|
+// moves a sounding Sampler note AND a sounding audio clip at once when the channel's PITCH changes (FL /R renders of a
|
|
|
+// PITCH automation step: the step lands inside the 10 ms window it falls in, no glide; the clip, like the note, plays
|
|
|
+// faster / slower: varispeed). LYNX's audio clips ignored the live pitch (SamplerInstrument::setChannelPitchNow returned
|
|
|
+// at once in clip mode), and a note that started before the rack first handed the instrument the channel's pitch never
|
|
|
+// followed it. docs/analise/REA_rodada190ud.md.
|
|
|
+//
|
|
|
+// The check renders through the real paths:
|
|
|
+// 1. offline (ExportJob, the export path) a PITCH automation step 0 -> +2 st at 1 s and +2 -> -5 st at 2 s on a held
|
|
|
+// 440 Hz sine: a Sampler note (resampled), an audio clip, a "keep length" Sampler note at G5 (its pitch shifter moves
|
|
|
+// the transposition and its length stays: it ends where the same note without the steps ends) and an audio clip
|
|
|
+// with a pitch of its own (+3 st, its own shifter; the channel's pitch is its speed, so it ends sooner). The new
|
|
|
+// pitch must be there in the window that starts one block (512 samples) after each step.
|
|
|
+// 2. live: the engine on a stand-in device (callbacks of 512 samples from its own thread), Play, then the channel
|
|
|
+// header's PITCH knob edit (AudioEngine::editSong, as the knob does) while a Sampler note / an audio clip sounds:
|
|
|
+// the new pitch must be heard within two device blocks of the edit, and the sound must go on.
|
|
|
+
|
|
|
+#include "engine/AudioEngine.h"
|
|
|
+
|
|
|
+#include "core/SamplerPage.h"
|
|
|
+#include "engine/Exporter.h"
|
|
|
+
|
|
|
+namespace lynx
|
|
|
+{
|
|
|
+namespace
|
|
|
+{
|
|
|
+constexpr double rate190ud = 48000.0;
|
|
|
+constexpr int block190ud = 512;
|
|
|
+
|
|
|
+// the stand-in device: plays the engine from its own thread and keeps what the engine wrote (left channel)
|
|
|
+struct PitchDevice final : juce::AudioIODevice, private juce::Thread
|
|
|
+{
|
|
|
+ PitchDevice() : juce::AudioIODevice ("Pitch test device", "Sampler pitch test"), juce::Thread ("pitch test device") {}
|
|
|
+ ~PitchDevice() override { close(); }
|
|
|
+
|
|
|
+ static inline std::vector<float>* capture = nullptr; // (sized by the test before Play; the device thread fills it)
|
|
|
+ static inline std::atomic<int> captured { 0 }; // frames written into it while the transport plays
|
|
|
+ static inline std::atomic<bool> recording { false };
|
|
|
+
|
|
|
+ juce::StringArray getOutputChannelNames() override { return { "Out 1", "Out 2" }; }
|
|
|
+ juce::StringArray getInputChannelNames() override { return {}; }
|
|
|
+ juce::Array<double> getAvailableSampleRates() override { return { rate190ud }; }
|
|
|
+ juce::Array<int> getAvailableBufferSizes() override { return { block190ud }; }
|
|
|
+ int getDefaultBufferSize() override { return block190ud; }
|
|
|
+ juce::String open (const juce::BigInteger&, const juce::BigInteger& outs, double, int) override
|
|
|
+ {
|
|
|
+ close();
|
|
|
+ outsNow = outs;
|
|
|
+ outsNow.setRange (2, juce::jmax (0, outsNow.getHighestBit() - 1), false);
|
|
|
+ data.setSize (2, block190ud);
|
|
|
+ opened = true;
|
|
|
+ startThread();
|
|
|
+ return {};
|
|
|
+ }
|
|
|
+ void close() override
|
|
|
+ {
|
|
|
+ stop();
|
|
|
+ stopThread (10000);
|
|
|
+ opened = false;
|
|
|
+ }
|
|
|
+ bool isOpen() override { return opened; }
|
|
|
+ void start (juce::AudioIODeviceCallback* cb) override
|
|
|
+ {
|
|
|
+ if (! opened || cb == nullptr)
|
|
|
+ return;
|
|
|
+ cb->audioDeviceAboutToStart (this);
|
|
|
+ const juce::ScopedLock sl (callbackLock);
|
|
|
+ callback = cb;
|
|
|
+ }
|
|
|
+ void stop() override
|
|
|
+ {
|
|
|
+ juce::AudioIODeviceCallback* old = nullptr;
|
|
|
+ {
|
|
|
+ const juce::ScopedLock sl (callbackLock);
|
|
|
+ old = std::exchange (callback, nullptr);
|
|
|
+ }
|
|
|
+ if (old != nullptr)
|
|
|
+ old->audioDeviceStopped();
|
|
|
+ }
|
|
|
+ bool isPlaying() override { return callback != nullptr; }
|
|
|
+ juce::String getLastError() override { return {}; }
|
|
|
+ int getCurrentBufferSizeSamples() override { return block190ud; }
|
|
|
+ double getCurrentSampleRate() override { return rate190ud; }
|
|
|
+ int getCurrentBitDepth() override { return 32; }
|
|
|
+ juce::BigInteger getActiveOutputChannels() const override { return outsNow; }
|
|
|
+ juce::BigInteger getActiveInputChannels() const override { return {}; }
|
|
|
+ int getOutputLatencyInSamples() override { return block190ud; }
|
|
|
+ int getInputLatencyInSamples() override { return 0; }
|
|
|
+
|
|
|
+private:
|
|
|
+ void run() override
|
|
|
+ {
|
|
|
+ while (! threadShouldExit())
|
|
|
+ {
|
|
|
+ {
|
|
|
+ const juce::ScopedLock sl (callbackLock);
|
|
|
+ if (callback != nullptr)
|
|
|
+ {
|
|
|
+ callback->audioDeviceIOCallbackWithContext (nullptr, 0, data.getArrayOfWritePointers(), data.getNumChannels(), block190ud, {});
|
|
|
+ if (recording.load() && capture != nullptr)
|
|
|
+ {
|
|
|
+ const auto at = captured.load();
|
|
|
+ const auto n = juce::jmin (block190ud, (int) capture->size() - at);
|
|
|
+ if (n > 0)
|
|
|
+ {
|
|
|
+ std::copy (data.getReadPointer (0), data.getReadPointer (0) + n, capture->begin() + at);
|
|
|
+ captured.store (at + n);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ juce::Thread::sleep (2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ juce::BigInteger outsNow;
|
|
|
+ juce::AudioBuffer<float> data;
|
|
|
+ juce::CriticalSection callbackLock;
|
|
|
+ juce::AudioIODeviceCallback* callback = nullptr;
|
|
|
+ bool opened = false;
|
|
|
+};
|
|
|
+
|
|
|
+struct PitchType final : juce::AudioIODeviceType
|
|
|
+{
|
|
|
+ PitchType() : juce::AudioIODeviceType ("Sampler pitch test") {}
|
|
|
+ void scanForDevices() override {}
|
|
|
+ juce::StringArray getDeviceNames (bool input) const override { return input ? juce::StringArray() : juce::StringArray ("Pitch test device"); }
|
|
|
+ int getDefaultDeviceIndex (bool input) const override { return input ? -1 : 0; }
|
|
|
+ int getIndexOfDevice (juce::AudioIODevice* d, bool input) const override { return d != nullptr && ! input ? 0 : -1; }
|
|
|
+ bool hasSeparateInputsAndOutputs() const override { return false; }
|
|
|
+ juce::AudioIODevice* createDevice (const juce::String& out, const juce::String&) override
|
|
|
+ {
|
|
|
+ return out == "Pitch test device" ? new PitchDevice() : nullptr;
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+bool writeSine (const juce::File& file, double seconds)
|
|
|
+{
|
|
|
+ juce::AudioBuffer<float> b (1, (int) (seconds * rate190ud));
|
|
|
+ for (int i = 0; i < b.getNumSamples(); ++i)
|
|
|
+ b.setSample (0, i, (float) (0.5 * std::sin (2.0 * juce::MathConstants<double>::pi * 440.0 * i / rate190ud)));
|
|
|
+ file.deleteFile();
|
|
|
+ juce::WavAudioFormat wav;
|
|
|
+ std::unique_ptr<juce::AudioFormatWriter> w (wav.createWriterFor (file.createOutputStream().release(), rate190ud, 1, 32, {}, 0));
|
|
|
+ return w != nullptr && w->writeFromAudioSampleBuffer (b, 0, b.getNumSamples());
|
|
|
+}
|
|
|
+
|
|
|
+std::vector<float> readLeft (const juce::File& file)
|
|
|
+{
|
|
|
+ juce::WavAudioFormat wav;
|
|
|
+ std::unique_ptr<juce::AudioFormatReader> reader (wav.createReaderFor (file.createInputStream().release(), true));
|
|
|
+ if (reader == nullptr)
|
|
|
+ return {};
|
|
|
+ juce::AudioBuffer<float> b ((int) reader->numChannels, (int) reader->lengthInSamples);
|
|
|
+ reader->read (&b, 0, b.getNumSamples(), 0, true, true);
|
|
|
+ return { b.getReadPointer (0), b.getReadPointer (0) + b.getNumSamples() };
|
|
|
+}
|
|
|
+
|
|
|
+// the pitch of a (near) pure tone in [from, from + n), cents from 440 Hz, by interpolated upward zero crossings; NaN when
|
|
|
+// the window has too few
|
|
|
+double centsAt (const std::vector<float>& x, int from, int n)
|
|
|
+{
|
|
|
+ std::vector<double> t;
|
|
|
+ for (int i = juce::jmax (0, from); i + 1 < juce::jmin ((int) x.size(), from + n); ++i)
|
|
|
+ if (x[(std::size_t) i] <= 0.0f && x[(std::size_t) i + 1] > 0.0f)
|
|
|
+ t.push_back (i + (double) x[(std::size_t) i] / ((double) x[(std::size_t) i] - (double) x[(std::size_t) i + 1]));
|
|
|
+ if (t.size() < 4)
|
|
|
+ return std::numeric_limits<double>::quiet_NaN();
|
|
|
+ const auto hz = (double) (t.size() - 1) * rate190ud / (t.back() - t.front());
|
|
|
+ return 1200.0 * std::log2 (hz / 440.0);
|
|
|
+}
|
|
|
+
|
|
|
+// where the tone ends: its last upward zero crossing (an audio clip holds its last value after its file, so the level
|
|
|
+// alone does not end)
|
|
|
+int soundEnd (const std::vector<float>& x)
|
|
|
+{
|
|
|
+ for (int i = (int) x.size() - 2; i >= 0; --i)
|
|
|
+ if (x[(std::size_t) i] <= 0.0f && x[(std::size_t) i + 1] > 0.0f && std::abs (x[(std::size_t) i + 1] - x[(std::size_t) i]) > 0.001f)
|
|
|
+ return i;
|
|
|
+ return -1;
|
|
|
+}
|
|
|
+
|
|
|
+float stepValue (double semitones) { return (float) (0.5 + semitones / 96.0); } // (channelPitchSemitones' range: ±48)
|
|
|
+} // namespace
|
|
|
+
|
|
|
+juce::String AudioEngine::samplerPitch190udSelfTest (const std::function<void (const juce::String&)>& log)
|
|
|
+{
|
|
|
+ auto say = [&log] (const juce::String& line) {
|
|
|
+ if (log)
|
|
|
+ log (line);
|
|
|
+ };
|
|
|
+ const auto folder = juce::File::getSpecialLocation (juce::File::tempDirectory)
|
|
|
+ .getChildFile ("lynx-pitch190ud-" + juce::String::toHexString (juce::Random::getSystemRandom().nextInt64()));
|
|
|
+ folder.createDirectory();
|
|
|
+ struct Cleanup
|
|
|
+ {
|
|
|
+ juce::File f;
|
|
|
+ ~Cleanup()
|
|
|
+ {
|
|
|
+ f.deleteRecursively();
|
|
|
+ PitchDevice::capture = nullptr;
|
|
|
+ PitchDevice::recording = false;
|
|
|
+ }
|
|
|
+ } cleanup { folder };
|
|
|
+ const auto sine = folder.getChildFile ("sine440.wav"), shortSine = folder.getChildFile ("sine440-3s.wav");
|
|
|
+ if (! writeSine (sine, 8.0) || ! writeSine (shortSine, 3.0))
|
|
|
+ return "ERROR can't write the test samples in " + folder.getFullPathName();
|
|
|
+
|
|
|
+ juce::StringArray errors;
|
|
|
+ int checks = 0;
|
|
|
+ auto check = [&] (const juce::String& what, bool ok, const juce::String& detail = {}) {
|
|
|
+ ++checks;
|
|
|
+ say ((ok ? "ok " : "FAIL ") + what + (detail.isNotEmpty() ? " (" + detail + ")" : juce::String()));
|
|
|
+ if (! ok)
|
|
|
+ errors.add (what + (detail.isNotEmpty() ? " (" + detail + ")" : juce::String()));
|
|
|
+ };
|
|
|
+ auto cents = [] (double c) { return std::isnan (c) ? juce::String ("none") : juce::String (c, 1) + " cents"; };
|
|
|
+ auto near = [] (double c, double want, double tolerance) { return ! std::isnan (c) && std::abs (c - want) <= tolerance; };
|
|
|
+
|
|
|
+ // a song: one channel (a Sampler note held 3 bars, or an audio clip of 3 bars) at 120 BPM; `steps`: the PITCH
|
|
|
+ // automation step 0 -> +2 at 1 s and +2 -> -5 at 2 s
|
|
|
+ struct Case
|
|
|
+ {
|
|
|
+ const char* name;
|
|
|
+ bool clip = false, keep = false, steps = true, shortSample = false;
|
|
|
+ int key = 60;
|
|
|
+ float clipPitch = 0.0f;
|
|
|
+ };
|
|
|
+ auto makeSong = [&] (const Case& k) {
|
|
|
+ Song s;
|
|
|
+ s.bpm = 120.0;
|
|
|
+ s.mixer = Song::defaultMixer (2);
|
|
|
+ s.mixer[0].effects.clear();
|
|
|
+ const auto bar = s.barTicks();
|
|
|
+ ChannelDef c;
|
|
|
+ c.instrument = k.clip ? InstrumentKind::audioClip : InstrumentKind::sampler;
|
|
|
+ c.samplePath = (k.shortSample ? shortSine : sine).getFullPathName().toStdString();
|
|
|
+ c.name = k.name;
|
|
|
+ c.mixerTrack = 0;
|
|
|
+ c.sampler.keepPitch = k.keep;
|
|
|
+ s.channels.push_back (c);
|
|
|
+ auto& p = s.patterns.emplace_back();
|
|
|
+ p.lengthTicks = 4 * bar;
|
|
|
+ if (! k.clip)
|
|
|
+ {
|
|
|
+ p.notes.push_back ({ 0, 3 * bar, 0, k.key, 0.8f });
|
|
|
+ Clip pc;
|
|
|
+ pc.kind = ClipKind::pattern;
|
|
|
+ pc.pattern = 0;
|
|
|
+ pc.length = 4 * bar;
|
|
|
+ s.playlist.push_back (pc);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Clip ac;
|
|
|
+ ac.kind = ClipKind::audio;
|
|
|
+ ac.channel = 0;
|
|
|
+ ac.length = 3 * bar;
|
|
|
+ ac.pitch = k.clipPitch;
|
|
|
+ s.playlist.push_back (ac);
|
|
|
+ }
|
|
|
+ if (k.steps)
|
|
|
+ {
|
|
|
+ Automation a;
|
|
|
+ a.name = "Pitch";
|
|
|
+ a.target = { AutomationTargetKind::channelParam, 0, 0, channelPitchParam };
|
|
|
+ const auto t1 = bar / 2, t2 = bar; // 1 s, 2 s
|
|
|
+ a.points = { { 0, stepValue (0), 0.0f }, { t1, stepValue (0), 0.0f }, { t1 + 1, stepValue (2), 0.0f }, { t2, stepValue (2), 0.0f },
|
|
|
+ { t2 + 1, stepValue (-5), 0.0f }, { 4 * bar, stepValue (-5), 0.0f } };
|
|
|
+ s.automations.push_back (a);
|
|
|
+ Clip ac;
|
|
|
+ ac.kind = ClipKind::automation;
|
|
|
+ ac.automation = 0;
|
|
|
+ ac.track = 2;
|
|
|
+ ac.length = 4 * bar;
|
|
|
+ s.playlist.push_back (ac);
|
|
|
+ }
|
|
|
+ s.mode = PlayMode::song;
|
|
|
+ return s;
|
|
|
+ };
|
|
|
+ exportopts::Options options;
|
|
|
+ options.format = exportopts::Format::wav;
|
|
|
+ options.wavBits = 32;
|
|
|
+ options.sampleRate = rate190ud;
|
|
|
+ options.tail = exportopts::TailMode::leave;
|
|
|
+ options.pluginWarmUp = false;
|
|
|
+ auto render = [&] (const Case& k) {
|
|
|
+ const auto file = folder.getChildFile (juce::String (k.name) + (k.steps ? "" : "-plain") + ".wav");
|
|
|
+ ExportJob job (makeSong (k), options, file);
|
|
|
+ job.setExactFrames ((std::int64_t) (7.0 * rate190ud));
|
|
|
+ juce::String error;
|
|
|
+ if (! job.run ({}, error))
|
|
|
+ {
|
|
|
+ errors.add (juce::String (k.name) + ": " + error);
|
|
|
+ return std::vector<float>();
|
|
|
+ }
|
|
|
+ return readLeft (file);
|
|
|
+ };
|
|
|
+
|
|
|
+ // --- 1. offline: the automation step is heard one block after it --------------------------------------------------
|
|
|
+ const int s1 = (int) rate190ud, s2 = (int) (2.0 * rate190ud), w = 2048;
|
|
|
+ for (const auto& k : { Case { "Sampler note" }, Case { "audio clip", true }, Case { "keep length note at G5", false, true, true, true, 67 },
|
|
|
+ Case { "audio clip with its own +3 st", true, false, true, true, 60, 3.0f } })
|
|
|
+ {
|
|
|
+ const auto out = render (k);
|
|
|
+ const auto base = (k.clip ? (double) k.clipPitch : (double) (k.key - 60)) * 100.0;
|
|
|
+ const auto before = centsAt (out, s1 - block190ud - w, w), after1 = centsAt (out, s1 + block190ud, w),
|
|
|
+ after2 = centsAt (out, s2 + block190ud, w);
|
|
|
+ // (a voice on a pitch shifter: its restarted shifter settles within a few cents in its first blocks, then exact)
|
|
|
+ const auto shifted = k.keep || k.clipPitch != 0.0f;
|
|
|
+ const auto first = shifted ? 5.0 : 2.0;
|
|
|
+ const auto settled1 = centsAt (out, s1 + 10 * block190ud, 4096), settled2 = centsAt (out, s2 + 10 * block190ud, 4096);
|
|
|
+ check (juce::String ("offline, ") + k.name + ": before the step", near (before, base, 2.0), cents (before));
|
|
|
+ check (juce::String ("offline, ") + k.name + ": +2 st one block after the step", near (after1, base + 200.0, first), cents (after1));
|
|
|
+ check (juce::String ("offline, ") + k.name + ": -5 st one block after the second step", near (after2, base - 500.0, first), cents (after2));
|
|
|
+ check (juce::String ("offline, ") + k.name + ": exact 10 blocks after each step", near (settled1, base + 200.0, 1.0) && near (settled2, base - 500.0, 1.0),
|
|
|
+ cents (settled1) + ", " + cents (settled2));
|
|
|
+ if (k.shortSample) // the length: kept by the shifter of a keep-length note; a clip's speed follows the channel's pitch
|
|
|
+ {
|
|
|
+ const auto plain = render ({ k.name, k.clip, k.keep, false, true, k.key, k.clipPitch });
|
|
|
+ const auto endSteps = soundEnd (out), endPlain = soundEnd (plain);
|
|
|
+ const auto moved = (endSteps - endPlain) / rate190ud;
|
|
|
+ if (k.keep)
|
|
|
+ check (juce::String ("offline, ") + k.name + ": its length stays (the shifter moves the transposition)", std::abs (moved) < 0.01,
|
|
|
+ juce::String (moved, 4) + " s");
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // the clip read 1 s at x1, 1 s at 2^(2/12), the rest at 2^(-5/12): 3 s of file end at 1 + 1 + (3 - 1 - 1.1225) / 0.7492 s
|
|
|
+ const auto expect = 2.0 + (3.0 - 1.0 - std::exp2 (2.0 / 12.0)) / std::exp2 (-5.0 / 12.0) - 3.0;
|
|
|
+ check (juce::String ("offline, ") + k.name + ": its speed follows the channel's pitch (it ends where the file runs out)",
|
|
|
+ std::abs (moved - expect) < 0.01, juce::String (moved, 4) + " s, expected " + juce::String (expect, 4));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // --- 2. live: the header's PITCH knob while a note / a clip sounds --------------------------------------------------
|
|
|
+ auto live = [&] (const Case& k, const std::function<void (Song&)>& edit, const juce::String& what) {
|
|
|
+ AudioEngine engine (false);
|
|
|
+ engine.player.setProcessor (&engine.graph);
|
|
|
+ engine.deviceManager.addAudioDeviceType (std::make_unique<PitchType>());
|
|
|
+ if (const auto e = engine.deviceManager.initialise (0, 2, nullptr, true); e.isNotEmpty())
|
|
|
+ {
|
|
|
+ errors.add ("open the stand-in device: " + e);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ engine.deviceManager.addAudioCallback (&engine);
|
|
|
+ engine.setSong (makeSong (k));
|
|
|
+ for (int i = 0; i < 20; ++i) // (the rack is built and published by the engine's timer)
|
|
|
+ {
|
|
|
+ engine.timerCallback();
|
|
|
+ juce::Thread::sleep (10);
|
|
|
+ }
|
|
|
+ std::vector<float> out ((std::size_t) (2.0 * rate190ud), 0.0f);
|
|
|
+ PitchDevice::capture = &out;
|
|
|
+ PitchDevice::captured = 0;
|
|
|
+ engine.stop();
|
|
|
+ engine.rewind();
|
|
|
+ engine.timerCallback();
|
|
|
+ PitchDevice::recording = true;
|
|
|
+ engine.startPlayback();
|
|
|
+ auto waitFor = [&] (int frames) {
|
|
|
+ const auto since = juce::Time::getMillisecondCounter();
|
|
|
+ while (PitchDevice::captured.load() < frames && juce::Time::getMillisecondCounter() - since < 30000)
|
|
|
+ {
|
|
|
+ engine.timerCallback();
|
|
|
+ juce::Thread::sleep (1);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ waitFor ((int) (0.6 * rate190ud));
|
|
|
+ const auto editAt = PitchDevice::captured.load();
|
|
|
+ engine.editSong (edit); // (as the header knob: ChannelHeaderControls' FrameKnob)
|
|
|
+ waitFor ((int) out.size());
|
|
|
+ PitchDevice::recording = false;
|
|
|
+ engine.stop();
|
|
|
+ for (int i = 0; i < 10; ++i)
|
|
|
+ {
|
|
|
+ engine.timerCallback();
|
|
|
+ juce::Thread::sleep (5);
|
|
|
+ }
|
|
|
+ engine.deviceManager.removeAudioCallback (&engine);
|
|
|
+ engine.deviceManager.closeAudioDevice();
|
|
|
+ PitchDevice::capture = nullptr;
|
|
|
+
|
|
|
+ const auto before = centsAt (out, editAt - 4096, 4096);
|
|
|
+ // the first block after the edit whose pitch is the new one
|
|
|
+ int heardAfter = -1;
|
|
|
+ for (int b = 0; b < 40 && heardAfter < 0; ++b)
|
|
|
+ if (near (centsAt (out, editAt + b * block190ud, 1024), 200.0, 3.0))
|
|
|
+ heardAfter = b;
|
|
|
+ const auto settled = centsAt (out, editAt + 8 * block190ud, 4096);
|
|
|
+ const auto tail = centsAt (out, (int) out.size() - 4096, 4096);
|
|
|
+ check ("live, " + what + ": before the edit", near (before, 0.0, 2.0), cents (before));
|
|
|
+ check ("live, " + what + ": the new pitch is heard within two device blocks of the edit", heardAfter >= 0 && heardAfter <= 2,
|
|
|
+ heardAfter < 0 ? juce::String ("never") : "block " + juce::String (heardAfter) + " after the edit");
|
|
|
+ check ("live, " + what + ": it stays there and the sound goes on", near (settled, 200.0, 2.0) && near (tail, 200.0, 2.0),
|
|
|
+ cents (settled) + ", at the end " + cents (tail));
|
|
|
+ };
|
|
|
+ auto knob = [] (Song& s) { s.channels[0].sampler.pitch = 2.0f; }; // (the PITCH knob: ChannelSettings headerKnob "Pitch")
|
|
|
+ live ({ "live note", false, false, false }, knob, "Sampler note, the channel's PITCH knob");
|
|
|
+ live ({ "live clip", true, false, false }, knob, "audio clip, the channel's PITCH knob");
|
|
|
+ // the Sampler page's time-stretching PITCH knob while it is dragged (samplerpage::turnStretchPitch, ChannelSettings'
|
|
|
+ // stretchPitchKnob; FL switches Resample to Auto when the drag ends)
|
|
|
+ live ({ "live note stretch knob", false, false, false }, [] (Song& s) { samplerpage::turnStretchPitch (s.channels[0].sampler, 200, false); },
|
|
|
+ "Sampler note, the Sampler page's PITCH knob (dragged)");
|
|
|
+
|
|
|
+ say ("checks: " + juce::String (checks) + ", failed: " + juce::String (errors.size()));
|
|
|
+ return errors.isEmpty() ? "OK " + juce::String (checks) + " checks" : "FAIL: " + errors.joinIntoString ("; ");
|
|
|
+}
|
|
|
+} // namespace lynx
|