Viewing Issue Advanced Details
ID Category [?] Severity [?] Reproducibility Date Submitted Last Update
02875 Sound Major Always Jan 25, 2009, 07:08 Mar 19, 2009, 01:08
Tester vidpro1 View Status Public Platform MAME (Official Binary)
Assigned To couriersud Resolution Fixed OS Windows XP/Vista 32-bit
Status [?] Resolved Driver
Version 0.124u5 Fixed in Version 0.130u1 Build I686
Fixed in Git Commit Github Pull Request #
Summary 02875: Any Game that uses AY-3-8910: Envelope Fix causes notes tones to be played back incorrectly
Description An AY-3-8910 fix was submitted on .124u5
it was supposed to emulate envelope fixing to make it more accurate.
This affect all MAME drivers not just scramble.c


However it makes the games sound wrong when tones are supposed to be played back at a certain rate/duration. The result is too long duration sounding notes compared to a normal game pcb.

A good test to do is play Konami Amidar from .123 then try .124u5 or higher. any AY-3-8910 you can noteice the difference.
Steps To Reproduce A good test to do is play Konami Amidar from .123 then try .124u5 or higher. any AY-3-8910 you can notice the difference.
Additional Information
Github Commit
Flags
Regression Version
Affected Sets / Systems Any Game that uses AY-3-8910
Attached Files
mp3 file icon timepilot1.mp3 (615,993 bytes) Feb 21, 2009, 16:07
mp3 file icon roc2.mp3 (136,404 bytes) Feb 21, 2009, 16:08
mp3 file icon roc1.mp3 (1,392,875 bytes) Feb 21, 2009, 16:13
Relationships
There are no relationship linked to this issue.
Notes
25
User avatar
No.03682
couriersud
Developer
Jan 29, 2009, 02:02
I do not think this is a bug. The period for an envelope is 256*EP clocks. Given that the driver is clocked with clock / 8 we get 32 * EP clocks. For the YM, we get 32 steps within one envelope. For the AY, there are 16 and we are counting till 2 * EP.
You should check against 0121 as well. This version should give the envelope durations as 0124u5+.
Apart from the envelope, there is no way to control tone length with AY registers.

If you have access to a amidar pcb, please attach some recordings so we may investigate further.
User avatar
No.03687
couriersud
Developer
Jan 29, 2009, 08:09
Update: amidar does not use envelopes. Please provide a real pcb recording
User avatar
No.03702
couriersud
Developer
Jan 30, 2009, 22:56
Update #3:

This is not an issue within the ay8910 driver. The bug report needs to be updated. This issue is driver specific.

At around the same time Aaron commited the new galaxian driver. One part of the rewrite was a change to the sound timer code, which is now properly representing the available schematics. The timer sequence provided at port B of one of the ay8910 however now differs from the old driver and most likely is causing the issues.
User avatar
No.03703
couriersud
Developer
Jan 31, 2009, 00:22
0124u4 sounds exactly like 0124u5. To further nail down the issue, please provide a regression version, i.e. the version when it first occurred.
User avatar
No.03705
Tafoid
Administrator
Jan 31, 2009, 04:39
Actually, using Frogger as a reference - you can hear a major difference between 0.124u3 and 0.124u4.
User avatar
No.03706
couriersud
Developer
Jan 31, 2009, 05:19
edited on: Jan 31, 2009, 05:38
Yes, between 124u3 and u4 the ay8910 rewrite happened. But the bug report here is about tone duration. The ay8910 does not control tone duration - apart from envelopes, which are not used e.g. in amidar. Tone duration must be controlled by the sound cpu.

As far as I can judge 124u3 is very similar to 124u5 when it comes to tone durations.
And between 0123 and 0124u3 there has been the galaxian rewrite as well.

The bug is not related to changes in 0124u5 which actually fixed envelope issues.
User avatar
No.03768
mcp
Tester
Feb 21, 2009, 09:00
edited on: Feb 22, 2009, 13:13
One can hear the wrong sound very exactly when playing Roc'n rope or Time Pilot ( High Score tune and Start tune ) which both use the AY-3-8910 - the sound seems to be played continuously without interruption. There could be a bug in the ADSR (attack/decay/sustain/release) emulation, it seems that sustain is too long and sound is never released, which describes the wrong sound in the Konami games mentioned.

Older mame versions ( < 124u4 ? ) do play the sound in a much more correct way, there is evidently sustain and release, eventually a little bit too gently.

I have uploaded sound samples from Time Pilot ( High Score tune ) and Roc'n Rope ( Game Over tune and the longer one is the start sequence til end of round 1 ). I have sampled from original arcade games at my home. If the quality is not sufficient I will try to make other samples.
User avatar
No.03790
couriersud
Developer
Feb 23, 2009, 01:21
I do not have the time right now for an in depth analysis, but the issue is not related to ADSR. ADSR is not enabled at any time. The duration is 0, the envelope select bits are not set and the envelope shape is 0.

I am wondering if there is an arcade game out there which uses ADSR.

The ADSR is most likely implemented in software. Thanks a lot for uploading the samples. I will analyse them as soon as I find a slot.
User avatar
No.03791
Sune_S
Senior Tester
Feb 23, 2009, 02:34
edited on: Feb 23, 2009, 02:41
Just redundantly pitching in..

Bomb Jack (3xAY-3-8910) and Gyruss (5xAY-3-8910!) sound arcade perfect in 129u4 to me.

Burnin' Rubber (2xAY-3-8910) too, except for the missing filtering - but that's been taken care of I see...got me excited about u5 too.

If there was something wrong with the '8910 emulation itself I would think a game like Gyruss that uses FIVE of them would sound wrong.

Apart from that I have to agree about Time Pilot, the note duration seem to be longer in the start and highscore tunes than they are on the real board. Unfortunately It's not possible for me to hook up and record my PCB at the moment and prove it.
User avatar
No.03796
mcp
Tester
Feb 23, 2009, 11:11
edited on: Feb 23, 2009, 12:43
Have compared Gyruss mame 121 and 129 with my Gyruss original PCB, the older mame version comes nearer to the original, actually there is a slight difference between mame 121 and mame 129.

However the difference is not that evident as it is with Roc'n Rope and Time Pilot because Gyruss has more organ-like tunes, but the difference is there. ( you can hear the difference clearly in first round at the end of the first Bach tune, hear the last 5 scores )

Having compared the mame versions with the 3 original PCBs I would hint as follows:
older mame versions ( < 124u4 ) play the sound much more accurate with regard to decay, but the newer mame versions play the sound with slightly more volume.
maybe envelope register 13 is affected ?
User avatar
No.03797
Haze
Senior Tester
Feb 23, 2009, 12:30
it's not something really silly like the ADSR code working fine, but the code that actually sets the registers to enable it being broken, thus it always appearing to be 'off' is it?
User avatar
No.03808
couriersud
Developer
Feb 23, 2009, 20:14
Haze, no it is not that silly. I have plastered the code with logging calls right now and the two games in question do not make use of ADSR. Actually I have not seen a single arcade game yet using it.

The issue is most likely related to the output voltage of volume 0 (channel on) and volume 0 (channel off). The datasheet is not clear at all here. If there is a difference, it would mean that you hear something if a tone is output with e.g. 1 Khz. If the voltages do not differ, well you would hear nothing.

Most other ay8910 sources out in the field neglect the difference, because their primary purpose is to play "register files". Those files do not make use of tone generation. They turn the channel on, set the period to infinity and vary the volume. As a reference, this does not help us.

On the other hand, some games (e.g. scramble) need the difference so that you can hear the "bullet" sound at all.

Perhaps I find some time to look (hear) at the recording later.

@mcp: Where exactly did you do the recordings? It would really help if we could get recordings directly of the pcb, e.g. pins 4,3 or 38 of the AY8910.

In addition, you may try changing the following line (around 709 in ay8910.c) from

info->zero_is_off = 1;

to

info->zero_is_off = 0;

This causes audible decay again, but bullets in scramble are barely audible.
User avatar
No.03809
couriersud
Developer
Feb 23, 2009, 20:31
The output is more in line with the recordings now is well.
User avatar
No.03810
mcp
Tester
Feb 23, 2009, 21:29
@couriersud

I have recorded sound with my old cassette recorder and have sampled from there into my PC using audacity. I know the sound is somewhat ugly because too much overmodulating but you can hear the "piano" like sound of the arcade games compared to the "organ" like sound in the late mame versions.
If you really need more direct sound recordings, I could try to get my PC line-in connected to the PCB, but have to check out.

btw: http://dev-docs.atariforge.org/files/GI_AY-3-8910_Feb-1979.pdf
( sure you already know the link, but maybe of interest )
User avatar
No.03811
couriersud
Developer
Feb 23, 2009, 21:44
mcp, could you try the source change to see whether it matches your pcb more closely?
User avatar
No.03816
mcp
Tester
Feb 24, 2009, 12:18
edited on: Feb 24, 2009, 17:56
@couriersud

ok, have built mame 129.
changed code ay8910.c as follows:
case SOUND_AY8910:
case SOUND_AY8930:
info->step = 2;
info->par = &ay8910_param;
info->par_env = &ay8910_param;
info->zero_is_off = 0; //1; <-- CHANGED to 0

Now the sound for Gyruss, Amidar, Tutankham, Time Pilot and Roc'n Rope again comes very close to the arcade versions!
I have compared with my arcade PCBs again and all fit well.
User avatar
No.03818
couriersud
Developer
Feb 24, 2009, 20:21
Good, will submit this soon together with changes from the attached post on comp.sys.sinclair from Dec 2001. After a year of searching, finally found some real measurements!

This should make the emulation more accurate, specifically for drivers with discrete filters/mixing.

However, there may be the need to change volume in certain drivers.

---------------------------------------------------------------------------------------

http://groups.google.com/group/comp.sys.sinclair/browse_thread/thread/fb3091da4c4caf26/d5959a800cda0b5e?lnk=gst&q=Matthew+Westcott#d5959a800cda0b5e

After what Russell mentioned a couple of weeks back about the lack of
publicised measurements of AY chip volumes - I've finally got round to
making these readings, and I'm placing them in the public domain - so
anyone's welcome to use them in emulators or anything else.

To make the readings, I set up the chip to produce a constant voltage on
channel C (setting bits 2 and 5 of register 6), and varied the amplitude
(the low 4 bits of register 10). The voltages were measured between the
channel C output (pin 1) and ground (pin 6).

Level Voltage
 0 1.147
 1 1.162
 2 1.169
 3 1.178
 4 1.192
 5 1.213
 6 1.238
 7 1.299
 8 1.336
 9 1.457
10 1.573
11 1.707
12 1.882
13 2.06
14 2.32
15 2.58

Presumably anyone doing anything useful with these will want to subtract
1.147 from all of these to get a scale that starts at zero. Oh, and the
'blip' at levels 7 and 8 (as shown in the RealSpec and AYEmul results)
happens here as well.

--
Matthew Westcott - CSSfiance to Nattie
http://www.zxdemo.org/ - the home of the Spectrum demo scene
"there's a breach in security, a disturbance in the chuntey"
User avatar
No.03832
couriersud
Developer
Feb 26, 2009, 23:17
Changes will be in 129u6. Please review after release.
User avatar
No.03846
Sune_S
Senior Tester
Feb 28, 2009, 04:37
Nice find! It's not the first time someone from the Speccy emulation scene contributes directly or indirectly to MAME.
User avatar
No.03850
Stefan Lindberg
Senior Tester
Feb 28, 2009, 09:05
Something similar has to be done with YM2149 also... right? As it output a differnt voltage.
User avatar
No.03853
Haze
Senior Tester
Feb 28, 2009, 12:43
Well, the best tests for a lot of the systems / components in MAME are on computers / consoles, so it makes sense, in many cases it's the only way to ensure things are *really* accurate. As couriersud points out, there are features of the AY it doesn't look like any arcade game uses, and that's a common chip. The speccy rocked anyway ;-)
User avatar
No.03866
couriersud
Developer
Mar 1, 2009, 14:41
measurements have been taken for the YM2149 and the internal model is replicating those measurements. Details are in ay8910.c
The DC offset for the AY and YM are differently modeled if AY8910_DISCRETE_OUTPUT is specified.
User avatar
No.03894
mcp
Tester
Mar 6, 2009, 12:15
Having tested Gyruss, Tutankham, Rocn Rope, Amidar, Time Pilot and Scramble mame v129u6.

Tutankham, Rocn Rope, Time Pilot and Amidar: very accurate when compared with original arcade version.

Scramble bullet sound can easily be heared. Have no PCB, cannot compare.

Gyruss sound has issues now !
Gyruss background music, in my testings in the right channel, is very false now which can easily be heared.
User avatar
No.03897
couriersud
Developer
Mar 6, 2009, 22:16
edited on: Mar 6, 2009, 22:40
A sound recording taken at VR1 (right channel) would help tremendously.
The recording directly off the pcb is needed to verify the DC component of the signal and the levels around it.
User avatar
No.03999
couriersud
Developer
Mar 19, 2009, 01:08
Gyruss sound regression fixed
* Details in source