Jump to content
IGNORED

Running code at each scanline for PCM voice playback


rfunes

Recommended Posts

I have developed a bB program to play PCM data (currently only voice) in reasonable quality and using a custom compression algorithm to save ROM space.

 

I record and export to RAW PCM 8-bit unsigned, then using an external program I developed in Java, I downsample every 8 samples to only 1 sample, and quantize the values to 15 or 30 (depending if I want to use only one or both sound channels). This program also does a basic compression of the resulting values, using a very simple algorithm to save bytes when a value repeats 3 or more times.

 

Based on how I prepare the data, I can fit from 15 to 30 seconds of PCM audio, depending on if I use both channels (volume up to value = 30, or 5 bits) or only one channel (volume up to value = 15, or 4 bits) (ps: I plan on writing a tutorial and sharing my code).

 

If quality is not so important, or if a "robotic" voice is acceptable, it is also possible to be even more aggressive with the downsampling and quantization, for example to reduce from 16 samples to 1 sample, or even 32 samples to 1 sample (in this case, although the quality suffers, it still produces understandable audio, and I can fit more than 10 seconds in a single bank, or about 80 seconds in a 32k ROM !

 

The major limitation is that in bB I cannot call "drawscreen", otherwise my program will run at only 60 fps, which of course is not quick enough for the speech.

So currently I run it without drawing the screen and it works great, but the major limitation is that I cannot have anything on screen while the speech is being played.

 

is there any way in batariBasic to make code to run at each scanline, like it is done in pure ASM ? Even if it would require using some asm inside bB, or maybe changing bB itself?

Has anyone did this or have any idea if this is feasible/possible?

 

Thanks!

Edited by rfunes
  • Like 2
Link to comment
Share on other sites

Here's a bB example that never calls drawscreen, but produces a stable display. Since it doesn't do drawscreen, it also doesn't do stuff like position or display objects, etc. All of that would need to be done manually, which I would think would defeat the purpose of using bB to begin with. Here it is in case it is useful, however.

 

bbdraw.bas

  • Like 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...