Jump to content

Audio Pitfalls


Recommended Posts

Apologies if this is well-known.


I noticed something recently : Atari messed up with the Jaguar audio subsytem. (Some of you will say it's not suprising ;) )

The Jaguar Technical Reference Manual v8 claims that the Word Strobe signal is high for the RIGHT channel, but according to the audio DAC datasheet, Word Strobe should be high for the LEFT channel.


There are two consequences :

  • The left and right channel are swapped. I.e. the L_I2S (LTXD, $F1A148) register should be called R_I2S (RTXD, $F1A14C) and vice-versa.

    Try it -- if you write to L_I2S only, the sound will be coming from the RIGHT speaker. (I always thought I had something wrong in my cabling, turns out it's not the case).

  • As the DAC expects data for the left channel before the right channel for a given sample, the I²S interrupt should be configured to occur on the RISING edge of Word Strobe, i.e. the SMODE register should be set to %001101.

Also, a related piece of advice : the I²S interrupt occurs shortly before sending the data to the DAC, so it's important to update the data registers as early as possible. If you don't, since the right data is sent first much later than the left data, it may happen than the left channel gets the data for the previous sample, while the right channel gets the data for the current sample. In other words, the channels will be out of phase by 1 sample.


Personally, I use code like this for the I²S interrupt :

(r2 and r3 are constants ; r2 = $F1A14C, r3 = $F1A148)



store r0, (r2)

store r1, (r3)

movei #i2s_int_2, r30

jump (r30)







; --- code to save the flags register (it's not affected by the stores) ---


;--- code to compute the left sample in r0 and the right sample in r1 ---


;--- code to restore the flags register and return from the interrupt ---

Link to comment
Share on other sites

Interesting. Thanks for the fix :)


Link to comment
Share on other sites

Just tested this morning and this is (really) true! I find strange that this bug is not (AFAIK) documented anywhere else.

Link to comment
Share on other sites

  • 2 years later...

Those last few days, I started playing with audio again.


First thing : apparently, Atari eventually realized something was wrong. The left/right channels swapping bug is actually documented in the later versions of the documentation (I used the scans from Tyrant, which are the most recent version I know about - the JagRef revision 8 PDF is actually an older version). Well... "documented" is a strong word. They removed the timing diagrams, added alternate definitions of the registers called L_DAC and R_DAC, and some text saying "Note that these registers have right and left swapped on purpose". You didn't think Atari would have admitted they'd made a mistake, did you ? :P


It seems the mistake was discovered quite early, because definitions for L_DAC and R_DAC can be found in Jaguar.inc files dating back to 1993, and they are correct (L_DAC = $F1A14C and R_DAC = $F1A148).

Note that the definitions of L_I2S/R_I2S, LTXD/RTXD and LRXD/RRXD have not been changed. So if you don't want your channels to be swapped, you should use L_DAC and R_DAC instead of those.


Another related and interesting question : which register should be written first, L_DAC or R_DAC ? The Atari sample code writes to R_DAC first. I tried both, and it doesn't seem to make any difference.


So this part of the puzzle looks pretty clear now.


But there's still something strange about the SMODE register. Atari sample code enables the interrupt on the falling edge of Word Strobe. Before, I thought they got it wrong, and that it should be set to the rising edge instead.

But it appears that it depends on the sample rate. For low sample rates, the channels are in-phase with the rising edge setting, and out of phase by one sample with the falling edge setting. For high sample rates, it works the other way ! So back to square one...

The Jaguar is definitely a mysterious animal :D


(by the way, if you think a delay of one sample between two audio channels is negligible, check this article. Sony had a similar bug in some of their MiniDisc players, and it can indeed cause problems.)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...