Commit Graph
73 Commits
Author SHA1 Message Date
Brandon Thomas 6d268d5623 Merge remote-tracking branch 'origin/main' into m/672
# Conflicts:
#	ROADMAP.md
#	docs/gaps.md
2026-10-19 03:09:47 -04:00
Brandon Thomas a8fa1e53d3 Merge remote-tracking branch 'origin/main' into m/672
# Conflicts:
#	ROADMAP.md
2026-10-19 03:04:40 -04:00
Brandon Thomas 798ee7d88f Merge remote-tracking branch 'origin/main' into m/667
# Conflicts:
#	ROADMAP.md
2026-10-19 03:04:40 -04:00
reoniazx ef65ceafb8 fix(mix): exclude failed inserts from aux and master latency 2026-10-16 18:21:31 +08:00
reoniazx da404551b1 fix(mix): keep master automation within render blocks 2026-10-16 14:59:16 +08:00
MarekSpodBiedry 52dc4f9822 Reset clip effect EQ/compressor state on stop and seek (#442) 2026-10-13 17:53:21 +02:00
Brandon ThomasandClaude Opus 5.5 14862a5139 Merge main into #408
render_bus moved into RangeRender (#393); the bus-latency fix now applies there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 06:45:20 -04:00
Brandon Thomas 6d4f9a41a5 Merge main into #409
# Conflicts:
#	ROADMAP.md
#	docs/architecture.md
2026-10-13 06:44:55 -04:00
Brandon Thomas 58a0482712 Merge pull request #335 from reoniazx/fix/fade-drag-waveform-preview
Fix clip fade editing and add live waveform previews
2026-10-13 06:31:12 -04:00
Brandon Thomas 123ae65e2b Merge pull request #306 from grovebit/plugin-safety
Plugin safety: read plugin state off the audio thread, keep refused settings, contain NaN plugins
2026-10-13 06:30:53 -04:00
Brandon Thomas a8594684a1 Merge pull request #393 from grovebit/bounce-streaming
Stream bounces to disk and keep the app responsive while bouncing
2026-10-13 06:30:29 -04:00
Brandon ThomasandClaude Opus 5.5 baea184bd1 Keep one VST3 controller-sync path after merging #306's latest
The landing branch already syncs host-set values to the controller before
saving state (lock-free atomics + EditorLink::sync_param); the PR's later
ControllerPending table did the same, so keep one. Keeps the PR's new
'a loaded state replaces earlier edits' assertion, which passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 06:26:54 -04:00
Brandon Thomas 0c30ecffcc Merge #367's latest into the landing branch 2026-10-13 06:25:56 -04:00
Brandon Thomas 7a6df4cbbd Merge #306's latest into the landing branch 2026-10-13 06:25:56 -04:00
grovebit 2895fa7dd0 Merge origin/main into plugin-transport-midi
#304's MIDI Track Offset shifts the block schedule_notes reads, which
now carries this branch's controllers too. chase_controllers takes the
same offset, so a seek chases the controller values in effect where the
offset puts the track, not at the raw transport position. New test: with
the track 0.5 s late, starting at 1.25 s chases the sustain pedal still
down (without the offset it sent the pedal-up that only plays at 1.5 s).

Also: reset() sets the chase flag beside #301's alignment flush, the
VST3 Instance keeps #400's set_normalized beside midi_mapping, and the
mix tests keep #210's Keys plugin beside this branch's Clock and Ears.
2026-10-13 11:06:09 +01:00
grovebit 776a7af06c Merge origin/main into plugin-safety
#400 (fixes #257) made Vst3Plugin::save_state tell the edit controller
the values the host set before taking the snapshot. This branch reads
plugin state on the UI thread through EditorLink instead, and removes
Vst3Plugin::save_state, so keeping its side of that conflict would have
dropped the fix.

The values now wait in a ControllerPending table shared by the instance
and its EditorLink: one AtomicU64 slot per parameter, which set_param
fills on the audio thread without locking or allocating.
EditorLink::save_state sends the waiting values with setParamNormalized
under its lock, before it reads the controller's state. A state load
clears them, as #400's refresh did. Instance::set_normalized, which only
the old save_state used, is gone. #400's round-trip test passes, plus a
check that a loaded state replaces earlier host edits.

#327's a_new_instance_replaces_a_matching_one_in_its_slot told the two
instances apart through MixEngine::capture_states, which this branch
removes (states are read on the UI thread). The two instances now
differ in gain instead (-6 and -20 dB), and the test checks that the new
level plays and that the old instance is retired.

Also: Side::new sets #210's old_sessions field.
2026-10-13 10:58:07 +01:00
Brandon Thomas e0deb3f4e5 Merge main into #335 2026-10-13 05:55:06 -04:00
Brandon ThomasandClaude Opus 5.5 ca1a6d443e Fix build after merging main into #306
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 05:31:48 -04:00
Brandon Thomas 056bc288c4 Merge main into #306 2026-10-13 05:31:14 -04:00
Brandon Thomas 5051b4a45f Merge main into #393 2026-10-13 05:12:31 -04:00
Brandon Thomas e32c16b82e Merge main into #367 2026-10-13 05:11:18 -04:00
NetterSilver 446a059faf Mix: delay compensation covers the master faders' inserts (#351)
The master faders process the main mix after every track and aux return has been
summed, so a lookahead insert on them (the Maximizer: 71 samples at 48 kHz)
delays the whole main mix. The mix's compensation latency, which a bounce drops
from the head of the render, left it out, so the bounce came out late by the
insert's latency (the voice was 71 samples later than in the same mix without
the Maximizer).

The latency of the master inserts is now part of the mix latency. With Delay
Compensation off nothing changes.
2026-10-13 11:11:12 +02:00
NetterSilver 5cd155bb64 Mix: a bus bounce compensates the aux returns onto it (#246)
render_bus dropped only the track-insert latency from a bus, but an aux that
returns onto a bus delays it by the slowest aux return as well. With Delay
Compensation on, a bounce of such a bus came out late (a 5 ms lookahead left
240 leading silent frames) and its last impulse fell outside the requested end.

The engine now knows which busses an aux returns onto. A bounce of one drops
the aux latency too, and the tracks routed straight to that bus wait for it, as
the tracks routed to the main mix already do, so the two kinds of signal on the
bus arrive together. Other busses and the main mix are unchanged.
2026-10-13 11:01:34 +02:00
Brandon Thomas 9c7e5018b3 Merge pull request #333 from grovebit/strip-silence-long
Stop Strip Silence deleting clips late in long selections
2026-10-13 04:43:41 -04:00
Brandon Thomas 0ef67b795b Merge pull request #210 from grovebit/realtime-safety
Stop allocating and freeing memory on the audio thread
2026-10-13 04:43:00 -04:00
Brandon Thomas 6dfa00590b Merge pull request #304 from marcoarnulfo/fix/midi-track-offsets
Apply MIDI track offsets when scheduling notes
2026-10-13 04:29:40 -04:00
Brandon Thomas 75e019dde3 Merge pull request #301 from marcoarnulfo/fix/seek-flushes-state
Locate clears plugin and delay-compensation state
2026-10-13 04:29:11 -04:00
Brandon Thomas e5ca13d07f Merge pull request #327 from Limestudio90/fix-replaced-instance
mix: a newly adopted plugin instance replaces a matching one in its slot
2026-10-13 04:29:07 -04:00
Brandon ThomasandClaude Opus 5.5 ad8beac9b4 Look up the MIDI track offset without allocating on the audio thread
schedule_notes ran format!() every block for every instrument track; scan
the edit values by prefix instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 04:21:20 -04:00
grovebit f188b66209 Leave controller events before a clip's start silent
A MIDI clip whose start was trimmed may keep the events before its new
start at negative ticks, hidden until the start is trimmed out again
(midi-clip-trim does this). The controller loop clamped every event's
tick to 0, so a hidden sustain pedal or pitch bend played at the clip
start, and the chase after a seek counted hidden values as the state
in effect.

Both loops now skip events before tick 0. Nothing changes for clips
without hidden events: notes and controllers made by the app never
start before tick 0.

Test: a sustain-pedal event at tick -480 is neither sent when the clip
starts nor chased after a seek into the clip, while a visible
controller is still chased.
2026-10-13 02:42:15 +01:00
grovebit d19d44cd1b Cap bogus plugin latency so offline renders can't stall
CLAP and VST3 plugins report their latency unchecked (up to u32::MAX
samples), and an offline render skips that many samples before its first
block, inside one call. A plugin reporting garbage made a bounce render
about 25 hours of audio before producing anything, with the UI stuck in
that call: no progress, no Cancel. Freeze and Commit stalled the same
way.

- A strip reports at most 2^20 samples of latency (about 22 s at 48 kHz),
  the most delay compensation could align anyway (MAX_LATENCY, shared
  with the delay lines). That holds for the latency an aux's inserts
  report before the aux is processed, too.
- RangeRender::next_block renders one block per call, returning no frames
  while it skips the latency, so a bounce yields to the UI there too.
2026-10-12 23:47:24 +01:00
grovebit 5755795663 Stream bounces to disk instead of rendering them in memory
A bounce rendered the whole mix (or bus) into memory and then encoded a
second copy, and the render silently stopped at 2^29 samples: about 93
minutes of stereo at 48 kHz, 31 of 5.1, 15 of 7.1.4. Longer bounces came
out cut short while file.bounce_mix still reported the requested length.

- audio-io: FileEncoder writes WAV/BWF (RF64 above 4 GiB), AIFF and FLAC
  block by block into any Write + Seek, byte for byte what encode writes
  for the whole buffer. check_room fails up front when an AIFF (4 GiB) or
  a FLAC (2^36 frames) can't hold the bounce. AIFF and FLAC encode run on
  the same writers; their output is unchanged.
- mix: RangeRender renders the main mix or one bus over a range of any
  length, a block at a time; render_range and render_bus (in memory,
  still capped) are built on it.
- engine: io::Bounce streams the main mix or a bus, or its stereo
  fold-down, into "<name>.part" next to the target, syncs it and renames
  it into place, so a failed bounce leaves no partial file and keeps the
  old one. In the browser it encodes into memory (failing instead of
  aborting when memory runs out) and delivers the file as before.
  Normalize renders twice (peak, then the scaled write); levels are
  measured as blocks are written. Stems stream the same way and share the
  4-hour limit.

A 100-minute bounce of the demo session now writes all 288,000,000
frames with 83 MB peak memory.
2026-10-12 23:46:13 +01:00
reoniazx 4ac47b3a7f Add draggable midpoint curvature for clip fades 2026-10-13 02:48:00 +08:00
Limestudio90andClaude Opus 5.5 acaa91008c mix: a newly adopted instance replaces a matching one in its slot
When a third-party plugin was removed and re-added (same id, same channel
count) and both session updates reached the audio thread in one drain, sync
saw an unchanged slot, kept the old instance and retired the new one as an
unclaimed leftover. The host-side editor belonged to the new, retired
instance, so reopening it failed with "the plugin is gone", and the old
instance kept running with no editor.

The host only hands over an instance when it no longer tracks the one in
the slot, so an instance waiting for a slot now always replaces it (inserts
and instruments). Debug logs record instance creation and release on the
UI thread.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 19:27:12 +02:00
grovebit dab2bb956c Don't let Strip Silence delete clips past what one render holds
Strip Silence rendered the whole selection at once, and a render stops
at 2^29 samples over all channels: 93 minutes of stereo at 48 kHz, 46
at 96 kHz. Everything past that read as silence, so the clips there
were deleted. A 105-minute selection on a stereo track lost its clip at
100 minutes.

It now renders at most 2^24 samples at a time, only where unmuted audio
clips play, into a streaming version of the silence detector
(`SilenceScan`, which `non_silent_ranges` now runs on). A window takes
at most 64 MB instead of up to 2 GiB, and more than a day of clips is
refused rather than scanned for minutes. `render_clips` now skips clips
outside its range before looking up their clip effects, so a track of
5,000 clips strips as fast as before. Results are unchanged on the demo
sessions and on 10 minutes of tone bursts that cross window edges.
2026-10-12 18:12:00 +01:00
grovebit c9e53ee704 Look up clip effects and Real-Time Properties without allocating
Once a session has any edit.values entry (click settings, Real-Time
Properties, clip effects), MixEngine::render allocated every block,
although the crate docs say steady-state rendering doesn't: every audio
clip formatted two Strings and collected a Vec to look up its clip
effects, and every MIDI clip formatted four keys for its Real-Time
Properties. Strips render on rayon's workers while the audio callback
waits for them, or on the audio thread itself below 4 strips.

Lookups now format their keys on the stack (Key) and range over
edit.values with &str bounds. A new test checks that Real-Time
Properties still reach the instrument.

A counting allocator on all threads, over 1000 blocks of the demo
session with a clip effect on every clip and Real-Time Properties on
every track, saw 10 to 43 allocations per block before and none after,
apart from rayon's job queue (a new chunk every 63 blocks) and the
one-time setup of each clip's effects when it first plays.
2026-10-12 16:02:37 +01:00
grovebit 56ffce6dec Take a plugin that puts out NaN out of the mix instead of silencing it
One insert or instrument putting out NaN or infinity silenced the whole
mix: the value spread through the busses and the main mix (NaN plus
anything is NaN), and the output guard turned all of it into silence.
It can also poison the state of filters, reverbs and compressors
downstream, which then stay silent after the plugin has calmed down.

After each insert (track or master) and each instrument processes, the
engine checks its block. If the block holds NaN or infinity, the engine
silences that block of the strip and skips the plugin until the next
MixEngine::reset (playback starts or stops), which resets it and tries
it again. Meanwhile the strip plays on without it, as if bypassed. The
check costs about 60 ns per insert for a stereo 512-sample block.

StripMeter::plugin_failures counts how often a strip lost a plugin and
names the slot of the latest, so the UI names that plugin in the status
line each time, also when it fails again after a restart. The AU host
no longer zeroes non-finite output itself, so Audio Units are taken out
and named like CLAP and VST3 plugins.
2026-10-12 15:50:58 +01:00
grovebit 4c21ff8fe4 Keep a plugin's saved settings when it refuses to load them
When a third-party plugin refused its stored state (a newer plugin
version that can't read it, a damaged blob), it ran with its defaults,
and the next save or two-minute autosave read its state back into the
session: the saved settings were gone, even after updating the plugin.

create_instance now says whether the plugin refused the state
(NewInstance::refused_state). Playback leaves such an instance out of
the states it reads for saving, so the session keeps the stored state,
until the plugin's own editor is opened: from then on its state is the
user's work. Parameter values are saved apart from the state, so edits
made with SoundCraft's own controls survive either way.
2026-10-12 15:50:58 +01:00
grovebit 793432bbfc Read plugin state on the UI thread, not the audio thread
Saving, bouncing and the two-minute autosave read every third-party
plugin's state through the audio callback: a command made the callback
call each plugin's save_state between two blocks and reply, while the
UI waited for up to 2 s. So:
- CLAP's clap.state and VST3's getState ran on the audio thread,
  although both formats want them on the main thread.
- The callback allocated and waited on the plugins; a plugin with a
  large state (a sampler) could make the audio drop out on every save
  and autosave.
- Without a running callback (a stalled or lost device), every save
  waited 2 s and then kept stale plugin states.

Each instance now hands Side::prepare a state reader before it leaves
for the audio thread, the way it hands over its editor handle. CLAP's
GuiLink and VST3's EditorLink (which now holds the component as well)
read the state under their lock; Audio Units get a StateLink that does
the same. Each instance cuts its link off before it is destroyed, so a
reader never calls into a dead plugin. Player::capture_states reads
them on the calling (UI) thread, and the CaptureStates command is gone.

Each host's tests read the state while another thread processes the
instance, and get nothing once it is dropped. Playback reads states
with no audio thread at all.
2026-10-12 15:50:58 +01:00
Marco Arnulfo 4bacfb13d5 Apply MIDI track offsets when scheduling notes (fixes #234)
event.midi_track_offsets stored midi.offset.<track> but the note
scheduler never read it, so the render was unchanged. schedule_notes
now looks that many samples back into the clips, which plays the track
exactly as if its MIDI had been moved by the offset. The scheduler is
shared by offline bounce and realtime playback.
2026-10-12 16:48:50 +02:00
Marco Arnulfo 4235def686 Locate clears plugin and delay-compensation state (fixes #247) 2026-10-12 16:40:16 +02:00
Marco Arnulfo 3765a32b9a fix(mix): pan automation reads the same in playback and bounce (fixes #244) 2026-10-12 16:36:59 +02:00
grovebit acd9e7d54e Play MIDI controllers through instruments
Imported MIDI keeps its controller events: sustain pedal and other CCs,
pitch bend, channel and poly pressure, program changes. Playback sent
instruments only note-ons and note-offs, so a piano part lost its pedal
and bends went flat.

- Plugin::midi takes any other MIDI 1.0 channel message at a sample
  offset. The mix engine sends each clip's controllers at their sample,
  after the Real-Time Properties delay (and transpose, for poly
  pressure), on channel 1 like the notes.
- After a seek, a stop or a loop wrap, an instrument first gets Reset All
  Controllers (CC 121), then the last value each controller had on its
  track before the playhead. A pedal held before the start point is
  still down.
- CLAP: raw MIDI events when the note port speaks the MIDI dialect.
- VST3: CCs, aftertouch and pitch bend become parameter changes at their
  offset, through the plugin's IMidiMapping. It is asked once in prepare,
  on the main thread, and there is one point per parameter per block.
  Poly pressure is a PolyPressureEvent. Program changes have no VST3
  mapping and are dropped.
- AU: MusicDeviceMIDIEvent for instruments and music effects.
- The built-in synth follows the sustain pedal, pitch bend (2 semitones
  each way), Reset All Controllers and All Notes Off.
- The sampler ignores the pedal, pitch bend and Reset All Controllers
  for now.

The AU check of MIDI volume lives inside the existing DLS test. Creating
two DLSMusicDevice instances at once on two threads crashes inside the
unit, with or without this change. Two instances created one after
another render in parallel fine.
2026-10-12 02:57:22 +01:00
grovebit 33ad8264c8 Give plugins the session's tempo and transport
Hosted plugins never learned the session's tempo or where the song was:
- CLAP got a null transport;
- VST3 got a fixed 120 BPM 4/4 context that never played and counted
  processed samples as the song position;
- Audio Units had no host callbacks.
Tempo-synced delays, LFOs and arpeggiators ran at 120 BPM and ignored
the transport.

Before each block the mix engine now hands every insert, instrument and
master-fader plugin a soundcraft_dsp::Transport (Plugin::set_transport):
play and record state, tempo and meter at the block start, and the
timeline position in samples, seconds and quarter notes, with the
current bar. Built-in plugins ignore it.
- CLAP: a clap_event_transport (fixed-point beats and seconds, bar start
  and number, time signature, play and record flags).
- VST3: ProcessContext tempo, time signature, project time in samples and
  quarter notes, bar position, kPlaying and kRecording. Continuous time
  stays the processed-sample count.
- AU: kAudioUnitProperty_HostCallbacks (beat and tempo, musical time
  location, transport state 1 and 2), read from atomics the instance
  owns and frees after disposing the unit.

Loop (cycle) ranges aren't reported yet: playback keeps the loop range
to itself.
2026-10-12 02:56:55 +01:00
Brandon ThomasandClaude Opus 5.5 7a1035a3d5 Merge origin/main into sampler-instrument
#181 already pushes instrument params each block, so drop the duplicate
apply_instrument_params. Import Session Data now brings a Sampler's sample
along and remaps its source id.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 20:45:12 -04:00
Brandon Thomas 4e1c18f949 Merge pull request #181 from rollroyces/fix/soundcraft-152-instrument-level-bounce
fix(mix): push an instrument's stored params to its plugin before each block (#152)
2026-10-11 20:40:40 -04:00
Brandon ThomasandClaude Opus 5.5 3055cbb0c0 Measure the #152 regression test past parameter smoothing
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 20:37:56 -04:00
Brandon ThomasandClaude Opus 5.5 ec920cd975 Instrument params: never read insert slot A's automation; regression tests for #152
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 20:17:53 -04:00
Brandon Thomas 5243f9a2a8 Merge pull request #208 from Jafz2001/perf/reuse-mix-buffers
perf: reuse realtime mix buffers
2026-10-11 20:05:01 -04:00
Brandon Thomas 3731299851 Merge pull request #134 from vbasky/fix/104-volume-to-clip-gain
Convert only the selected volume automation into clip gain.
2026-10-11 19:50:56 -04:00