Skip to content

Hook up sound from jsbeeb#117

Draft
ojwb wants to merge 1 commit into
mattgodbolt:mainfrom
ojwb:enable-sound
Draft

Hook up sound from jsbeeb#117
ojwb wants to merge 1 commit into
mattgodbolt:mainfrom
ojwb:enable-sound

Conversation

@ojwb

@ojwb ojwb commented Jan 22, 2025

Copy link
Copy Markdown
Collaborator

This patch does get us working sound, but during loading a modal full-window error pops up:

Uncaught runtime errors:
ERROR
The operation was aborted.

Clicking the X in the top right continues to a working owlet. I've failed to work out where this is coming from.

Fixes #80

@ojwb

ojwb commented Jan 22, 2025

Copy link
Copy Markdown
Collaborator Author

I've marked this as a draft because the error needs fixing, but I'm not really a JS dev and I'm stumped as to how to debug it - I don't see anything in the browser's JS console. @mattgodbolt Any ideas?

The styling of the "audio-warning" probably needs sorting out too, but that's only cosmetic at least.

@mattgodbolt

Copy link
Copy Markdown
Owner

I'll have a poke about at the weekend! Thanks for taking a look

@mattgodbolt

Copy link
Copy Markdown
Owner

Probably worth a chat with @8bitkick as to whether no sound was a very deliberate choice too

@ojwb

ojwb commented Jan 24, 2025

Copy link
Copy Markdown
Collaborator Author

Any thoughts, Dom?

FWIW I doubt it was deliberate - even just thinking about writing code for BBCMicrobot, the bot used to support sound and that code is still there if you select jsbeeb as the emulator to use, but sound has not yet been implemented when using beebjit as the emulator, which is the hard-wired default.

The main obstacle there is lack of support for recording audio from a headless beebjit - I did try to implement that but the patch had some problems that I probably needed help to resolve and sadly I never got any response: scarybeasts/beebjit#48

@ojwb

ojwb commented Jan 28, 2025

Copy link
Copy Markdown
Collaborator Author

Another data point - 8bitkick's old editor supported sound from the emulator.

This patch does get us working sound, but during loading a modal
full-window error pops up:

Uncaught runtime errors:
ERROR
The operation was aborted.

Clicking the X in the top right continues to a working owlet.  I've
failed to work out where this is coming from.

Fixes mattgodbolt#80
@ojwb

ojwb commented Mar 9, 2025

Copy link
Copy Markdown
Collaborator Author

I'll have a poke about at the weekend! Thanks for taking a look

@mattgodbolt Did you get anywhere poking this?

I had another poke myself, commenting out various things and monkey patching stub functions over things and even adding alert("here"); to try to track down where we get to before the error but reached no useful conclusions.

(I've also rebased onto current main to make sure this wasn't caused by something we'd already fixed recently - if that's unhelpful feel free to git reset my branch to 17e9983 and force push it.)

@mattgodbolt

Copy link
Copy Markdown
Owner

I'm sorry @ojwb I did not in fact look... I'll try and take a look next week (this week is a write-off). Sorry!

@mattgodbolt

Copy link
Copy Markdown
Owner

I'm still failing on this: it has progressed to "sticky note on my monitor" priority, but in fair warnings I've been prepping an important talk for next week...after that things get a little free-er

@mattgodbolt

Copy link
Copy Markdown
Owner

@ojwb I'm finally taking a look...

and it seems to "just work" ™️ for me locally on Chrome... but not firefox!

I'll dig about :)

@mattgodbolt

Copy link
Copy Markdown
Owner

image
our culprit

@mattgodbolt

Copy link
Copy Markdown
Owner

I'm going to try and get the latest jsbeeb in and update all the deps, then dig into this!

@mattgodbolt

Copy link
Copy Markdown
Owner

ok ... merged... which brings in some jsbeeb worklet fixes BUT probably means we need to move over to vite to build...so I'll do that next...

@mattgodbolt

Copy link
Copy Markdown
Owner

Well sad me is hitting some apparent bugs in vite (the new system). I'll keep on trucking but vitejs/vite#6459 seems to be an issue for us...

@ojwb

ojwb commented Apr 21, 2025

Copy link
Copy Markdown
Collaborator Author

Seems you've at least identified the problem I was hitting (and more generally updated owlet to work with current jsbeeb).

One thing I noticed:

    node_modules/jsbeeb/src/web/audio-handler.js:2:7:
      2 │ import music500WorkletUrl from "../music5000-worklet.js?url";
        ╵        ~~~~~~~~~~~~~~~~~~

Is music500WorkletUrl correct? (500 vs 5000)

I can't seem to see either music500WorkletUrl or music5000WorkletUrl defined in jsbeeb's src/music5000-worklet.js, but admittedly I've no idea what code for a "worklet" is meant to look like.

@mattgodbolt

Copy link
Copy Markdown
Owner

that's interesting: it's possible the music 5000 stuff's broken in jsbeeb. I've been going around in circles trying to fix this in owlet :\

@mattgodbolt

Copy link
Copy Markdown
Owner

oh that's just a typo.

so the magic is:

import x as 'thing?url should be interpreted as "compile "thing" and make it available at some URL; then x will be that URL.

@mattgodbolt

Copy link
Copy Markdown
Owner

it's just that doesn't seem to work across project boundaries properly

@mattgodbolt

Copy link
Copy Markdown
Owner

I tried a couple more workaround bit keep hitting new snags. Argh! I'm sorry :(

@mattgodbolt

Copy link
Copy Markdown
Owner

Been plugging away a bit more and I'm starting to run out of ideas. This might be the thing that forces me to publish a "proper" jsbeeb package though :D

@mattgodbolt mattgodbolt mentioned this pull request Apr 22, 2025
@ojwb ojwb mentioned this pull request Mar 26, 2026
@avengah

avengah commented Mar 27, 2026

Copy link
Copy Markdown

I was pointed to this thread (thanks ojwb). Shame there's no sound - I wonder whether people could write tiny compressed programs to play great audio if it gets fixed? I remember on my old BBC we had a Digitised Sound demo that played a bit of Video Killed The Radio Star repeatedly (a few bars starting from one of the bits that goes Ohhw-ah-ohhw... then a few vocals from the male voice, repeated over and over) - basically a 4 second loop from the start of 0:44 to the end of 0:47 over and over (or a similar-sounding part): https://www.youtube.com/watch?v=W8r-tXRLazs&t=44

Then there's Spy Hunter, the game I always think of when I remember digitised sound on the BBC Micro. Kinda reminds me of Bart vs. the Space Mutants on the NES - that game had digitised voice effects for Bart: "Eat my shorts" and "Cool man".

Having looked at the BBC Micro Bot website, I'm seriously impressed with what people have done in tiny amounts of code. I've seen where people encode machine code in Base64, run a quick loop to decode it then CALL it. I notice the Owlet and the Bot both accept code compressed in base2048 format, but base65536 should probably be accepted too as it has a better compression ratio.

Sorry, rambling a bit. Thanks! Don't worry if any of these suggestions are too awkward or not worth doing for whatever reason.

EDIT: Ah, what's this? It says no clashes, but is that right? I don't know enough about this sort of programming I'm afraid. #135

Matt

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.

Sound?

3 participants