bvold,
MP3, Ogg, Wav, etc.
MP3, Ogg, Wav, etc.
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,
bvold,
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.):
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.
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
I doubt mp3 or ogg would be any good for 6502, but I'd be happy if someone surprised me.
Memblers wrote:
I doubt mp3 or ogg would be any good for 6502, but I'd be happy if someone surprised me. 
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.
kc5tja wrote:
Memblers wrote:
I doubt mp3 or ogg would be any good for 6502, but I'd be happy if someone surprised me. 
I remember making my old 486/66 struggle to play MP3 files in Cubic Player, heheh (it almost could).
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
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