What's new

YM3812 Sound Chip Help

Danny

Programmer | Moderator
hey guys.

My experience with sound emulation is very low, and I am hoping one of you can give me some pointers as to what is wrong.

Basically what this is used in is my Wolfenstein 3D port.

I presumed for a long time that the issue lay in the fmopl.c, (opl emulator implementation). So I ported the latest version from mame to Wolf, and it made no difference.

So I am convinced that the issue lies in sd_sdl.c (Wolf3D Opl Initializer file).

I have done some improvements (such as using a separate buffer for sound and music) but it has only had modest performance gains.

Setting the sample rate to 44010 does improve things, but makes the music playback at a tempo which is far too high, and gives most sound effects "helium" like sounds.

The main problem is the Music. The sound effects seem to play back ok, but don't play the full sample. They play around half (at what seams the middle to end) , never the full sample.

The music plays back poorly. There seems to be a sample that always gets played at the wrong time or in the wrong thread. It also crackles too. The menu suffers from the worst crackling, and in-game is poor too. (unbearable with headphones).

So that is all the information that I have to give you, most of it is based on my naive assumptions and may be totally incorrect. I hope it helps you see what is wrong, so you can hopefully give me a clue how to go about fixing it.

I have pasted the code below and have put it in a zip file (below) too for ease of view.

Thanks so much for any help, and of course anyone who helps will be credited for it on my next release.

(if you need more code just ask, I will happily upload more if required)

Had to use rafb.net (aka nopaste) to submit the code because the message exceeded the character limit with it in the post.

sd_sdl.c

http://rafb.net/p/Mtpjnx47.html

fmopl.c

http://rafb.net/p/YXIfze15.html

Code in a zip file : HERE
 

smcd

Active member
I can't really help but just a heads up that rafb purges items after 24 hours so the zip file is the way to go
 

Exophase

Emulator Developer
Sorry but this is close to impossible to diagnose just by looking at those files alone.

If this uses SDL all the way then have you personally compiled it for PC? Does it work fine? If that's the case then it's possible that your problems are performance related. If you aren't running at 333MHz then try it to see if it improves anything.
 
OP
Danny

Danny

Programmer | Moderator
Sorry but this is close to impossible to diagnose just by looking at those files alone.

If this uses SDL all the way then have you personally compiled it for PC? Does it work fine? If that's the case then it's possible that your problems are performance related. If you aren't running at 333MHz then try it to see if it improves anything.

Btw the full source is available from the Wolf3d link i posted on the first thread.

I don't actually have a compiler set up for building .exe's right now. Only have PSP compiler set up at the moment.

I was sure I tried 333mhz with no improvements.... I will double check though

Edit : yeah , 333mhz made no difference.... Guess I will just have to leave improving the sound for a while until i understand more about it, unless someone else happens to see the issue.
 
Last edited:
OP
Danny

Danny

Programmer | Moderator
Chilly Willy and I have finally fixed it:)

Thanks anyway guys :D
 

smcd

Active member
Care to post or link to the fix so if others come along with a similar issue (and search!) they can find a solution? :)
 
OP
Danny

Danny

Programmer | Moderator
Care to post or link to the fix so if others come along with a similar issue (and search!) they can find a solution? :)

It was a wolf3d specific issue though :p The implementation of the sound didn't quite get along with the psp :evil:

Will be releasing all code as per usual with the next release:)

Was basically just a rework of the code to re-sample the audio at a better frequency, also added more sound channels.
 
OP
Danny

Danny

Programmer | Moderator
May I ask why you are not using Ken Silverman's OPL2 emulator?

I just used what was there really. i like to keep the original source intact as much as possible when doing a port. If it needs replacing or changing then of course I have no quarrels with doing so. It's fixed now and works fantastic so no need to use a different opl emulator :)
 

Top