Jump to content

Recommended Posts

While improving the sound emulation in Stella, we got some better insight into the TIA's sound generation.

 

One important finding is, that the TIA volume is not linear (by far). E.g. a volume value of 56 is exactly 50% as loud as a value of 15. The higher the volume, the more it gets compressed.

 

While this is good to know if you want to control the volume, this seems like no major problem. But the non-linearity affects both channels combined. This means that the combined volume of both channels is compressed too. E.g. a combined volume value of 10 is exactly 50% as loud as a combined value of 30, a volume of 15 is exactly 2/3 as loud as 30. And then the fun begins.

 

Usually, if you combine e.g. two sinus waves of different frequencies, the resulting wave will look pretty wild. But it will still only contain the two original sinus waves. But doing the same with the TIA will add additional artifacts. This is because the amplitudes of both waves influence each other. If e.g. one wave is a full peak (volume = 15) the other wave at full peak would only add 50% of what it would add if played alone. And if you combine non-sinus waves, the effects are even stronger.

 

The higher the combined volume, the more noticeable this becomes. I yet have to see an analysis (e.g. a Fourier transformation) of the the resulting waves, but I am pretty sure that additional frequencies are added which result from the hefty volume compression. You can clearly hear those as distortions.

 

E.g. Ms. Pac-Man and E.T. sound pretty distorted on real hardware. This is because both games combine both channels at maximum volume value (15). And there the volume compression strikes most. If the volume values are reduced to e.g. 6 (= 50%), the distortions are much reduced.

 

Rule of thumb:

When you create sounds and especially music and want to avoid those distortions, reduce the volume. If you want to create unique, distorted effects, use high volumes.

Edited by Thomas Jentzsch
  • Like 12

Share this post


Link to post
Share on other sites

E.g. Ms. Pac-Man and E.T. sound pretty distorted on real hardware. This is because both games combine both channels at maximum volume value (15). And there the volume compression strikes most. If the volume values are reduced to e.g. 5, the distortions are much reduced.

 

The games with the most grating sound under the 7800 are the Nintendo ports; all of which sound like the volume is cranked way up when compared to most other titles.

 

Wondering how much less dissonant those games would be if the volume was reduced by 1/3 as well.

:ponder:

Share this post


Link to post
Share on other sites

Here is Ms. Pac-Man with the volumes of the tunes reduced by 25% (volume 10) and 50% (volume 6). On real hardware (or in Stellerator and soon Stella too) you can hear the difference.

Ms. Pac-Man (1982) (Atari) (volume 10).a26

Ms. Pac-Man (1982) (Atari) (volume 6).a26

Edited by Thomas Jentzsch
  • Like 1

Share this post


Link to post
Share on other sites

(or in Stellerator and soon Stella too)

Excuse my ignorance, but what is Stellerator? It popped up several times in the past weeks, but all I can find is Stellarator, an emulator that according to its GitHub page has no audio...?

Share this post


Link to post
Share on other sites

Excuse my ignorance, but what is Stellerator? It popped up several times in the past weeks, but all I can find is Stellarator, an emulator that according to its GitHub page has no audio...?

https://6502ts.github.io/stellerator/

 

The developer is the same who helped improving the Stella TIA emulation lately.

Edited by Thomas Jentzsch

Share this post


Link to post
Share on other sites

Google gave me https://github.com/dpiponi/Stellarator(note the "a" instead of the "e" in the name), where it says "There is no audio yet.." so I was confused. :)

 

 

:) An slightly unfortunate name collision. The emulator you found is written in Haskell and (from what I know) a work in progress --- there is a thread by the dev somewhere on this forum.

 

My emulator is a web based (written in TypeScript, a statically typed superset of JavaScript) emulator called 6502.ts --- you can find the GitHub link in my sig. It was (is) meant to eventually support more 6502 based target platforms, therefore the name. Stellerator is the name of the user-facing frontend for the VCS implementation. In hindsight, I might have chosen a slightly more descriptive and google-friendly name, but that's how it goes :P

Edited by DirtyHairy

Share this post


Link to post
Share on other sites

I tried Stellerator with some of my demos, and I'm quite impressed. I don't have the latest version of Stella installed at the moment so the comparison is unfair, but right now Stellerator looks and sounds more like a VCS connected to a real TV. This is great!

  • Like 1

Share this post


Link to post
Share on other sites

Thanks to DirtyHairy since version 5.0 Stella has the same, all new TIA core as Stellarator. Except for sound which is currently implemented.

Edited by Thomas Jentzsch
  • Like 2

Share this post


Link to post
Share on other sites

I tried Stellerator with some of my demos, and I'm quite impressed. I don't have the latest version of Stella installed at the moment so the comparison is unfair, but right now Stellerator looks and sounds more like a VCS connected to a real TV. This is great!

 

Thanks a lot! The next thing I'll Stellarator-wise do is a embeddable version that can be used to embed games and demos in other websites.

 

Thanks to DirtyHairy since version 5.0 Stella has the same, all new TIA core as Stellarator. Except for sound which is currently implemented.

 

 

I should also add that I don't think that, without I my involvement in Stella, I would have managed to take 6502.ts to the point where it currently stands in terms of accuracy. The TIA and RIOT implementations of the two emulators have evolved together over the last year, and they're almost identical at this point.

Edited by DirtyHairy
  • Like 3

Share this post


Link to post
Share on other sites

Sounds much like the POKEY, where there are 64 total volume levels across all channels, but if you exceed 32 you start getting distortion/artifacting. I'm guessing the TIA has a similar cut-off point

Share this post


Link to post
Share on other sites

There is not hard cut off, but the volume is compressed. With each step in volume, the effective volume gain becomes smaller.

Share this post


Link to post
Share on other sites

Hard to tell. I posted two versions of Ms Pac Man above, but got no feedback yet.

 

IMO the distortions are still quite noticeable with volume 10, but volume 6 sounds OK for me.

Edited by Thomas Jentzsch

Share this post


Link to post
Share on other sites

After doing the maths, the equation that governs the nonlinear mixing of the two channels is simple enough:

 

post-47984-0-22274900-1510777103.gif

The values in this equation are:

  • v_out: the volume after mixing the channels (normalized between 0 and 1)
  • v_in: the added volume of the two channels before mixing (between 0 and 30)
  • v_max = 30: the maximum added volume
  • R_0 = 30, R_1 = 1: two characteristic resistances of the mixing circuit (actual unit in the circuit is kOhms)

The first factor is just the added volume of the two channels normalized to 1, and the second factor is a nonlinear volume boost that becomes smaller with increasing volume, effectively compressing the signal. So, as Thomas says, there is not "hard" transition between linearity and compression.

Edited by DirtyHairy
  • Like 7

Share this post


Link to post
Share on other sites

We need to get this properly documented, perhaps in the Stella/Stellerator header file/source code.

  • Like 1

Share this post


Link to post
Share on other sites

We need to get this properly documented, perhaps in the Stella/Stellerator header file/source code.

 

 

I remember we talked to Albert before about hosting a wiki dedicated to VCS hardware lore on atariage. I think this would be the best place for this kind of documentation.

Share this post


Link to post
Share on other sites

Sounds much like the POKEY, where there are 64 total volume levels across all channels, but if you exceed 32 you start getting distortion/artifacting. I'm guessing the TIA has a similar cut-off point

I was about to say that probably all sound chips from the early years suffer this kind of compression/distortion to some degree. I know personally from the VIC-I chip in the VIC-20 that if you set the global volume to maximum 15 (it doesn't have any per-channel volume registers), you can safely use one or perhaps two of the voices without distortion. Once you are using all three square waves and in particular also add the white noise, you will certainly want to lower the volume to 8-10 or so. I haven't done the math or scientific studies on the output sound wave but I very well recognize what is mentioned here about the TIA and POKEY.

 

I have too little experience of the AY and SN chips yet to determine if they have similar issues, though I wouldn't be surprised if they do. It seems perhaps the generation starting with SID and onwards is better at putting out maximum volume without terrible compression and distortion of the sound (though there are people who don't like its sound anyway, but that is another matter).

Share this post


Link to post
Share on other sites

How about using the Stella github repo and add a wiki there? Creating it is just a checkbox away. ;-)

 

 

True, but I think it would be more appropriate if this wiki would not be coupled to Stella, but part of atariage, where anyone with a atariage account can edit it.

Share this post


Link to post
Share on other sites

True, but I think it would be more appropriate if this wiki would not be coupled to Stella, but part of atariage, where anyone with a atariage account can edit it.

 

I agree. This is (and should be) general 2600 knowledge, editable by anyone having experience with the hardware. Stella (and Stellerator) may be the test bed for it, but everyone (other emulator authors, ROM developers, etc) should be able to use it.

Share this post


Link to post
Share on other sites

I strongly agree with setting up a wiki for VCS hardware on atariage. A unified place for information is always the best choice.

Share this post


Link to post
Share on other sites

Thanks for the detective work, Thomas and DirtyHairy! Looking forward to having this emulated in Stella. I have a hunch that this quirk might actually turn out to be a useful "feature" at some point ;)

  • Like 2

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...