Jump to content
IGNORED

TIA Sounding Off in the Digital Domain


Crispy

Recommended Posts

Excellent work on this, Crispy. I know I'm excited about this finding its way into emulation and other areas. (thanks Stephena!)

 

One observation... some people have separated their 2 TIA audio channels with stereo mods. It seems these folks now have real hardware with audio output closer to the less-faithful emulation. Something for the modders to keep in mind!

 

[edit - a single pole switch joining the channels on one of these modded systems would be an excellent way to experience the difference]

  • Like 2
Link to comment
Share on other sites

Excellent work on this, Crispy. I know I'm excited about this finding its way into emulation and other areas. (thanks Stephena!)

 

One observation... some people have separated their 2 TIA audio channels with stereo mods. It seems these folks now have real hardware with audio output closer to the less-faithful emulation. Something for the modders to keep in mind!

 

[edit - a single pole switch joining the channels on one of these modded systems would be an excellent way to experience the difference]

 

Raises hand...I have one such (Woody modded) system with the channels separated. It's sometimes cool to hear sound only from either the left or right side for some effects, but also can standout a little too much at times depending on where I'm sitting, relative to speaker positioning.

 

For instance, in the most excellently programmed 4/8K remake of Pac-Man for the 2600, it clearly emphasizes some of the intro melody playing from one side/channel, and the other pieces of the melody playing on the other speaker/channel. Almost to the point of being distracting and annoying if I'm leaning slightly more towards one speaker or the other, as the sound comes across as being imbalanced.

 

Love the idea of the pole switch, and if someone ever does it, that's going to make me slightly jealous over who possess it. I have come close to just merging the lines via RCA adapters externally - very similar to the hardware used to merge the Vox output with the 2600 & 7800 sound output. For some games though, it is still pretty cool having that separation of sound in place.

Link to comment
Share on other sites

Yes, I also have some questions about true stereo sound, which Stella currently emulates. This new code doesn't (yet) do that, so more work is still required. I'm concentrating on integrating the current code into Stella before I look into expanding it with new features.

Link to comment
Share on other sites

Excellent work on this, Crispy. I know I'm excited about this finding its way into emulation and other areas. (thanks Stephena!)

 

One observation... some people have separated their 2 TIA audio channels with stereo mods. It seems these folks now have real hardware with audio output closer to the less-faithful emulation. Something for the modders to keep in mind!

 

[edit - a single pole switch joining the channels on one of these modded systems would be an excellent way to experience the difference]

 

Yes, this is an excellent point RevEng. Breaking the direct connection between the two audio pins on the TIA will change the sound.

 

While on the subject of stereo sound, I'll throw in a couple of ideas that I had. I was thinking of adding mixed stereo sound to the HDMI interface on my FPGA 2600. It's too late for the analog audio since it's hard wired for mono sound on the PCB, so I would only be able to do this for the HDMI audio. My thought was to define two new TIA registers that would be used to position each audio channel on the stereo output. It would be an 8 bit register, and a 0 would position the channel all the way left, while a 255 would position it all the way right. With this feature a channel could be panned, or placed at any position in the stereo image.

 

Of course this would be a useless feature since it would require games to be written to take advantage of the new feature, and it's unlikely that my FPGA 2600 will become a target platform for game designers. So I had the idea of an add-on board for real 2600 systems. I could create a small PCB that would sandwich in between the main PCB and the TIA (the TIA would be removed from the main board, and plugged into a socket on the add-on board). It would have logic that would decode the new register addresses, and store the values written to these addresses. These values would be then used to control each mixer for each TIA audio channel. It's just a thought.

Edited by Crispy
Link to comment
Share on other sites

Yes, I also have some questions about true stereo sound, which Stella currently emulates. This new code doesn't (yet) do that, so more work is still required. I'm concentrating on integrating the current code into Stella before I look into expanding it with new features.

 

Easier done than said.

unsigned short left;
unsigned short right;
unsigned short vol_lut[256];

left = vol_lut[aud0_pulse_is_high ? AUDV0 : 0];
right = vol_lut[aud1_pulse_is_high ? AUDV1 : 0];


Edited by Crispy
Link to comment
Share on other sites

Here's my first pass at converting the code from Crispy to C++, and into a TIASnd class that can be plugged into Stella. I must say that everything is working perfectly, and the output is exactly the same from the original C code.

 

One question I have is on the deferred writes when a write to a sound register misses both cycles on the previous line (then does them on the next line): does this apply to all registers, or only to AUDFx? I ask because the phaser ROM example only did it for AUDFx, but it seems that the code should take all registers into account. It's very easy to add; I just want to make sure it's the right thing to do.

 

Anyone who is interested, please look at the new code: TIASnd.zip.

  • Like 2
Link to comment
Share on other sites

Here's my first pass at converting the code from Crispy to C++, and into a TIASnd class that can be plugged into Stella. I must say that everything is working perfectly, and the output is exactly the same from the original C code.

 

One question I have is on the deferred writes when a write to a sound register misses both cycles on the previous line (then does them on the next line): does this apply to all registers, or only to AUDFx? I ask because the phaser ROM example only did it for AUDFx, but it seems that the code should take all registers into account. It's very easy to add; I just want to make sure it's the right thing to do.

 

Anyone who is interested, please look at the new code: TIASnd.zip.

Very cool.

 

Don't get too bogged down in the details concerning what I called deferred writes in my test bench. The important point is that for every call to TIASnd::updateAudioState(), the audf and audc parameters must contain the values that were in AUDF and AUDC at the point in time with which this audio sample is associated. So yes, if a register write happens after the second audio clock cycle on a line, then the value written won't be seen by the audio blocks until the next line, and this applies to all registers.

Edited by Crispy
Link to comment
Share on other sites

Just wanted to update on the current status of converting this code to Stella. The class now includes outputting samples in stereo or mono. The following is from Audacity, which is an open-source sound editing program. It uses the 'tremolo.bin' ROM posted at the start of this thread, and by pressing both Select and Reset.

 

The first is the mono sampling, or IOW, mixing of the two TIA channels as described by Crispy in the original PDF (note that the channels aren't simply added together, but influence each other):

post-1512-0-62114100-1458258652_thumb.png

 

The next is in stereo mode, with each channel separated. You can clearly see the two separate tones generated by the ROM; they are not blended together at all:

post-1512-0-85733800-1458258660_thumb.png

 

Ironically, the mono output from Stella currently is what is called stereo here, and there's no mode in current Stella to emulate the mono mixing; that's the point of adding this code. I'll post the updated code soon.

  • Like 3
Link to comment
Share on other sites

To be clear:

A switch to recombine split TIA audio will cause both channels to influence each other, and just setting your display to mono won't cause the separated channels to influence each other?

 

I thought setting your display to mono if the separation was undesirable for a particular game was a great tip, but that won't recreate the un-modified 2600's sound?

 

P.S. Thanks Crispy for any help you gave or will give to the Stella emulator!

For a quick TIA graphic test that Stella gets wrong, start Pole Position. The "0" m.p.h. in the upper left is a box on hardware, and a broken box with a dot inside on Stella.

Link to comment
Share on other sites

The unmodified, mixed channel output from real console will be emulated with the new mono setting. It will be the default setting in Stella. The stereo setting will emulate a real console with a hardware modification that actually separates the TIA channels, meaning that each channel will not modify the other. This is what Stella currently does in both modes, but it is not accurately emulating a real console.

 

EDIT: To be absolutely clear:

 

Current Stella:

'mono' setting mixes the two channels using simple addition and averaging, which doesn't accurately emulate what a real, unmodified console sounds like

'stereo' setting sends TIA channel 1 to the left speaker, and TIA channel 2 to the right speaker.

 

New Stella (with the new sound code integrated):

'mono' setting mixes the two channels using the methods described in the PDF of this thread, which accurately emulate a real, unmodified console

'stereo' setting does the same as above, and emulates a real console with a hardware mod installed that physically separates the TIA channels.

 

Of course, the code contains other improvements too, like doing delayed writes to registers, and in general being cycle-exact wrt TIA sound. I kind of excited about it, since this has been a problem for so long in Stella.

  • Like 5
Link to comment
Share on other sites

The TIASnd class is the most obvious change; it is completely re-written. The next biggest change is that the logic for generating the samples is moving into the TIA class, as will the TIASnd object (so there will be a close relationship between those classes).

 

SoundSDL2 will mostly be gutted, since right now it contains the sound processing logic. In the new version, it will simply ask for sound samples from the TIA core (through TIASnd) with its callback. All reference to TIA registers, processing, etc will be removed. Which really makes sense, since that class should only be about getting sound samples from the core and passing them to the sound hardware; the sample generation itself moves into TIA/TIASnd.

  • Like 1
Link to comment
Share on other sites

That's more for a hardware person to answer, but I would guess it would depend on how exactly the split was done with the hardware mod. If it contains extra circuitry, then I don't know what effect there would be with recombining them into a mono TV.

Link to comment
Share on other sites

It depends on how the mod and/or TV stereo-to-mono is implemented, as Stephena alludes. If both channels are sent through a buffer/amp first before being recombined, then it would break the resistor ladder interactions Crispy described in his pdf, and sound more like the original Stella audio.

Link to comment
Share on other sites

It depends on how the mod and/or TV stereo-to-mono is implemented, as Stephena alludes. If both channels are sent through a buffer/amp first before being recombined, then it would break the resistor ladder interactions Crispy described in his pdf, and sound more like the original Stella audio.

 

I stand corrected! :) I missed the PDF in the opening post, and having read it I now see the interactions between channels are far more complex than I would have guessed.

  • Like 1
Link to comment
Share on other sites

  • 1 year later...

So, instead of creating a monster post, I'll just attach a PDF of my write up.

Late to the party. icon_smile.gif (and still trying to follow)

 

I checked the lookup table created in the PDF. It seems that the two channels do not really modify each other, but that their volumes simply add. But higher volumes are compressed more than lower volumes. So e.g. 10+6 has the same volume as 15+1. Knowing that, the LUT can be reduced to 31 entries.

Edited by Thomas Jentzsch
Link to comment
Share on other sites

It depends on how the mod and/or TV stereo-to-mono is implemented, as Stephena alludes. If both channels are sent through a buffer/amp first before being recombined, then it would break the resistor ladder interactions Crispy described in his pdf, and sound more like the original Stella audio.

Not only combined channels are affected by the volume compression as described in the PDF. So, assuming the amp is linear, the recombined stereo signal's volume will still not be linear. But more linear than without splitting and recombining.

Link to comment
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...