Skip to content

Conversation

@julianharty
Copy link
Contributor

Integrates and refactors sound tests from https://github.com/commercetest/babylonjs-sound-testing repo which were created as for this purpose.

Adds comprehensive test coverage (59 tests) with audio utilities, integration tests, verification tests, and diagnostics. Note: there are still more tests available in the babylonjs-sound-testing repo that may be relevant. This commit is already large so I'd prefer to consider them once this work has been reviewed and merged.

Details:
Test Suite Changes:

  • Add audio test utilities (FFT, RMS, tone generation, clipping detection)
  • Add sound-integration.test.js (15 tests: lifecycle, async workflows, edge cases)
  • Add sound-verification.test.js (24 tests: audio output, MIDI, instruments)
  • Add sound-api-investigation.test.js (2 tests: API exploration)
  • Add sound-replacement-diagnostic.test.js (3 tests: timing diagnostics)
  • Update test infrastructure (tests.html, run-api-tests.mjs)

Bug Fixes:

  • Fix NaN error in playNotes() when durations array shorter than notes
    • Add default duration (0.5 beats) for missing values
    • Add parameter validation in playMidiNote() to prevent non-finite values
    • Prevents "linearRampToValueAtTime non-finite value" Web Audio API errors
  • Fix sound replacement tests to account for loop parameter behavior
    • Promise resolution timing differs: loop=true (immediate) vs loop=false (on end)

Test Organization:

  • Integration tests: workflows, replacement, cleanup, spatial/non-spatial
  • Verification tests: deep API validation, audio output, FFT analysis
  • Investigation tests: document actual BabylonJS Sound API methods
  • Diagnostic tests: sound replacement timing and promise behavior

Results: 59/59 tests passing, no Web Audio errors

Related to issue #264
documenting playSound() promise behavior and playNotes() array handling.

  Integrate and refactor sound tests from babylonjs-sound-testing repo.
  Add comprehensive test coverage (59 tests) with audio utilities,
  integration tests, verification tests, and diagnostics.

Details:
Test Suite Changes:
  - Add audio test utilities (FFT, RMS, tone generation, clipping detection)
  - Add sound-integration.test.js (15 tests: lifecycle, async workflows, edge cases)
  - Add sound-verification.test.js (24 tests: audio output, MIDI, instruments)
  - Add sound-api-investigation.test.js (2 tests: API exploration)
  - Add sound-replacement-diagnostic.test.js (3 tests: timing diagnostics)
  - Update test infrastructure (tests.html, run-api-tests.mjs)

  Bug Fixes:
  - Fix NaN error in playNotes() when durations array shorter than notes
    * Add default duration (0.5 beats) for missing values
    * Add parameter validation in playMidiNote() to prevent non-finite values
    * Prevents "linearRampToValueAtTime non-finite value" Web Audio API errors
  - Fix sound replacement tests to account for loop parameter behavior
    * Promise resolution timing differs: loop=true (immediate) vs loop=false (on end)

  Test Organization:
  - Integration tests: workflows, replacement, cleanup, spatial/non-spatial
  - Verification tests: deep API validation, audio output, FFT analysis
  - Investigation tests: document actual BabylonJS Sound API methods
  - Diagnostic tests: sound replacement timing and promise behavior

  Results: 59/59 tests passing, no Web Audio errors

  Related to issue <flipcomputing#264>
  documenting playSound() promise behavior and playNotes() array handling.
@julianharty julianharty changed the title feat(sound): integrates sound tests and fixedsWeb Audio errors feat(sound): integrates sound tests and fixes Web Audio errors Dec 31, 2025
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