Xref: utzoo comp.sys.amiga.programmer:1789 comp.sys.amiga.audio:435 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!uwm.edu!linac!att!pacbell.com!ucsd!nosc!crash!jcs From: jcs@crash.cts.com (John Schultz) Newsgroups: comp.sys.amiga.programmer,comp.sys.amiga.audio Subject: Re: playing samples using audio h/w Message-ID: <8203@crash.cts.com> Date: 26 Mar 91 06:53:13 GMT References: <2325@m1.cs.man.ac.uk> Organization: Crash TimeSharing, El Cajon, CA Lines: 43 >> I'm having a problem playing sound samples by hitting the >>hardware directly. The problem is that I set up the registers >>for the channel I'm going to use and set audio DMA going >> using >> move.w #(DMAF_SETCLR!DMAF_MASTER!DMAF_AUD0),dmacon(a0) >>as per the h/w manual. The sound starts playing OK. >> If I then stop the sound by turning its DMA off using >> move.w #DMAF_AUD0,dmacon(a0) again as in the h/w manual, >>the sound stops. If I then reload the registers and start >>DMA going the sound I get is the remains of the first sample >>(assuming I stopped it before it had finished playing >>completely). The h/w manual does say that if you stop and >>start DMA over a short period then this can happen but there >>is actually quite a long delay between turning off DMA for >>the first sample and turning it on for the second. >> Can anyone shed any light on this? Here's a quick look at how to do this: ; Brief excerpt showing how to stop DMA sound and play another. ; Although this example busy waits, it's still faster than the ; audio.device. An interrupt scheme is faster (and more elegant). move.w d2,intena(a0) ; disable 7-10 (aud) interrupts move.w d2,intreq(a0) ; clear any 7-10 interrupts move.w d6,dmacon(a0) ; shut off dma for channel move.w #0,ac_dat(a3) ; write directly to output (to stop) move.w #1,ac_per(a3) ; fast period (less waiting) move.w #$c000,intena(a0) ; enable wasteloop move.w intreqr(a0),d5 ; wait for interrupt and.w d2,d5 ; test against current mask cmp.w d2,d5 bne.b wasteloop ; not yet occurred ; Interrupt has occured, channel is stopped. move.w d2,intreq(a0) ; clear 7-10 interrupt ; Write values to regs here, then turn on dma... John