Skip to content

Make lib/stdlib/audio/README.md describe the API that exists - #574

Merged
godofecht merged 3 commits into
mainfrom
audio-readme-accuracy
Aug 19, 2026
Merged

godofecht merged 3 commits into
mainfrom
audio-readme-accuracy

Conversation

@godofecht

@godofecht godofecht commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Every code block in this README failed to compile. unverified: 235 -> 224.

Three sections named functions that were never written

README said Actually exists
gpu_process_buffer(input, effect_kernel) audio_gain_block(backend, buf, gain), audio_convolution_block, audio_fft_block
simd_gain_f32x8(samples, gain) audio_gain_interleaved_f32(data, frames, channels, gain)
graph_new(), graph_add_oscillator, graph_add_filter, graph_connect effect_chain_new(rate), effect_chain_set_gain_db, effect_chain_enable_lowpass, effect_chain_tick

The graph section described a node-and-edge API. What graph.flow actually provides is a value: each stage returns a new EffectChain. The section is rewritten around that rather than renamed onto it, because a signal path reads as a sequence of assignments and that is worth showing.

A parameter that was planned and never added

pattern_4 and euclidean_pattern were called with a trailing voice argument (, bass, , kick, , lead). They take no such argument. pattern_4 always plays through bass and pattern_8 through lead, and the comment in livecode.flow says why:

# Use a default instrument (bass) - caller can modify this pattern if needed

The README now states which voice each sequencer uses.

Blocks that could not run as written

Five used clock without declaring it. Two used both clock and pos at file scope with no enclosing function. A reader copying any of them hit the same errors CI now catches.

One block stays unverified, with the reason written down

The GPU example is tagged ignore= because it links runtime/audio_gpu_metal.m, which the doc example build does not compile. The prose now gives the clang line needed to build it, which it did not before.

What this turned up: issue #573

lib/stdlib/audio/scales.flow returns a fixed-size array from every function, and -> array<T, N> lowers to a pointer into the callee's dead frame:

int32_t* triad_i32(int32_t root) {
    return (int32_t[]){ root, (root + 4), (root + 7) };   // automatic storage
}
memcpy(chord, triad_i32(60), sizeof(chord));              // reads a dead frame

All 25 functions in lib/stdlib/ returning array<T, N> return garbage, silently. Filed as #573 with the repro, and added here as a strict xfail in test_coverage_known_bugs.py so it reports the moment it is fixed.

Worth being precise about what this PR claims: these blocks now compile, which is all the doc checker asserts. The one that also calls a scale function still prints garbage at runtime until #573 is fixed.

Verification

Check Result
pytest tests/ 1655 passed, 6 skipped, 1 xfailed
check_doc_examples.py --check-ledger no new unverified, 224
check_doc_links.py all links and fragments resolve

Each block was also run, not only compiled: 12 of 14 run clean, one is the ignore= GPU block, one is a fragment the harness wraps.

@godofecht

Copy link
Copy Markdown
Contributor Author

Updated: dropped the #573 xfail from this PR.

When I opened this, #573 was an open bug and recording it as a strict xfail was the right move. It is now fixed in #576, so keeping the xfail here would XPASS and fail the build the moment that lands. The real regression test ships with the fix, in tests/integration/test_array_return.py, and reads the values back rather than checking the shape of the generated C.

One correction to this PR's description. It said:

The one that also calls a scale function still prints garbage at runtime until #573 is fixed.

That no longer holds once #576 lands. scale_major(48) now returns 48 50 52 53 55 57 59. The nested progression_pop case is still broken and is tracked separately as #575.

godofecht and others added 3 commits August 19, 2026 11:45
Every code block in this README failed to compile. Three sections named
functions that were never written:

  gpu_process_buffer(input, effect_kernel)   -> audio_gain_block(backend, buf, gain)
  simd_gain_f32x8(samples, gain)             -> audio_gain_interleaved_f32(...)
  graph_new(); graph_add_oscillator(...)     -> effect_chain_new(rate); effect_chain_*

The graph section described a node-and-edge API. What exists is a value:
each stage returns a new EffectChain, so the section is rewritten around
that rather than renamed onto it.

pattern_4 and euclidean_pattern were called with a trailing voice argument.
They take no such argument; pattern_4 always plays through bass and
pattern_8 through lead, and the comment in livecode.flow ("caller can modify
this pattern if needed") shows the parameter was intended and never added.
The README now says which voice each one uses.

Five blocks used `clock` without declaring it, and two used both `clock` and
`pos` at file scope with no enclosing function. A reader copying any of them
got the same errors CI now catches.

The GPU block is tagged ignore= rather than fixed: it links
runtime/audio_gpu_metal.m, which the doc example build does not compile. The
prose now gives the clang line, which it did not before.

unverified: 235 -> 224.

This turned up issue #573. lib/stdlib/audio/scales.flow returns fixed-size
arrays from every function, and `-> array<T, N>` lowers to a pointer into
the callee's dead frame, so all 25 such functions in the stdlib return
garbage. Added as a strict xfail in test_coverage_known_bugs.py so it
reports the moment it is fixed. The blocks here compile, which is all the
doc checker asserts; the one that also runs a scale function still prints
garbage until #573 is fixed.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The xfail asserted that -> array<T, N> stops returning stack memory. #576
makes that true, so keeping it here would XPASS and fail the build the moment
that lands. The real regression test lives with the fix, in
tests/integration/test_array_return.py, and reads the values back.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
#572 changed the key format and #574 changed which blocks pass, so the
checked-in ledger conflicted. Regenerated rather than hand-merged.

unverified: 235 -> 221 with both changes applied.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@godofecht
godofecht force-pushed the audio-readme-accuracy branch from 278f3b7 to e577aba Compare August 19, 2026 10:46
@godofecht
godofecht merged commit 485b9d0 into main Aug 19, 2026
20 checks passed
@godofecht
godofecht deleted the audio-readme-accuracy branch August 19, 2026 10:50
@godofecht godofecht mentioned this pull request Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant