YM2612 fully accurate VGM hardware player

For anything related to sound (YM2612, PSG, Z80, PCM...)

Moderator: BigEvilCorporation

Post Reply
sigMate
Interested
Posts: 21
Joined: Sun Mar 25, 2012 2:28 pm
Location: Paris, France
Contact:

YM2612 fully accurate VGM hardware player

Post by sigMate » Wed Apr 25, 2012 7:43 am

Hi guys,

I just finished a first version of my project. It uses a Teensy2.0++ board.

I wrote a custom VGM file streamer (PC side) which sends 64 bytes data packets to the Atmel µC over USB with the RAW HID protocol (no drivers to install) into a circular buffer.

The VGM file format is very well thought, at least for emulation, but not really for realtime, which led me into very interesting timing issues which now seem to be resolved. I was also able to add PCM support for the DAC.

Have a look : http://www.youtube.com/watch?v=cYtwoyx1ccI

It also seems to be very hard to find a 7.67 MHz oscillator or even a 53.7 MHz I could then clock divide so I find a nice solution : an adjustable clock generator I can fine tune very precisly (even in real time which is funny).

And also, I little experimentation : the YM2612 playing 8 bit PCM audio (with DAC mode from channel 6 only of course) at 44.1 kHz still with the RAW HID protocol. I had to adjust the clockrate to ~8.81 MHz.

Here it is : http://www.youtube.com/watch?v=fYWclV9H2eY

I just ordered some SN76489 chips and I'm waiting for those to arrive :)

Hope you'll enjoy !

Cheers,

sig

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Wed Apr 25, 2012 2:15 pm

Only ~30000 writes end up in the output of the chip. Going past half of YM sample rate results in missed writes.

Regarding the PSG chips you'll be getting different noise pattern from them than the PSG inside MD and SMS VDP.

Still pretty nice ^^
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

sigMate
Interested
Posts: 21
Joined: Sun Mar 25, 2012 2:28 pm
Location: Paris, France
Contact:

Post by sigMate » Wed Apr 25, 2012 7:11 pm

Yeah, I think you're write about the YM sample rate because when I first tried the PCM audio experiment, the chip was running at ~7.67 (as usual) and I had cracks in the output, then I thought I was sending data too fast, but, after overclocking it a little, the cracks disappeared. It was easy to observe taht since I can adjust the clock source in real time. Unless you tell me that there should not be any link between the clockrate of the YM2612 and its working speed for some operations ?

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Thu Apr 26, 2012 8:04 am

Everything is tied to the clock. YM sample rate is Clock/144, and maximum PCM rate is half that from my tests.
Take some metal song with lot of cymbals and boost the highs (12KHz+) and you can hear how crap the sound becomes. On lower freqs the missed writes don't cause much issues as the waveforms are quite "flat" but one missed sample in a very high freq results in that waveform getting obliterated.
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

KanedaFr
Administrateur
Posts: 1139
Joined: Tue Aug 29, 2006 10:56 am
Contact:

Post by KanedaFr » Thu Apr 26, 2012 10:07 pm

cooooooooool

Did you use LUFA ? I planned to use it and its Audio In/Out template....
Now make it an usb toy so we can support it on emulator
It was my final goal : let KMod send sound to usb device for better sound experience ;)

sigMate
Interested
Posts: 21
Joined: Sun Mar 25, 2012 2:28 pm
Location: Paris, France
Contact:

Post by sigMate » Fri Apr 27, 2012 8:33 am

@TmEE co.: Thanks for the info. I forgot about the internal clock division /144 and the PCM maximum rate you found is very interesting.

@KanedaFr: I didn't use LUFA. The Atmel is programmed in plain C with avr-gcc. But LUFA seems to be very nice ! I should look at it ! Your idea is very nice, but, as a lot of emulations purists told me, I will never get the true sound of the Genesis because the SN76489 I'm gonna use won't have the same noise shift registrer and won't sound the same as the original MD/SMS VDP :-/

Cheers !

KanedaFr
Administrateur
Posts: 1139
Joined: Tue Aug 29, 2006 10:56 am
Contact:

Post by KanedaFr » Fri Apr 27, 2012 2:01 pm

wow! pure code !

USB seems so hard to implement (one mistake in the header struct and you're out) ...
about the purists, I think hard emu will still be better than soft emu...
and the purists use a flash card, not an emu ;)

tristanseifert
Interested
Posts: 35
Joined: Tue Sep 06, 2011 2:16 am
Location: /dev/sa0
Contact:

Post by tristanseifert » Fri Apr 27, 2012 2:34 pm

This is indeed an interesting project.
However, lik one other people said, you won't really get close to the MD's sound with the noise shift reg issue, although if you implement the PSG in an FPGA you could get around this issue.

Just a quick question - where did you buy your YM2612 and SN76489? I'm planning to make a 68k based MIDI thinger with those two chips.

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Fri Apr 27, 2012 6:57 pm

utsource.net and alibaba.com are good places to start.
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

sega16
Very interested
Posts: 251
Joined: Sat Jan 29, 2011 3:16 pm
Location: U.S.A.

Post by sega16 » Mon May 07, 2012 10:10 pm

sigMate, I just bought a ym2612 on ebay and got it today and I am interstead in your clock generator how does it work? I hope to get my ym2612 working on the arduino.

sigMate
Interested
Posts: 21
Joined: Sun Mar 25, 2012 2:28 pm
Location: Paris, France
Contact:

Post by sigMate » Wed May 09, 2012 5:01 pm

@sega16: I used an LTC1799, a variable oscillator. It is precise and easy to configure.

Cheers !

Post Reply