Original Post

Here’s a demo of an 8-bit WAV player that I started developing immediately after reading this thread

http://www.planetvb.com/modules/newbb/viewtopic.php?topic_id=5139&forum=2

but did not want to release it because while it works perfectly on Mednafen, it plays too slowly on hardware and I’m not sure whether it’s a bug in it or my code. But it would be a shame not to release at least a proof of concept if I’ve already spent some time on it. I’ve shown it to Morintari and he liked it, so why not?

The demo is mono and the WAV is sampled at 8000 Hz, and nothing is happening while it plays, but it should be able to support playing pretty much any kind of sound in the background while other things are happening.

Attachments:
8 Replies

Well, I’d love to try this, but PVB isn’t letting me download it… Maybe it would work if you ZIPped it.

As for the speed thing: release the source and maybe someone can figure out the problem (it might also help make Mednafen and other emulators more accurate).

It is just a wild guess as I never saw the sources but maybe you have to use the timer interruped to play your music instead of calling your funtions from the main loop.

How do you get the wav into the ROM? Did you code a converter or something?

I do use the timer interrupt. Maybe the interrupt handler is coded incorrectly, since the way libgccvb handles it is IMO quite confusing. I should do it in assembly, that would give me more speed too.

I “converted” the WAV the cheapest way there is: I made a program that converted all of it except the 54-byte header into a giant C header file with a byte array.

HorvatM wrote:
[…] a giant C header file […]

What we’re doing with libvue is we’ve included a macro that makes use of the assembler’s .incbin directive to include resource files directly. You may want to consider doing something similar.

When I was doing the conversion, I thought: if only C had an incbin directive…

It didn’t occur to me that I could use the assembler to do it.

Zipped version.

Attachments:

Guy Perfect wrote:

What we’re doing with libvue is we’ve included a macro that makes use of the assembler’s .incbin directive to include resource files directly. You may want to consider doing something similar.

I was messing around with .incbin a few years back when I worked on my midi player, but I only ever succeeded in putting the files in the RAM area (which soon filled up after a few songs)… How did you map the files to reside in the ROM area?

Like this, in the .text section:

.section .text
.align 2
.global _label
_label:
.incbin myfile.bin
.size	_label, .-_label
  • This reply was modified 10 years, 11 months ago by dasi.

 

Write a reply

You must be logged in to reply to this topic.