vgmrips / vgmplay-legacy

VGM file command-line player and Winamp plugin.
http://vgmrips.net
221 stars 52 forks source link

Distorted sound #51

Closed katananja closed 5 years ago

katananja commented 5 years ago

Listening to Track 8 - Germany (Stage 4) of this playlist: https://vgmrips.net/packs/pack/city-connection-arcade

It sound distorted. Compiling the code and using ./vgm2wav --loop-count 1 "08 Germany (Stage 4).vgz" citycon.wav the waveform looks strange. tracks000

The dc-offset of that track also looks off. For reference I've attached a direct sample from a YM2203 hardware from project RE:birth hw.zip

superctr commented 5 years ago

It is because the SSG (AY-3-8910 part, it is output directly by the FM chip instead of going through the DAC) only outputs a positive voltage and that is simulated here. The real hardware probably filters the SSG output.

vgmplay does not emulate any filtering done outside the sound chips themselves (with few special cases), so I don't think this particular behavior will be changed.

Btw, since the YM2203 outputs analog voltage for SSG and digital serial for FM, there are two separate discrete sound paths and the way it sounds in REbirth may not at all match the actual game PCB.

katananja commented 5 years ago

Wait, you guys are the ones responsible for the MAME new QSound engine!

Congratulations @superctr, I'm really sorry for what you have gone through to make that happen in MAME. Back in the day I was a 3rd party working for CAPCOM Japan designing the QSound hardware, I can't disclose any information but you guys nailed and I was so excited when it happen! I could not believe I could listen the old tunes again with the real QSound mix, well done!

I can share two little secrets with you, hope nobody listen, there are some music tracks that has some hidden instruments we use to test the QSound hardware, they are not "invisible", you can't notice it unless some one point it out. Street Fighter Alpha 2/Zero 2, Chun Li stage, in that mix was added some bongo drums effects that you can't hear it right without a QS decoder, without the decoder is just a stereo sound track.

If you want I can decode that soundtrack with your QS sound engine, you'll see that it works great.

When you get a full original CAPCOM arcade machine with the QS decoder in it, if you stay in front of it and the QS engine kicks in, you'll feel like you are inside a void of some sort, just like when you use a noise cancellation headphones, that weirdness feeling that you are suppose to be listen something like silence but you hear nothing kind of thing. If you get that feeling, QS is decoded right, right know you QS engines does that perfectly!

I have a sample decoded below, if you notice, in the floor there are some orange stripes, the drum plates will play at that exact position when the QS is decoded. If you are using a TV set, this drum plates will play at the bottom of your tv and along with the screen. That was only possible with your QSound engine patch. https://www.youtube.com/watch?v=Dx7V2xnUdVg

Run this wav file in your TV or stereo sound system: http://www.mediafire.com/file/6hu7z5g0lduuwac/08._Alinhamento.wav.7z

While is playing, walk around slowly. You should notice that in some spots at your space/home, the beep is 99% gone, the beep is playing but you can't hear it even if you set your volume at maximum, in other you'll notice that the beep is louder even if the volume. This audio will generate a pattern similar to this mage. jkygymm

Black areas means the sound waves are canceling each other out while bright areas means the sound waves are summing it. All this are based in psychoacoustics science, so I'm not breaking any trademark secret. You understand how this works and you will be very close to break the secrets of QS code.

By the way, you know that the CPS-1 game "The Punisher" has QSound registers to play with in the service menu, right?

Sorry it took that long but I want to vent this out before I die.

About the issue, I've saw that you use MAME source in your engine, well, MAME had a regression with that FM or YM2203. I've played that arcade in Japan in my lunch time every day in 88~89, I remember the sound, trust me, this is not how the original hardware sounded like. If you look at the City Connection sound block schematics, you'll see that Rebirth shield has the same circuit.

I'm attaching a sound sample from MAME 0.112 to show that it was working before, it got broken from MAME 0.113 on. mame112.zip

Thank you for your time, sorry for all this but I'm a sucker for sound chips.

PS: Hello donluca! Do you believe me now?

ValleyBell commented 5 years ago

... ohh, I think I know what it is.

The song uses the "OPN prescaler" stuff and then uses an instrument that only sounds right when the FM chip is emulated at the correct sample rate.
Unfortunately VGMPlay currently doesn't support sample rate changes for FM chips.
But I'll try to make a fix in libvgm.

ValleyBell commented 5 years ago

This should be fixed with ValleyBell/libvgm@ee17446493124a3d610f25a736b3436aedf71c0b
It was on my TODO list anyway.

Here is an MP3 of the song playing using the just-fixed libvgm: CityConnectionGermany(fixed).zip

katananja commented 5 years ago

Hello @ValleyBell congratulations to you too on the QSound Engine, oh my God! The whole gang is here! Thank you for the fix man, that is the correct tune!

I'm finishing up a few things here, I'll decode that Chun-Li soundtrack for you guys.

THANK YOU!

superctr commented 5 years ago

I think you should give credit to Vas Crabb from the MAME team for emulating the DSP in the first place. We just took the DSP code and ported it to C.

Yes I am aware of how the qsound effect works, technically it's not quite that complicated. And the secrets about how the filter was designed are in the (now-expired) patents that are mentioned in the Qsound splash screen anyway...

If you want another example of a track that you really only can hear with the effect enabled, it would be the bass track in "Irene" from Street Fighter EX2 Plus. It is almost inaudible with the old emulator (that you hear on the vgmrips website).

katananja commented 5 years ago

Vas Crabb has issues with me, issues I don't know what and personally I really don't care about. You guys got the job done!

About the patents... they are not complete, what you see in there doesn't complete the circle, it did expired but I still have a non-disclosure contract signed.

For convenience and easy reference I've done both, decoded and non-decoded, the non-decoded is just the vgmplay log. It will be possible to hear the "bongos" (ta-da-da/ta-da-da) we use to do hardware testing, that is the missing part in that patent.

decoded.zip non-decoded.zip

Hope you like it! Thank you @superctr and @ValleyBell! You guys are THE BEST!

Edit: One thing I forgot to tell, the bongos are located in the 3D space in front of you, if done right, you should not be able to pinpoint his location. For better effect you need a pair of time aligned speakers, all smart tv has it this days, playing with the sound modes can make the effect better or worse.

katananja commented 5 years ago

I was listening to your fix @ValleyBell with headphones, there is still a ringing type noise inside the tone.

Don't know if this might help you improve your sound engine or not, I'm not a software developer, fmgen 008 is a open source FM Sound Generator, rumor says that this guys are the engineers that created the YM2203 and other sound engines. http://retropc.net/cisc/m88/download.html

All the files are SHIFT_JIS encoded, the code is free to use, the autor only asks to drop him a line if you use it in you project.

Thank you again @ValleyBell !

superctr commented 5 years ago

Fmgen is quite old and based on ancient MAME sources, as you can tell from the source code. I think considering that, it would probably fall under the "no commercial use" MAME license as well.

katananja commented 5 years ago

Thank you @superctr