fix: resolve ReferenceErrors in Sampler, Tuner, and TurtleActions#7774
Conversation
|
@walterbender @Ashutoshx7 please take a look when u got time! |
|
Did you also test by running the sampler widget? And trying to use some of the other code paths you changed? |
… toggles in SamplerWidget
The ReferenceError: TunerUtils is not defined and ReferenceError: MusicBlocks is not defined console errors are resolved. |
…-reference-errors
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7774 +/- ##
==========================================
- Coverage 58.23% 58.22% -0.01%
==========================================
Files 174 174
Lines 57787 57872 +85
==========================================
+ Hits 33650 33696 +46
- Misses 24137 24176 +39 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Description
Opening the Tuner or triggering audio/timbre actions from the Sampler widget resulted in uncaught console errors (
ReferenceError: TunerUtils is not definedandReferenceError: MusicBlocks is not defined), preventing sample tuning and timbre selection from functioning correctly in interactive browser sessions. Additionally, playing recorded audio left playback buttons stuck without properly resetting icon animations or playback toggle states.Fix
"widgets/tuner"inMUSICBLOCKS_EXTRAS(js/activity.js) sotuner.jsloads beforesampler.js, and exportedwindow.TunerUtils = TunerUtilsinjs/widgets/tuner.jssoSamplerWidgetcan access pitch conversion utilities globally.else if (MusicBlocks.isRun)to checktypeof MusicBlocks !== "undefined" && MusicBlocks.isRunacross all 6 turtle action files (ToneActions.js,DrumActions.js,OrnamentActions.js,MeterActions.js,IntervalsActions.js,VolumeActions.js) so accessing action listeners does not throwReferenceErrorwhen running inside browser editor sessions..connectionsor stylingsamplerCanvasinSamplerWidget(js/widgets/sampler.js).await Tone.start()/Tone.context.resume()) when playing recordings (js/utils/synthutils.js) and added a reliable duration completion handler soplayback = falseresets when audio finishes playing.this.pause(),this.resume(), and_playbackBtn.onclickinSamplerWidget(js/widgets/sampler.js) to directly update imagesrcattributes (img.src), ensuring smooth and reliable icon toggling (play-button.svg↔pause-button.svgandplayback.svg↔stop-button.svg).PR Category
Changes Made
js/activity.js(Addedwidgets/tunertoMUSICBLOCKS_EXTRAS)js/widgets/tuner.js(ExportedTunerDisplayandTunerUtilstowindow)js/widgets/sampler.js(Added.connectionsandsamplerCanvasnull checks; updated play/pause and playback button handlers to directly updateimg.src)js/utils/synthutils.js(ResumedTone.start()/Tone.context.resume()on recording playback, added duration completion timeout fallback, and cleaned up timeout in_disposeRecordingPlayer)js/turtleactions/ToneActions.js,DrumActions.js,OrnamentActions.js,MeterActions.js,IntervalsActions.js,VolumeActions.js(Guarded globalMusicBlockscheck withtypeof MusicBlocks !== "undefined")Testing Performed
npm run lint— passes with 0 errorsnpx prettier --check .— passesnpm test— all tests passed successfully acrosssampler.test.js,tuner.test.js, and all 9turtleactionstest suites