RevEng Posted March 13, 2016 Share Posted March 13, 2016 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] 2 Quote Link to comment Share on other sites More sharing options...
Trebor Posted March 13, 2016 Share Posted March 13, 2016 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. Quote Link to comment Share on other sites More sharing options...
+stephena Posted March 13, 2016 Share Posted March 13, 2016 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. Quote Link to comment Share on other sites More sharing options...
Crispy Posted March 13, 2016 Author Share Posted March 13, 2016 (edited) 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 March 13, 2016 by Crispy Quote Link to comment Share on other sites More sharing options...
Crispy Posted March 13, 2016 Author Share Posted March 13, 2016 (edited) 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 March 13, 2016 by Crispy Quote Link to comment Share on other sites More sharing options...
+stephena Posted March 13, 2016 Share Posted March 13, 2016 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. 2 Quote Link to comment Share on other sites More sharing options...
Crispy Posted March 14, 2016 Author Share Posted March 14, 2016 (edited) 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 March 14, 2016 by Crispy Quote Link to comment Share on other sites More sharing options...
+stephena Posted March 17, 2016 Share Posted March 17, 2016 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): 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: 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. 3 Quote Link to comment Share on other sites More sharing options...
iesposta Posted March 18, 2016 Share Posted March 18, 2016 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. Quote Link to comment Share on other sites More sharing options...
+stephena Posted March 18, 2016 Share Posted March 18, 2016 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. 5 Quote Link to comment Share on other sites More sharing options...
Kylearan Posted March 18, 2016 Share Posted March 18, 2016 It's awesome that Stella's sound emulation gets improved! Will the changes only affect TIASnd, or will other classes be changed as well? I ask because I use Stella's sound emulation for TIATracker and would like to port the changes once you're finished. 1 Quote Link to comment Share on other sites More sharing options...
+stephena Posted March 18, 2016 Share Posted March 18, 2016 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. 1 Quote Link to comment Share on other sites More sharing options...
iesposta Posted March 18, 2016 Share Posted March 18, 2016 My question was about real Atari hardware and splitting, and whether a split TIA changed to mono on the TV does that influence effect. Not to detract from an awesome Stella advancement. Quote Link to comment Share on other sites More sharing options...
+stephena Posted March 18, 2016 Share Posted March 18, 2016 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. Quote Link to comment Share on other sites More sharing options...
+thegoldenband Posted March 18, 2016 Share Posted March 18, 2016 I'd think summing the signals back to mono shouldn't be a big deal, unless phase issues have crept in somewhere along the way. Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted March 18, 2016 Share Posted March 18, 2016 I'd think summing the signals back to mono shouldn't be a big deal, unless phase issues have crept in somewhere along the way. If that happens, just put the phasers on stun. Quote Link to comment Share on other sites More sharing options...
RevEng Posted March 18, 2016 Share Posted March 18, 2016 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. Quote Link to comment Share on other sites More sharing options...
+thegoldenband Posted March 18, 2016 Share Posted March 18, 2016 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. 1 Quote Link to comment Share on other sites More sharing options...
+stephena Posted March 18, 2016 Share Posted March 18, 2016 OK, here's my second pass at the TIASnd code for Stella: TIASnd.zip In this version, variable names are cleaned up to match Stella naming scheme, and now implemented are stereo/mono output and volume control. I think it's getting pretty close to integrating into Stella. 5 Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted August 7, 2017 Share Posted August 7, 2017 (edited) So, instead of creating a monster post, I'll just attach a PDF of my write up. Late to the party. (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 August 7, 2017 by Thomas Jentzsch Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted August 7, 2017 Share Posted August 7, 2017 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.