Skip to content

Conversation

@rDarge
Copy link

@rDarge rDarge commented Dec 22, 2022

This is a draft just to illustrate how adding in music might work

I've commented out some logic in build.zig since I haven't finished implementing the corresponding sdl version of the music function, so you can ignore that for now.

The high level idea is that the music files will be accessible as (mp3|whatever) in the server, and loaded into audio elements by javascript executed by wasm. I've added in a parent div "music" to organize said elements under. Supplying the same channelMask more than once will delete the existing audio element and create a new one. fadems is not implemented yet.

One thing to note is that a user needs to interact with the document before any music can be played in this fashion, as most browsers don't look kindly to autoplay-on-load anymore.

@rDarge rDarge mentioned this pull request Dec 22, 2022
@rDarge rDarge force-pushed the addingMusic branch 2 times, most recently from 9575b1b to 5f811e6 Compare January 16, 2023 18:55
@rDarge
Copy link
Author

rDarge commented Jan 16, 2023

Spent a good chunk of today troubleshooting why I couldn't get this working on my desktop, as I had been doing my development on my laptop till now; turns out the latest experimental zig version (0.11.whatever) has broken whatever wasm building nuances this branch was relying on; I'm not sure exactly where the rub is, but it's working fine with 0.10, and I'm going to assume they'll work out whatever kinks by the 0.11 stable release.

Added basic SDL2 sfx... I think there needs to be a more robust music/sfx loading pattern since it's stuck with just one of each right now, but that'll take a bit more work to crank out.

@rDarge rDarge marked this pull request as ready for review January 16, 2023 20:43
@rDarge
Copy link
Author

rDarge commented Jan 16, 2023

Major limitations are that the api supports only one track each for music and sfx, 0.mp3 and 0.wav in the assets folder, respectively. It's enough to illustrate how this might work though. Playing music in wasm/native mode by fetching the source each time isn't that great either, so resource management could be improved. The two probably will need to go hand-in-hand.

@rDarge rDarge changed the title Draft: Testing out ways to play music in wasm Testing out ways to play music in wasm Jan 17, 2023
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