scarybeasts / beebjit

A very fast BBC Micro emulator.
Other
132 stars 15 forks source link

Support recording audio from a headless beebjit #48

Open ojwb opened 1 year ago

ojwb commented 1 year ago

If -opt sound:dev is specified, it's taken to be a filename to save audio data too.

The format is 16 bit unsigned raw audio data, with a default sample rate of 48kHz.

ojwb commented 1 year ago

This seems to work in a simple test - I can run:

./beebjit -terminal -headless -opt sound:dev=audio.raw

And then play the resulting audio.raw file with:

play --encoding unsigned-integer --bits 16 --rate 48000 audio.raw

However, this doesn't seem to work when I hook it up to the bot - I just seem to get an empty audio.raw created.

I'm suspecting something special is needed to handle -fast but I don't really know where to start with that.

ojwb commented 1 year ago

I just tried pruning options from the beebjit command the bot uses and it seems I can either remove -fast or -accurate and then I get some audio data written out (though different amounts for some reason).

Even if this was working, we'd ideally want a way to only start saving audio data after a certain number of cycles (to match video:paint-start-cycles). Without that we'd need to save way too much audio data and then ignore most of it. For a 30 second run that's not too bad, but for a 3 hour one it's more than 16MB of unwanted raw audio data if my calculation is right.