Skip to content

Conversation

cwoffenden
Copy link
Contributor

@cwoffenden cwoffenden commented Jan 14, 2025

These are the audio worklet tests from #22753 extracted to a standalone PR. The tests are:

  • Multiple stereo inputs mixing in the processor to a single stereo output
  • Multiple stereo inputs copying in the processor to multiple stereo outputs
  • Multiple mono inputs mixing in the processor to a single mono output
  • Multiple mono inputs copying in the processor to L+R stereo outputs

The tests use different stack sizes (from 2kB to 6kB depending on the requirement).

The audio tracks were composed by Tim Wright especially for Emscripten and released under a CC0 license.

The tests can be run manually via:

test/runner interactive.test_audio_worklet_stereo_io
test/runner interactive.test_audio_worklet_2x_stereo_io
test/runner interactive.test_audio_worklet_mono_io
test/runner interactive.test_audio_worklet_2x_hard_pan_io

There are no code changes to Emscripten apart from integrating the test.

@sbc100
Copy link
Collaborator

sbc100 commented Jan 14, 2025

I love that Tim Wright composed our audio tests :) Please tell him I was a great fan or Lemmings and Shadow of the Beast 2 back in the day.

@cwoffenden
Copy link
Contributor Author

I love that Tim Wright composed our audio tests :)

😁

Please tell him I was a great fan or Lemmings and Shadow of the Beast 2 back in the day.

Now we'll need to widen the office doors even more to let in his ego!

EM_JS(EMSCRIPTEN_WEBAUDIO_T, createTrack, (EMSCRIPTEN_WEBAUDIO_T ctxID, const char* url, bool looping), {
var context = emscriptenGetAudioObject(ctxID);
if (context) {
var audio = document.createElement('audio');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why are these two JS functions needed? Is this functionality not available though existing emscripten APIs?

Are folks expected to create their own audio elements like this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, there's no provision (that I know of) to create audio tracks.

In reality the audio will probably come in via other means (we decode and mix Opus files, for example, or generate effects).

@sbc100 sbc100 changed the title [AUDIO_WORKLET] Standalone multichannel audio tests [AUDIO_WORKLET] Add standalone multichannel audio tests Jan 14, 2025
@sbc100 sbc100 changed the title [AUDIO_WORKLET] Add standalone multichannel audio tests [AUDIO_WORKLET] Add standalone multichannel audio tests. NFC Jan 14, 2025
@sbc100 sbc100 changed the title [AUDIO_WORKLET] Add standalone multichannel audio tests. NFC [AUDIO_WORKLET] Add multichannel audio tests. NFC Jan 14, 2025
Copy link
Collaborator

@sbc100 sbc100 left a comment

Choose a reason for hiding this comment

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

I wish I knew the audio worklet API better so I could give this a better review myself.

@juj perhaps you could review later if you get time?

lgtm to all the parts I could understand

@sbc100
Copy link
Collaborator

sbc100 commented Jan 15, 2025

@juj please review if / when you get a chance

@sbc100 sbc100 merged commit bcad96d into emscripten-core:main Jan 15, 2025
29 checks passed
@cwoffenden cwoffenden deleted the cw-audio-tests-1 branch January 15, 2025 17:11
@cwoffenden
Copy link
Contributor Author

cwoffenden commented Jan 15, 2025

@juj please review if / when you get a chance

@sbc100, could I suggest nagging people like @mttjcksn to give a once over to the audio code and the mixing examples? He's seen more audio code than me (and worked on proper synthesisers).

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