Auto125Tests.inc 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Issue #125: an automation clip kept a control linked to a hardware knob from moving, also with the song stopped.
  2. // FL 2026 [EXEC round 185b, a channel volume knob with an automation clip over the whole song, moved with the mouse]:
  3. // stopped, the moved value stays (the clip does not pull it back); playback start puts the clip's value back; moved while
  4. // playing (a flat clip and a 0->1 ramp), the value stays for the rest of that playback; stopping keeps it.
  5. // LYNX: AudioEngine::noteTweaked releases the target (RackRenderer::setReleasedSlots); the renderer forgets the released
  6. // slots when the transport starts.
  7. TEST (auto125_moved_control_leaves_its_automation_until_playback_starts)
  8. {
  9. auto song = lynx::Song::makeDefault();
  10. song.mode = lynx::PlayMode::song;
  11. song.channels.clear();
  12. song.playlist.clear();
  13. song.automations.clear();
  14. song.mixer = lynx::Song::defaultMixer (2);
  15. song.mixer[0].inputChannel = 0; // a constant through the Master's input
  16. song.mixer[0].monitor = lynx::InputMonitor::on; // (heard stopped as well as playing)
  17. const lynx::AutomationTarget target { lynx::AutomationTargetKind::mixerVolume, 0 };
  18. lynx::Automation a;
  19. a.target = target;
  20. a.points = { { 0, 0.0f, 0.0f }, { 4 * lynx::ppq, 0.0f, 0.0f } }; // the Master's fader automated down to silence
  21. song.automations.push_back (a);
  22. lynx::Clip clip;
  23. clip.kind = lynx::ClipKind::automation;
  24. clip.automation = 0;
  25. clip.length = 64 * lynx::ppq;
  26. song.playlist.push_back (clip);
  27. std::vector<int> slots;
  28. lynx::RackState::slotsOfTarget (song, target, slots);
  29. auto state = lynx::RackState::build (song, nullptr, 48000.0);
  30. lynx::RackRenderer renderer;
  31. renderer.prepare (48000.0, 512);
  32. lynx::LiveInput input;
  33. renderer.setLiveInput (&input);
  34. std::vector<float> in (512, 0.25f), l (512), r (512);
  35. input.channels[0] = in.data();
  36. input.channels[1] = in.data();
  37. input.numChannels = 2;
  38. double tick = 0.0;
  39. auto run = [&] (bool playing, int blocks) {
  40. for (int b = 0; b < blocks; ++b)
  41. {
  42. renderer.process (state.get(), playing, tick, 512, l.data(), r.data());
  43. if (playing)
  44. tick += 64.0;
  45. }
  46. return std::abs (l[511]);
  47. };
  48. CHECK (run (false, 8) < 1e-4f); // stopped, untouched: the clip's value at the position (as FL shows on opening)
  49. renderer.setReleasedSlots (slots); // moved while stopped (the knob, a linked controller)
  50. CHECK (renderer.isSlotOverridden (0));
  51. CHECK (run (false, 16) > 0.05f); // the moved value stays while stopped
  52. CHECK (run (true, 8) < 1e-4f); // playback starts: the clip drives it again
  53. CHECK (! renderer.isSlotOverridden (0));
  54. renderer.setReleasedSlots (slots); // moved while playing
  55. CHECK (run (true, 16) > 0.05f); // the clip no longer pulls it back during this playback
  56. CHECK (run (false, 8) > 0.05f); // stopping keeps the moved value
  57. CHECK (renderer.isSlotOverridden (0));
  58. CHECK (run (true, 8) < 1e-4f); // the next start: the automation again
  59. }