19 March 2021, 22:00 | #1 |
Registered User
Join Date: Apr 2013
Location: paris
Posts: 133
|
strange way to set dma audio
Hi,
The "official" safe way to start a new sampleA on voice A is: 1) switch off dma voice A ( move.w #$0001,$dff096 ) 2) write sample address ( move.l #sampleA,$dff0a0 ) 3) wait the right amount of time ( say X rasterlines ) 4) enable the dma voice A ( move.w #$8001,$dff096 ) Now I wonder if it's still safe to invert 1) and 2) like: 1) write sample address ( move.l #sampleA,$dff0a0 ) 2) switch off dma voice A ( move.w #$0001,$dff096 ) 3) wait the right amount of time ( say X rasterlines ) 4) enable the dma voice A ( move.w #$8001,$dff096 ) I think it should be ok but I want to be sure. Any though? |
19 March 2021, 22:15 | #2 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 54
Posts: 4,498
|
I see a possible weak point here: writing the pointer is not an atomic operation...
If the period [EDIT: of course I meant..] len counter has finished counting down and the DMA is still active a new sample is taken from the ptr position. The DMA is turned off immediately, but it is not an instant operation, sample in Paula is played. Could there possibly be an audio glitch? Toni should be asked Last edited by ross; 20 March 2021 at 11:21. |
20 March 2021, 07:52 | #3 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,355
|
This looks like a way to get a nice random sample triggering click
|
20 March 2021, 10:02 | #4 | |
Registered User
Join Date: Apr 2013
Location: paris
Posts: 133
|
Quote:
1) non atomic write occurs outside of PAULA exact loop point. In this case, the "next instrument" could be played (maybe one1 or two 8bits samples) before dma switch off and switch on again ( so the very first "good" sample will be played back again. I think this case is ok and doesn't produce noticeable annoying glitch ( with bad luck you will play the very first sample of the right instrument 2 times) 2) non atomic write occurs at the exact PAULA loop point. This case is a real issue, because if 1 or 2 samples are played before DMA is switched off, these two samples could be completely random ( I mean not the very first samples of the right instrument). So if case (2) could happen, then it could produce hearable audio glitch I agree. Toni, what do you think, is the case (2) possible on an Amiga? |
|
20 March 2021, 10:34 | #5 |
Registered User
Join Date: Apr 2013
Location: paris
Posts: 133
|
ok I simulated to worst case ever ( highest playing rate with smallest loop len ) and at least it produces audio glitches in WinUAE ( I didn't tested on real amiga ).
I'm still interested by Toni's view on that Code:
lea $dff000,a6 move.w #$f,$96(a6) move.w #1,$a4(a6) ; smallest sample len move.w #1,$a6(a6) ; highest replay rate move.w #64,$a8(a6) ; highest volume clr.w $50000 ; clear two samples at $50000 move.w #$807f,$50010 ; write worst audio glitch at $50010 clr.w $60010 ; write dummy sound at $60010 move.w #$807f,$60000 ; write worst audio glitch at $60000 move.w #$8001,$96(a6) ; start DMA play lea addrt(pc),a1 lea addrt+4(pc),a2 mainl: move.l (a1),$a0(a6) ; non atomic write $60010 (if it fails, audio will play $60000) move.l (a2),$a0(a6) ; non atomic write $50000 (if it fails, audio will play $50010) bra.s mainl addrt: dc.l $60010 dc.l $50000 |
20 March 2021, 10:49 | #6 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,574
|
I don't think there is anything too special. If AUDxLEN expires between writes (and DMA is on), it can cause side-effects.
|
20 March 2021, 13:13 | #7 |
Registered User
Join Date: Apr 2013
Location: paris
Posts: 133
|
right that is what my stress test show in winuae.
Ok I had a nice optimization for next LSP version but I won't use it because of potential audio glitch thanks! |
20 March 2021, 13:36 | #8 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,574
|
"DMA wait" stuff is the most annoying feature in Paula audio. It really should have had some way to instantly stop period counting/state machine 2<>3 "pingponging".
|
20 March 2021, 14:19 | #9 |
Registered User
Join Date: Apr 2013
Location: paris
Posts: 133
|
another question. For weird reason, I would use the highest bit of a sample start address to encode something. Is it safe on every amiga? ( I guess yes because PAULA sample address is 21 bits only but I want to double check).
Like is it ok on all amiga to do: move.l #sample|(1<<31),$dff0a0 |
20 March 2021, 14:38 | #10 | |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,574
|
Quote:
IMHO it would be safer to use bit 0 as a flag because DMA is always word aligned. |
|
20 March 2021, 15:14 | #11 |
Registered User
Join Date: Apr 2013
Location: paris
Posts: 133
|
|
20 March 2021, 16:21 | #12 |
Registered User
Join Date: Apr 2013
Location: paris
Posts: 133
|
I'm working on adding the last "big" missing feature in LSP: "instrument without a note". In some modules, a "instrument" is specified in the instrument column without a note. This is tricky case and many players ( esp PC players ) doesn't handle it correctly. What happen is that amiga players generally just write the "repstart/replen" in Paula registers ( so the instrument will really start at the end of the previous instrument loop )
I "think" these amiga players just write the Paula address using a non atomic "move.l" write instruction! So according to this forum thread, my guess is that it "could" ends in audio glitch. And to my knowledge, all amiga players are doing that actually (but I could be wrong, it's so hard to read amiga module player source code.... ) Did I miss something? |
20 March 2021, 16:56 | #13 |
Registered User
Join Date: Jun 2016
Location: europe
Posts: 1,068
|
PT2.3F ("reference player") doesn't play those I'm 99% sure.
|
20 March 2021, 19:01 | #14 |
Registered User
Join Date: Apr 2013
Location: paris
Posts: 133
|
you mean PT2.3F reference player doesn't support "instrument without a note"? I'm rewriting all LSP command encoding right now to support that ... Insane player will run same speed as before, but generic player will be slightly slower.
Do you know if p61 is supporting this feature? ( as p61 is the most used mod player in demos I guess I should at least be p61 feature complete ) |
20 March 2021, 20:24 | #15 |
Registered User
Join Date: Jun 2016
Location: europe
Posts: 1,068
|
Went again through the PT2.3F source... It explicitely checks for an empty note and skips the dma bits, pointer/length, period. Tried several scenarios, never ended up in that part of the code.
P61 does the same (doesn't play), actually easier to see what's going on there if you have a cleaned up source. |
20 March 2021, 21:11 | #16 | |
Registered User
Join Date: Apr 2013
Location: paris
Posts: 133
|
Quote:
|
|
20 March 2021, 21:39 | #17 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 54
Posts: 4,498
|
I'm pretty sure I've seen modules with this "instrument without the note" pattern (I remember it because it seemed strange to me ),
So a tracker/mplayer that supports it must certainly exist. |
20 March 2021, 22:10 | #18 |
Registered User
Join Date: Jun 2016
Location: europe
Posts: 1,068
|
Hmm, strange. It actually plays with PT2.3F, but not PT3/4 nor P61. All these play only one sample (#2), while PT2.3F plays both. Guess I must've missed one path (probably that delayed repstart/replen went through somehow).
I'd take PT2.3F as more correct. |
20 March 2021, 22:37 | #19 |
Registered User
Join Date: Apr 2013
Location: paris
Posts: 133
|
for instance this really cool attached .mod use a lot of "sample without note".
|
20 March 2021, 22:41 | #20 | |
Registered User
Join Date: Apr 2013
Location: paris
Posts: 133
|
Quote:
But something is still confusing to me: if you said PT2.3F replay my stress-test mod correctly, it means player should also write sample address using non atomic write during the play, right? We know it's not "legit". Maybe there is no glitch in this specific case |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
I want to set up an Amiga DAW for audio recording | Overmann | support.Hardware | 8 | 07 March 2019 10:45 |
Tools for set FILTER OFF audio | jhonny82 | support.Games | 14 | 22 July 2015 16:06 |
DMA-free audio | robinsonb5 | Coders. Asm / Hardware | 3 | 05 November 2012 08:43 |
CPU execution on odd cycles if no Audio/Disk/Sprite DMA | mc6809e | Coders. Asm / Hardware | 2 | 02 April 2012 19:50 |
Unsual Case of Dr. Strange / Return of Doctor Strange | killergorilla | HOL contributions | 1 | 12 July 2007 16:08 |
|
|