English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 01 April 2024, 23:33   #1
remz
Registered User
 
Join Date: May 2022
Location: Canada
Posts: 139
Paula Audio DMA general questions

Hi Amiga coders,

Would someone be able to kindly point me to some explanation or documentation on the exact workings of Amiga audio registers and paula state machine? (Aside from the hardware reference manual)?

For example, a few questions I have in mind:

When using DMA audio, normal unattached independent channels:

Exactly when is AUDxLC being read? I seem to understand it is re-read every time the currently playing sound has reached its AUDxLEN.
If so, I must assume one should always turn off DMA for an audio channel prior to resetting the AUDxLC 32-bit pointer, otherwise one risks having a partially set address (since split into two 16-bit writes, perhaps except on 32-bit chip (?), but even then, one cannot write both pointer and length atomically so there is always a risk of race condition here.

However AUDxPER and AUDxVOL can be freely written at all time and Paula will fetch them at every scanline? (or perhaps at every DMA read, thus depending on the current Period rate?)

Is it enough to write to DMACON to provoke the re-reading of the audio pointer? Or must that channel have been set to off beforehand?

I assume that leaving a fast, low period, silent 2-byte looping audio is wasting bus bandwidth, and would be more efficient to turn off the dma channel instead? (Alternatively, setting an extremely high period would make this channel waste less bus bandwidth? Is 65535 the maximum period in fact?)

I also assume that running a looping sample, whatever its length, if the volume is set to zero, is exactly equivalent of looping on a [0,0] empty sample?

These are all that come to mind now but any additional useful guide or information would be greatly appreciated!

What a wonderful machine, the Amiga..
remz is offline  
Old 02 April 2024, 00:43   #2
mc6809e
Registered User
 
Join Date: Jan 2012
Location: USA
Posts: 372
The main thing is to understand is the division of responsibility between Agnus and Paula. Paula's logic will tell Agnus that it needs a new sample from the stored waveform or that it has reached the end of a waveform but for the most part it's just outputting whatever two samples are in the data register at a rate determined by the period. It's up to Agnus to fetch samples to fill the data register after the samples have been output. And it's up to Agnus to reset pointers when the end of the waveform been reached.

Agnus does its work near the beginning of a scanline. This limits the rate at which Paula's data registers can be filled with new data. This means that if Paula is outputting samples too quickly Agnus may not be able to keep up and Paula will go right on outputting whatever old data is in the data register. It doesn't care that the data haven't been changed.

If DMA is off, Paula still doesn't care. It can continue outputting the two samples wasting no bandwidth.
mc6809e is offline  
Old 02 April 2024, 01:50   #3
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,039
Quote:
Originally Posted by remz View Post
Exactly when is AUDxLC being read?
1. When the audio DMA is activated and the first word has to be fetched.
2. After playing the last byte (length counter has hit 0) and then after the period counter has hit 0 (or: when the audio DMA is used to fetch the next word and you are at the end).
Also, audio hw will check its DMA state only when it has to fetch, so a too quick disable + re-enable would most likely go unnoticed.

Safe way:
- disable audio DMA (makes your writes atomic, among other things)
- write pointer, length, and other stuff as needed
- wait maximum* amount of time so that audio hw detects it's been disabled
- enable audio DMA
* This depends on the highest period value you are using, the period counter must hit 0 before you re-enable DMA so that the hw catches up. One option could be to set the period to 1 right after disabling the audio DMA, to speed it up. Period change is applied (copied to the internal period counter register) immediately IIRC, someone will surely correct me if I'm wrong about this one.

Might be hard to decipher everything: http://amigadev.elowar.com/read/ADCD.../node02DC.html
a/b is offline  
Old 02 April 2024, 08:45   #4
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,515
Here are some details, hope this helps:

AUDxPT: when Agnus does first DMA, it gets both DMA request and DMA reset bits via DMAL, does DMA from old AUDxPT -> AUDxDAT and loads new AUDxPT (state 1, this word is not used for anything), second fetch fetches from new PT (state 5).

AUDxLEN: Paula loads it to internal register immediately when DMA gets enabled (and when sample repeats)

AUDxVOL/AUDxPER: Paula loads both to internal registers when new 8-bit sample starts playing (=Volume/Period changes do nothing when Paula plays the sample and period is counting down)

Also when audio DMA gets disabled, it only prevents Paula from generating NEW DMA requests. Possible already DMAL queued DMA will still happen in next scan line. Agnus ignores DMACON audio (and floppy) bits.
Toni Wilen is offline  
Old 14 April 2024, 13:39   #5
remz
Registered User
 
Join Date: May 2022
Location: Canada
Posts: 139
I have a small bonus question: Is there an official mention that forbids writing 8-bit (byte) to a custom register?
Taking for example AUDxVOL, where only the 7 low bits are used, with the other bits being marked as "not used" in the doc, which means must be set to zero.
I wondered how the hardware reacted to a byte write in that scenario? (from testing at least in WinUAE, it appears to work fine.)
remz is offline  
Old 14 April 2024, 13:48   #6
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,039
Upper byte (bits 8-15) = lower byte (might be different on some 020+, e.g 060, but in this case it doesn't matter), because audio volume only uses bits 0-6, so it works fine. You can also have any value in bit7 (I'm doing that in my 4kb intro PT player, no problems).
a/b is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
What is the maximum size of memory Paula can play under a DMA interrupt? CCCP alert Amiga scene 8 10 March 2024 22:15
Understanding DMA audio remz Coders. Asm / Hardware 16 30 December 2023 02:42
strange way to set dma audio leonard Coders. Asm / Hardware 44 27 March 2021 13:21
DMA-free audio robinsonb5 Coders. Asm / Hardware 3 05 November 2012 08:43
Amiga 4000 Paula Audio CU_AMiGA support.Hardware 50 01 March 2007 21:26

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 20:33.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.08765 seconds with 13 queries