Page 1 of 1

MP3, Ogg, Wav, etc.

Posted: Tue Feb 14, 2006 11:07 pm
by bvold
Hay, I was wondering if anyone had ever done anything with the 6502 that envolved sound files like mp3, ogg, wav, etc. What I'm looking for is there experiances and the limitations and programing of it. Thanks.

bvold, :D

Posted: Wed Feb 15, 2006 7:17 pm
by Memblers
wav would be really easy. All the samples I play are just plain 8-bit unsigned PCM. You'll want it in an optimal format, converting or decoding it (at high sample rates like 44.1khz) for every sample will take some major CPU time.

If the CPU is supposed to be doing anything else at the same time you'll want a timer that can trigger an IRQ. Any timing variations in the code during playback will make it sound like crap for sure.

Actually I was planning on doing a whole bunch of sample stuff on NES (1.789mhz 6502). So I thought I'd put a PIC MCU in my design for the interrupts and stuff, soon I realized I could just generate all my samples in the PIC and feed it to the NES. So now I've got a nice-sounding little 4-channel synth, and the only part the 6502 has to do is this (well, besides setting the samples/freqs/volumes etc.):

Code: Select all

irq:
 pha
 lda $5000 ; in from PIC
 sta $4011 ; out to DAC
 pla
 rti
So I kinda cheated.. heheh. But I had to do, to get the results I wanted. You need to multiply (by volume) and add up the result to mix several channels with volume control. Or use some lookup tables to scale it. One sample at a time is a lot easier.

I doubt mp3 or ogg would be any good for 6502, but I'd be happy if someone surprised me. :)

Posted: Wed Feb 15, 2006 11:11 pm
by kc5tja
Memblers wrote:
I doubt mp3 or ogg would be any good for 6502, but I'd be happy if someone surprised me. :)
The problem is not the CPU architecture. The problem is clock speed. Even a 68020 at 8MHz will have a very hard time keeping up with Ogg or MP3.

You need at least a 50MHz machine or faster to be able to begin to play MP3s/Oggs in real-time. Otherwise, you'll want to pre-convert the audio to a more suitable format before playing.

Posted: Fri Feb 17, 2006 9:28 pm
by Memblers
kc5tja wrote:
Memblers wrote:
I doubt mp3 or ogg would be any good for 6502, but I'd be happy if someone surprised me. :)
The problem is not the CPU architecture. The problem is clock speed. Even a 68020 at 8MHz will have a very hard time keeping up with Ogg or MP3.
Yeah, I'm always thinking in terms of real-time. For me, that's 1.79Mhz and there's not much more than 100 cpu cycles between samples at 44.1khz. DPCM or ADPCM might be worth looking into. That should be doable in real time.

I remember making my old 486/66 struggle to play MP3 files in Cubic Player, heheh (it almost could).

Posted: Fri Feb 17, 2006 10:49 pm
by TMorita
I looked at decoding MP3s on low-end processors before, and came to the conclusion that you needed about 10-15 MIPS in order to decode in realtime.

A 6502 at 2 Mhz would only be about 0.7 MIPS, so this is impractical.

There are a few MP3 decoder peripheral chips. If you used one, then it might become practical.

Toshi