Skip to content

Enable set_scene_bpm and set_mesh_bpm blocks in sound toolbox#417

Merged
tracygardner merged 3 commits into
mainfrom
claude/add-sound-shadow-blocks-QAzYp
Mar 18, 2026
Merged

Enable set_scene_bpm and set_mesh_bpm blocks in sound toolbox#417
tracygardner merged 3 commits into
mainfrom
claude/add-sound-shadow-blocks-QAzYp

Conversation

@tracygardner

@tracygardner tracygardner commented Mar 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Update sound blocks to use shadow blocks

Key Changes

  • Update sound blocks to use shadow blocks

Implementation Details

  • Update sound blocks to use shadow blocks

https://claude.ai/code/session_01WHfBDw4GAS4LdEpdjWGGm2

Summary by CodeRabbit

  • New Features

    • Update sound blocks to use shadow blocks
  • Improvements

    • MIDI note and instrument parameter fields now accept connected value inputs while keeping sensible default values when left unconnected.
  • Localization

    • Updated create_instrument display strings to span two lines in multiple languages for improved readability.

Both blocks had input_value BPM fields but were missing from the toolbox.
Adds them with math_number shadow blocks defaulting to 60 BPM.

https://claude.ai/code/session_01WHfBDw4GAS4LdEpdjWGGm2
@coderabbitai

coderabbitai Bot commented Mar 18, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Toolbox and block definitions for sound were updated: MIDI note fields were converted to value inputs with shadow math_number defaults, a new create_instrument block (with frequency/attack/decay/sustain/release shadow inputs) was added to the toolbox, generators were updated to read inputs via valueToCode, and locale strings for create_instrument were reformatted with a newline.

Changes

Cohort / File(s) Summary
Toolbox updates
toolbox.js
Replaced midi_note block field defaults with inputs using shadow math_number; added create_instrument block entry with shadow math_number inputs for FREQUENCY, ATTACK, DECAY, SUSTAIN, RELEASE.
Block definitions
blocks/sound.js
Converted block inputs from field_number to input_value for MIDI note and instrument parameters; removed embedded min/max/precision and added "Number" input checks.
Code generation
generators/generators.js
Generators now use valueToCode(block, "...") with fallback defaults for NOTE and create_instrument params (60, 440, 0.1, 0.5, 0.7, 1) instead of reading static fields.
Locales (UI text)
locale/en.js, locale/de.js, locale/es.js, locale/fr.js, locale/it.js, locale/pl.js, locale/pt.js, locale/sv.js
Updated create_instrument translation strings to insert a newline between the frequency and attack segments (formatting change only).

Sequence Diagram(s)

mermaid
sequenceDiagram
rect rgba(200,200,255,0.5)
participant User
end
rect rgba(200,255,200,0.5)
participant Toolbox
participant BlockDef
participant Generator
end
User->>Toolbox: Drag create_instrument or midi_note block
Toolbox->>BlockDef: Provide block XML with shadow math_number inputs
BlockDef->>Generator: Block instance with value inputs
Generator->>Generator: valueToCode(..., fallback defaults)
Generator->>Runtime: Emit generated code (with numeric literals or expressions)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped through boxes, shadows bright and clear,

Numbers tucked in burrows, defaults kept near.
A new instrument springs, with attack, decay, release—
MIDI notes now listen, their values find peace.
Clap paws, little code, let soundfields sing with cheer!

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title refers to enabling set_scene_bpm and set_mesh_bpm blocks, but the actual changes focus on converting midi_note and create_instrument to use input_value with shadow blocks, and updating locale strings with newlines. Update the title to accurately reflect the main changes: 'Convert midi_note and create_instrument to use input_value with shadow blocks' or 'Add shadow math_number inputs to midi_note and create_instrument blocks'.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/add-sound-shadow-blocks-QAzYp
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

claude added 2 commits March 18, 2026 17:27
…adow blocks

- midi_note: NOTE field_number → input_value with math_number shadow (default 60)
- create_instrument: FREQUENCY, ATTACK, DECAY, SUSTAIN, RELEASE field_number → input_value with math_number shadows (defaults: 440, 0.1, 0.5, 0.7, 1)
- Update generators to use valueToCode instead of getFieldValue for these inputs
- Update toolbox shadow blocks accordingly, including nested midi_note in play_notes
- Revert unintended set_mesh_bpm uncomment

https://claude.ai/code/session_01WHfBDw4GAS4LdEpdjWGGm2
…elated set_scene_bpm

- Add \n before attack in create_instrument message across all locales so ATTACK, DECAY, SUSTAIN, RELEASE render on their own line
- Remove set_scene_bpm toolbox addition that was not requested

https://claude.ai/code/session_01WHfBDw4GAS4LdEpdjWGGm2

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
toolbox.js (1)

3214-3329: ⚠️ Potential issue | 🟠 Major

PR objective not met: BPM toolbox blocks are still not enabled.

set_mesh_bpm remains commented (Line [3316]-[3329]) and set_scene_bpm is not present in toolboxSound.contents, so these blocks are still inaccessible in the sound toolbox.

🔧 Proposed fix
                 {
                         kind: "block",
                         type: "play_notes",
                         inputsInline: true,
                         inputs: {
                                 ...
                         },
                 },
-                /*{
+                {
+                        kind: "block",
+                        type: "set_scene_bpm",
+                        inputs: {
+                                BPM: {
+                                        shadow: {
+                                                type: "math_number",
+                                                fields: {
+                                                        NUM: 60,
+                                                },
+                                        },
+                                },
+                        },
+                },
+                {
                         kind: "block",
                         type: "set_mesh_bpm",
                         inputs: {
                                 BPM: {
                                         shadow: {
                                                 type: "math_number",
                                                 fields: {
                                                         NUM: 60,
                                                 },
                                         },
                                 },
                         },
-                },*/
+                },
                 {
                         kind: "block",
                         type: "instrument",
                 },
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@toolbox.js` around lines 3214 - 3329, The sound toolbox still lacks BPM
blocks because the set_mesh_bpm block is left commented out and set_scene_bpm is
missing from toolboxSound.contents; uncomment the existing set_mesh_bpm block
(restore the block object with type "set_mesh_bpm" and its BPM input shadow
math_number NUM:60) and add a similar block object for "set_scene_bpm" into
toolboxSound.contents so both BPM controls are available in the sound toolbox
(use the same inputs structure as the existing set_mesh_bpm block and place them
alongside the other sound blocks such as "play_sound" and "play_notes").
🧹 Nitpick comments (1)
blocks/sound.js (1)

131-133: Consider preserving numeric bounds now that inputs accept expressions.

Line [131] and Lines [294-316] removed field-level numeric limits when switching to input_value. Please clamp/validate at generation/runtime (e.g., MIDI 0–127, FREQUENCY > 0, ATTACK/DECAY/RELEASE >= 0, SUSTAIN in 0–1) so invalid expressions don’t produce unstable audio behavior.

Also applies to: 294-316

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@blocks/sound.js` around lines 131 - 133, Replace removed field-level numeric
limits by validating and clamping values where code reads input values for the
sound block (e.g., the "NOTE" input and the other inputs referenced around lines
294-316 such as FREQUENCY, ATTACK, DECAY, RELEASE, SUSTAIN). In the
generator/runtime path that consumes these input_value fields (look for the
functions that serialize/compile block inputs or the sound synthesis routine
that uses NOTE, FREQUENCY, ATTACK, DECAY, RELEASE, SUSTAIN), coerce expressions
to numbers, validate ranges and clamp: NOTE to 0–127, FREQUENCY > 0,
ATTACK/DECAY/RELEASE >= 0, and SUSTAIN to 0–1; if conversion fails or values are
out of bounds, fall back to safe defaults and/or emit a warning so invalid
expressions don’t produce unstable audio.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@toolbox.js`:
- Around line 3214-3329: The sound toolbox still lacks BPM blocks because the
set_mesh_bpm block is left commented out and set_scene_bpm is missing from
toolboxSound.contents; uncomment the existing set_mesh_bpm block (restore the
block object with type "set_mesh_bpm" and its BPM input shadow math_number
NUM:60) and add a similar block object for "set_scene_bpm" into
toolboxSound.contents so both BPM controls are available in the sound toolbox
(use the same inputs structure as the existing set_mesh_bpm block and place them
alongside the other sound blocks such as "play_sound" and "play_notes").

---

Nitpick comments:
In `@blocks/sound.js`:
- Around line 131-133: Replace removed field-level numeric limits by validating
and clamping values where code reads input values for the sound block (e.g., the
"NOTE" input and the other inputs referenced around lines 294-316 such as
FREQUENCY, ATTACK, DECAY, RELEASE, SUSTAIN). In the generator/runtime path that
consumes these input_value fields (look for the functions that serialize/compile
block inputs or the sound synthesis routine that uses NOTE, FREQUENCY, ATTACK,
DECAY, RELEASE, SUSTAIN), coerce expressions to numbers, validate ranges and
clamp: NOTE to 0–127, FREQUENCY > 0, ATTACK/DECAY/RELEASE >= 0, and SUSTAIN to
0–1; if conversion fails or values are out of bounds, fall back to safe defaults
and/or emit a warning so invalid expressions don’t produce unstable audio.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 31a325e8-fea9-4d98-89c1-83a95135d0fb

📥 Commits

Reviewing files that changed from the base of the PR and between 76c2b46 and 986cd12.

📒 Files selected for processing (11)
  • blocks/sound.js
  • generators/generators.js
  • locale/de.js
  • locale/en.js
  • locale/es.js
  • locale/fr.js
  • locale/it.js
  • locale/pl.js
  • locale/pt.js
  • locale/sv.js
  • toolbox.js

@tracygardner tracygardner merged commit 30e6df9 into main Mar 18, 2026
6 checks passed
@tracygardner tracygardner deleted the claude/add-sound-shadow-blocks-QAzYp branch March 18, 2026 17:43
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.

2 participants