English Amiga Board


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

 
 
Thread Tools
Old 20 January 2014, 22:25   #1
losso
Registered User
 
losso's Avatar
 
Join Date: Oct 2013
Location: Hamburg
Posts: 70
Audio: Re-triggering a note

Hey,

I'm writing a minimalist tracker playback routine. What would be the cheapest way to re-trigger a note that has not been fully played? From what I've read in the HRM, in order to stop and restart playback for a channel, its audio DMA flag has to be disabled long enough (two sampling periods) to prevent looping.

I want to avoid setting up interrupts and have a VBR-wait main loop. Would it be too coarse (and sound bad) if I just disable audio DMA for a whole frame before the new note is triggered? Or is there an easier (cheap) way to achieve this?

Thanks for any hints,

losso
losso is offline  
Old 22 January 2014, 13:51   #2
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,551
Quote:
Originally Posted by losso View Post
I'm writing a minimalist tracker playback routine. What would be the cheapest way to re-trigger a note that has not been fully played?
Usually you will stop audio DMA as soon as you have a new note (or a re-trigger) for a channel. Then wait some time to make sure that the new DMA-state propagates into the Audio State Machine (e.g. 500 ticks). Now you can enable DMA again and the new sample pointer and length will be latched.


Quote:
I want to avoid setting up interrupts and have a VBR-wait main loop. Would it be too coarse (and sound bad) if I just disable audio DMA for a whole frame before the new note is triggered?
A whole frame of silence when you want to retrigger a note is a lot of time.


Quote:
Or is there an easier (cheap) way to achieve this?
You can do it like some older/bad players: busy-wait for a few raster lines, until you enable DMA again.
phx is offline  
Old 22 January 2014, 15:17   #3
pandy71
Registered User
 
Join Date: Jun 2010
Location: PL?
Posts: 2,888
set pointer to null data? write null data to AUDxDAT? (instead stopping play, just play silence)?
pandy71 is offline  
Old 22 January 2014, 19:59   #4
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,574
Writing to AUD pointers or data won't help (or any other audio register).

Agnus has already fetched next audio word (unless period is small enough) and audio pointer and length is only copied to internal registers when DMA starts or length becomes zero.

There is no other ways than to wait (max 2xaudio period color clocks). Writing low value to period register after clearing DMA bit should lower max waiting time to 1xaudio period color clocks. (Period is reloaded after each 8-bit sample)
Toni Wilen is online now  
Old 23 January 2014, 12:14   #5
pandy71
Registered User
 
Join Date: Jun 2010
Location: PL?
Posts: 2,888
Quote:
Originally Posted by Toni Wilen View Post
Writing to AUD pointers or data won't help (or any other audio register).

Agnus has already fetched next audio word (unless period is small enough) and audio pointer and length is only copied to internal registers when DMA starts or length becomes zero.

There is no other ways than to wait (max 2xaudio period color clocks). Writing low value to period register after clearing DMA bit should lower max waiting time to 1xaudio period color clocks. (Period is reloaded after each 8-bit sample)
So if i made sound with 2 samples (1 word), sample content will have analog ZERO (i assume 0 as real value), and i will set period to maximum possible then after ending required time, audio hardware will remain in constant playing 2 null samples, this one will be performed in a fully automatic way, with reasonable speed (AUDxPER) it should happen relatively simple and predictable.
Did i miss something?
As i understand issue is that for restarting , if restarting time (ie DMA play -> some time -> DMA stop --retrig time--> DMA start) is less than period then sample can be restarted from last position (i.e. before DMA was stopped), if retrig time is longer than period then there is no way to restart sample from last position and sample playout will start from beginning.

So looping is possible only by changing real pointer to sample data and this need to be controlled by software (CPU OR/AND Copper) - as stop DMA/start DMA in less two periods will not disturb audio continuity at all.
pandy71 is offline  
Old 23 January 2014, 12:46   #6
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,574
Quote:
Originally Posted by pandy71 View Post
So if i made sound with 2 samples (1 word), sample content will have analog ZERO (i assume 0 as real value), and i will set period to maximum possible then after ending required time, audio hardware will remain in constant playing 2 null samples, this one will be performed in a fully automatic way, with reasonable speed (AUDxPER) it should happen relatively simple and predictable.
Did i miss something?
I am not sure I understood.

After period ends twice (both audio states, 2 and 3, have finished), state machine enter idle state: channel's output stays at whatever the last 8-bit sample was.

Quote:
As i understand issue is that for restarting , if restarting time (ie DMA play -> some time -> DMA stop --retrig time--> DMA start) is less than period then sample can be restarted from last position (i.e. before DMA was stopped), if retrig time is longer than period then there is no way to restart sample from last position and sample playout will start from beginning.
Yes.

If DMA is turned on before audio state machine gets back to idle state (state 0), it continues like nothing happened. It technically changes to non-DMA mode and only condition out of non-DMA mode is: INTREQ bit must be set when state 3 period counting has finished. Writing or not writing to AUDxDAT does not matter!

Quote:
So looping is possible only by changing real pointer to sample data and this need to be controlled by software (CPU OR/AND Copper) - as stop DMA/start DMA in less two periods will not disturb audio continuity at all.
Yeah. It is impossible to have any effect on active DMA mode audio by writing to AUDxPT or AUDxLEN until previous AUDxLEN has counted to zero (or DMA is switched off long enough and state machine enters idle state)
Toni Wilen is online now  
Old 24 January 2014, 00:15   #7
pandy71
Registered User
 
Join Date: Jun 2010
Location: PL?
Posts: 2,888
Quote:
Originally Posted by Toni Wilen View Post
I am not sure I understood.
OK, sorry for that, yes it was not clear.

Generally fastest way to stop audio but make it responsive (stop play, start play) is to set sound that is long 1 word (2 samples), set sample value as zero, set period very high then audio DMA will start produce audio but there is no need to wait long time for 2xperiod as period is very short. So instead doing time consuming wait, kind of brute forced method can be used (with all remaining limitations).
Probably is not clear still anyway...
pandy71 is offline  
Old 24 January 2014, 18:07   #8
mc6809e
Registered User
 
Join Date: Jan 2012
Location: USA
Posts: 373
Quote:
Originally Posted by pandy71 View Post
OK, sorry for that, yes it was not clear.

Generally fastest way to stop audio but make it responsive (stop play, start play) is to set sound that is long 1 word (2 samples), set sample value as zero, set period very high then audio DMA will start produce audio but there is no need to wait long time for 2xperiod as period is very short. So instead doing time consuming wait, kind of brute forced method can be used (with all remaining limitations).
Probably is not clear still anyway...

How about turning DMA off, writing very small value to period, polling INTREQR, clear INTREQ, loading channel settings, and restarting DMA?

Not sure it would work, though. Audio state diagram seems to be missing a few things. Diagram suggests that the state may transition from 011 to 010 only if (perfin*(AUDxON + ~(AUDxIP)), but action on transition says AUDxIR if napnav & ~(AUDxON).
mc6809e 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
Best Audio Config in Winuae for a Creative X-Fi Audio Card shaf support.WinUAE 2 14 June 2012 16:27
Triggering the WinUAE Debugger? h0ffman Coders. General 2 03 June 2011 14:52
Triggering a Level 7 NMI Interrupt in WinUAE psw support.WinUAE 2 07 December 2010 15:14
Things to note about WHD Dragon's Lair MethodGit project.WHDLoad 18 18 April 2007 11:52
NOTE: You can't use DMS files with names longer than 18 characters! andreas support.WinUAE 2 07 July 2002 02:22

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 19:50.

Top

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