MemberAtarian Posted August 21, 2021 Share Posted August 21, 2021 Hi folks. I'm on the way on creating a new development framework for the Atari 2600 (you can see some peek of the development here: ), but unfortunately, I came to a point that I cannot understand. So, I plant to go with the audio editor and for that, I would like the generate the exact tones in the preview section that the TIA can produce. I looked at KK's own kernel, at Stella's, Javatari's code and even tough I understand how shift registers and poly work, I just cannot find out what kind of result I should get in the buffer, is my code working (translated well from C to Py). I attached both where I am right now (TiaTone) and also the also the code of Adam Wozniak from 2003 (wow, I was 16 and in attended high school that time!), this was easiest to me to understand as a source / inspiration. What kind of result should I get in the buffer? My guess is that there should be 44100 (or other freq) 0 or 1, that could be sent directly to the sound output channel, but since I get 0, 4 ot 6 with this code, even the lenght changes. It's not neccessary to be the most precise since the generated TIA data will be opened in Stella, but I would like to add some kind of preview as the user presses a piano button or hits a drum, etc. This is the project on github: https://github.com/MemberA2600/Fortari2600 TiaTone.py More sound source code (was Re_ [stella] TIA Audio Polynomia.pdf 1 Quote Link to comment Share on other sites More sharing options...
MemberAtarian Posted August 21, 2021 Author Share Posted August 21, 2021 Of course I wrote a small asm program that loops through all the important channels to me with gaps, but, recording Stella and cutting the wav out for playback would be too barbaric and only the last possible "solution". Quote Link to comment Share on other sites More sharing options...
JetSetIlly Posted August 23, 2021 Share Posted August 23, 2021 This is the TIA audio implementation for Gopher2600, which might give you a different view on it. In a nutshell, the audio.Mix() function is called every TIA video cycle. That function counts to 114 in order to produce the 31403Hz sample frequency from the 3.58Mhz video clock. On every 114th video cycle the two audio channels are processed and the volume of each channel mixed to produce a single volume value. https://github.com/JetSetIlly/Gopher2600/tree/master/hardware/tia/audio When writing to an audio buffer therefore, an output volume (an 8bit value in the case of Gopher2600) is written every 114 video cycles. If the playback sample rate is set to 31403Hz then the sound heard should be correct. To answer the question, "what kind of result should I get in the buffer?" my answer is a stream of samples (bytes) at a rate of 31403 per second. Hope this helps. Quote Link to comment Share on other sites More sharing options...
MemberAtarian Posted August 23, 2021 Author Share Posted August 23, 2021 9 minutes ago, JetSetIlly said: This is the TIA audio implementation for Gopher2600, which might give you a different view on it. In a nutshell, the audio.Mix() function is called every TIA video cycle. That function counts to 114 in order to produce the 31403Hz sample frequency from the 3.58Mhz video clock. On every 114th video cycle the two audio channels are processed and the volume of each channel mixed to produce a single volume value. https://github.com/JetSetIlly/Gopher2600/tree/master/hardware/tia/audio When writing to an audio buffer therefore, an output volume (an 8bit value in the case of Gopher2600) is written every 114 video cycles. If the playback sample rate is set to 31403Hz then the sound heard should be correct. To answer the question, "what kind of result should I get in the buffer?" my answer is a stream of samples (bytes) at a rate of 31403 per second. Hope this helps. Thankfully, I solved it yesterday in the morning. https://github.com/MemberA2600/Fortari2600/blob/master/src/Scripts/TiaTone.py 1 Quote Link to comment Share on other sites More sharing options...
+Andrew Davie Posted August 23, 2021 Share Posted August 23, 2021 Haha well done! 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.