New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cps: cps1 frequency response #556
Comments
My pleasure. Yes, MDFourier has been ported to CPS1 using ccps, the current source code is here: https://github.com/ArtemioUrbina/cps1mdfourier
Regarding Pin 7 of the MSM629, I will re-record the whole thing from all my PCBs again to compare having it set to both values, in order to confirm how much it changes and give you a proper comparison. I usually go with the high setting since I assume (maybe incorrectly) that since that covers the highest range and the analog path is the same, the widest range is being compared. I already coded this variant of the test and will be able to record tomorrow if you deem this to be useful. |
There is no explicit low-pass filter for the FM sound on the board: But I saw recently schematics for a Yamaha DAC, not sure the model, and I think the output was not buffered. So a resistor chain would be in series with the decoupling capacitors, forming a natural low pass filter. I think it was ikamusume, in Twitter, who published the schematics so I am going to ask him. That would make this messy because the effective filter frequency could be signal-dependent, and hencen non-linear. I need to see how that resistor divider at the output of YM3012 was done. Some configurations can have a constant output impedance. |
Another artifact that complicates things is that due to the short length of the quarter sine ROM inside the YM2151, for some high frequency settings you get less amplitude at the output. I can see this in simulation where the digital values have no filtering: This means that you are measuring two things: the FM ROM table aliasing and the DAC output impedance. It would be nice to separate them. Maybe using a different waveform as the output of the YM2151 could provide a more consistent amplitude level across frequency. A high feedback value for the 1st operator can produce a triangular shape if I remember well. I would need to think about how to overcome this limitation. |
There are schematics available for YM3014. From them, the output impedance for S[2:0] codes from 7 to 1 is 0.5R, 0.375R, 0.344R, 0.336R and then 0.333R. It looks like the schematics are missing a resistor, by adding it, the output impedance becomes exactly R/3 for all codes. |
I'll be waiting for suggestions on that area. Right now I can only compare the whole thing after the DAC since I am recording from the PCBs, but will follow any instructions to help.
Regarding the Above, I coded and tested a more complete version that runs the sweep in both pin7 settings: Yellow is oin 7 in high, and orange is pin 7 in low. Filtering is indeed different in MisterFPGA with both, I'll need to record the other PCBs to check if filtering varies between PCBs between both settings. But it follows the same filtering in hardware and MAME in both settings when comparing a PCB and MAME as you can see below, since both difference lines trace above each other: I'll add more results tomorrow after recording from more hardware. I added the option to test the "Reduction Specification" (amplitude) in ADPCM, and made MDfourier compare that in the time domain only. Here it is with zero reduction, above is the PCB and below is MiSTerFPGA: Here it is at a different Reduction level: I made these since I thought that maybe reduction levels were wrong and that made a perceived difference, but no, they match perfectly in amplitude, but you can clearly see the filtering difference even in the time domain: |
Just pasting results before going through your latest reply. The bounce back effect seeing in the reference waveform after the filter effect, cannot be seen with and without filter in the core, and using both truncated and non-truncated outputs of JT51. Could the bounce back be aliasing from your signal chain, @ArtemioUrbina ? |
Thank you for the new measurements. I think I need to split this in two different issues, one for FM (just continue here) and one for ADPCM (I'll create a new one) as differences will have complete different causes in both of them. |
I used toslink for MiSTer and the chain has been validated with stricter tests. I attach the new pattern generator in case you want to verify it, it is a new ADPCM tone at 1khz that is played with both Hi and Lo, and the 8 reduction levels to compare. And the flac files that generated these plots for both the PCB and MiSTer: |
By the way, @ArtemioUrbina, if you zoom in, you will see that the positive side of the sine wave is distorted in the PCB recording: This effect does not show in the core. It may be related to some electrical problem in the board. I do not think it indicates true performance. |
Ii was afraid I was doing the same and checked just after you mentioned it. Just recorded the older CPS1 88617A-7b (GNG) with ADPCM and compared it to the newer CPS18 9626A-4 (Sf2) with ADPCM, and the filters in hardware for ADPCM follow the exact same curve in hi and low for pin 7. As you can see yellow and orange trace the same difference curve. Comparing CPS1 88617A-7b to Mister we can see the bouncing on the frequency domain, and also the difference in filtering for ADPCM: |
Yeah, that's true. But it matches across all my boards and across all recordings as you can see in the FM comparisons and in all the recordings you have. And there is no missing or extra frequency information when you compare them. The match in FM is basically perfect across PCBs from different games and revisions: |
Here is the CPS1-88617A-7b-GNG-ADPCMFull recording: Edit: I checked the other YM2151 systems for which I have MDfourier, and this is not present in the X68000 or IREM boards, but it is present in all CPS1 PCBs I own Edit2: I found two boards that don't have those bumps: Magic Sword and Strider, both use 88617A-b7 and 88617b-5. Could be a capacitor issue? But common to all later revisions? I can recap one of the ones we have and check if it goes away, or I can use either board for all recordings if you prefer. |
If I understand this correctly, this plot is the spectrum difference between the MiSTer core and the board. If the dB are negative, who is small? the core or the board? Should I read it as FM is the same in the 100-1000Hz band? But then PCM is about 3-6dB louder in the core around 200Hz? Then the core has a low-pass filter so the board eventually gets 6dB louder PCM than the core at 3kHz? The board being 18dB+ louder than the core at 2.3kHz sounds unreasonable. The difference is too large and at a very hearable frequency. It is also a frequency at which the YM2151 will produce nice sine waves. It does not make sense unless the wave distortion is creating those HF harmonics. Speaking of the distortion, supply noise is a likely culprit. Yes, capacitors will likely help. But we can just forget about the broken boards and use the Strider one as reference, if that one produces a clean sine wave. I have recompiled the core without any filter on the ADPCM side. jtcps1.rbf.zip. Could you produce the spectrum difference again of this core vs Strider? By the way, if you could produce a longer ADPCM burst, it would be easier to compare the waveforms visually. The spectrum is very useful but plain transient waveforms are also kind to the eye. The current frequency sweep is too fast for that and the results look really different. Thank for all your help |
Yes it is the spectrum difference between the Board (as reference) and the MiSTer (as comparision). MdFourier uses the reference as the "truth" in a relative per comparison exercise. Thus, the plot is of spectral differences of the comparision signal (MiSTer in this case), in other words if the plot is negative it shows that MiSTer has that difference againt the PCB.
So yes, all the above are correct.
I agree, but that's what the numbers say. All the process is open so we can audit any part of it if you like.
Just as I read you I was about to tell you I had found the cause, and yes it is the power supply. I was using a new one, ofr those recordings, I went back to an era appropriate arcade power supply and the issue is gone.
With the power supply out of the equation, we now have clean form all of them, but I went with the Magic Sword one since it is a newer revision (88617A-b7) closer to the schematics we have.
I will and will post results soon here, with the current build of MDfourier.
I can and will to the largest possible size on the OKI, thank you. MDfourier can automatically produce the time domain plots of each "note" as the above comparing aligned segments (with the -u option), let me know if that helps you.
Thank you for caring. |
Here are the results comparing the unfiltered ADPCM:
That is due to the results in the PCB, check these out: MiSTer: Since the PCB is lower by that much at that frequency, MiSTer is that much higher when compared relative to it. |
Here is the Unfiltered ADPCM MiSTer FPGA recording: |
remnade a version that plays a 40 second ADPCM sweep, here are the recordings; Magic Sword CPS1 88617A-7b MiSTerFPGA non filtered code via toslink: MisterFPGA-CPS1-MDF-unfilteredADPCM-40s.zip And here's MDFourier difference plot: Spectrograms: MiSTer: And the sweeps: MiSTer: |
Thank you very much for all the new measurements and plots. Let me comment on the FM side. The summary is:
My takeaway is that the FM channel in MiSTer is good as it is. Differences below 10Hz and 18kHz are hard to control because each user has a different signal chain and filters around those frequencies will always be present. In the mid frequencies, I do not see differences large enough to justify going after them, at least for now because the PCM channel does have a large mismatch. About the distortion seen in the PCB recordings, one way around it would be to use a lower amplitude setting in the YM2151. We do not know what an out of the box PCB would be like but I would assume that the distortion was not present in fresh boards. Debugging the problem in the PCB can be quite a quest of its own as the number of possible culprits is quite large (power amplifier, opamps, DAC, digital noise coupling, capacitors, power supply...) This spread sheet contains the frequency comparison data I have used for the above judgement. |
Let me insist on this one: I think this is due to aliasing in the quarter-sine ROM table. It should always be present. For high frequency settings only a handful of values are read from the table, and this may skip the largest amplitude ones, so you get the effect of having a different gain. For this to be repetitive, the phase counter must be reset at the beginning of each note. The key on command should reset it. It will also be sensitive to anything affecting the phase, like DT and LFO settings. If you want to test this, you can set a very slow note, like a 10Hz tone and then just set the frequency setting above 2kHz at different positions of the output waveform. That will make the operator read the ROM table starting from a different position. Depending on when you trigger the frequency change relative to the current output, you will get a different amplitude for the HF sine wave. But, the important take away is that this does not represent real filtering due to external devices outside the YM2151 chip. |
@ArtemioUrbina it looks like the latest mdf zip does not run the long ADPCM sweep but the short 11 second version. I do see the volume steps (nice addition!) Could you post again the .zip with the modified files for mdf.zip? There's no need to include other files that do not change. |
Sure thing, sorry about that. |
First spectrum comparison for ADPCM:
I will work on a new low-pass filter to match the PCB spectrum better. I will look at the relative FM/ADPCM balance after that. |
This is great news, thank you very much for your impressive work.
You are right, my inexperience lead me to jump to conclusions. I am sorry about that. This is indeed not filtering, but it leaves me with a few questions that I still need to figure out:
Here are the spectrograms, CPS1 PCB: MAME: BTW, I recorded directly from the pre-outs and after the amplifier, and the curves are basically the same just to check if we had any differences. |
ADPCM issue moved to #559 for clarity. I will continue here after solving that one. |
If you are using key on and key off to control the notes during the FM test, the phase counter should get reset and you should get the same waveforms consistently. So the aliasing caused by the large sampling of the quarter sine ROM should be repetitive. |
@ArtemioUrbina, could you please give me a file that only generates four tones of the same amplitude on the ADPCM chip and that plays it in an infinite loop? That way I can fine tune the filter in real time. The tones would be at:
If possible, could the Z80 just work on its own without waiting for the M68k to trigger it? That will allow for Z80-only simulations, which are faster. It will also be more portable to other arcade systems. Excuse me for asking for so many things, but, if you do not mind, reply in #559 so the ADPCM conversation is there. |
Fixed in 22b08c0 |
Artemio kindly ported his test suite to CPS1 and made some measurements using real boards. I have some questions about the measurements:
Pin 7 of the MSM6295 (PCM chip) selects the sampling frequency. Games do toggle this bit. This will have an effect on the aliasing as the Nyquist filter after the PCM chip is fixed. Thus for high speed setting, the filter will be poorer and there will be more aliasing. I wonder which setting you used for the test.
The text was updated successfully, but these errors were encountered: