Skip to content

Comments

refactor(phrasemaker): extract audio playback logic into PhraseMakerAudio module#5738

Open
vanshika2720 wants to merge 1 commit intosugarlabs:masterfrom
vanshika2720:refactor/extract-phrasemaker-audio-logic
Open

refactor(phrasemaker): extract audio playback logic into PhraseMakerAudio module#5738
vanshika2720 wants to merge 1 commit intosugarlabs:masterfrom
vanshika2720:refactor/extract-phrasemaker-audio-logic

Conversation

@vanshika2720
Copy link
Contributor

Goal

This PR completes Phase 4 of the modular refactor for js/widgets/phrasemaker.js. All audio-related, playback triggering, and scheduling logic has been moved to a new module: js/widgets/PhraseMakerAudio.js.
After this phase, phrasemaker.js acts strictly as an orchestration layer, delegating to:

  • PhraseMakerUtils (Helpers)
  • PhraseMakerGrid (Data)
  • PhraseMakerUI (UI/Rendering)
  • PhraseMakerAudio (Playback/Audio)

Logic Extracted

Moved the following responsibilities to PhraseMakerAudio:

  • Playback Control: playAll() (toggling playback state).
  • Scheduling/Timing: __playNote() (recursive timeout logic and loop boundaries).
  • Note Collection: collectNotesToPlay() (converting grid state into playable frequencies/durations).
  • Sound engine linkage: _playChord() (triggering Tone/Singer synth notes).
  • Action Playback: _processGraphics() (executing painter commands during playback).

Integration & Loader

  • Created js/widgets/PhraseMakerAudio.js.
  • Registered widgets/PhraseMakerAudio in MUSICBLOCKS_EXTRAS within js/activity.js.
  • Updated js/widgets/phrasemaker.js to delegate calls to the new module.

Verification

  • Play/Stop toggle works as expected.
  • Playback highlighting follows the audio accurately.
  • Correct durations and pitches are triggered from the matrix state.
  • Looping behavior and matrix reset at end of phrase are preserved.
  • Rapidly clicking Stop does not hang the audio engine or leave stale timers.
  • No regressions in Graphics block execution during playback.

Git Requirements

  • Base Branch: refactor/extract-phrasemaker-ui-logic
  • Modified Only:
    • js/widgets/PhraseMakerAudio.js
    • js/widgets/phrasemaker.js
    • js/activity.js

@github-actions
Copy link
Contributor

✅ All Jest tests passed! This PR is ready to merge.

@walterbender
Copy link
Member

conflicts need to be resolved

@vanshika2720
Copy link
Contributor Author

@walterbender this is phase 4 of PR #5735 after its phase-3(#5737) is merged then i rebase it and conflicts gets resolved

@vanshika2720 vanshika2720 force-pushed the refactor/extract-phrasemaker-audio-logic branch from cbdc22d to 76f3237 Compare February 16, 2026 21:02
@github-actions
Copy link
Contributor

✅ All Jest tests passed! This PR is ready to merge.

@vanshika2720
Copy link
Contributor Author

@walterbender Conflicts resolved.please review !!

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