09 December 2004, 09:23 | #1 |
Registered User
Join Date: Sep 2002
Location: Germany
Posts: 349
|
How to stop sample playback ?
Hi,
when playing a sound sample with direct hardware programming (e.g. in assembler) the sample is looped by default. What's the best way to stop the playback after it was played once (e.g.interrupt?) ? Any examples ? |
09 December 2004, 10:23 | #2 |
Mostly Harmless
Join Date: Aug 2004
Location: Northern Ireland
Posts: 1,115
|
Yes, the best way is to wait for the audio interrupt then stop DMA for the channel. I also set its volume to zero but I'm not sure if that is strictly necessary
|
09 December 2004, 18:48 | #3 |
Registered User
Join Date: Sep 2002
Location: Germany
Posts: 349
|
Well, I assumed that but when I try to setup an interrupt then it is called immediately after I enabled it.
So maybe you or anybody have an example or any tips how to set up and code the interrupt routine correctly ? Thanks. |
10 December 2004, 10:26 | #4 |
Mostly Harmless
Join Date: Aug 2004
Location: Northern Ireland
Posts: 1,115
|
I've got some asm examples in the form of a simple sound effects engine for a game. I'll try to extract the source over the weekend - its on a backup CD somewhere in the computer graveyard that is our back room
|
10 December 2004, 13:13 | #5 |
Registered User
Join Date: Sep 2002
Location: Germany
Posts: 349
|
That would be very nice... I experimented a little bit but still have problems...
|
11 December 2004, 01:46 | #6 |
Moderator
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,613
|
Have you looked at one of the playroutines for a tracker, like Noisetracker?
What you usually do is to wait at least 4 raster lines, then set the audio pointers and loops to whatever you want. It will then take effect when the sound reaches the end. This means that you can start a sound with any loop length (AUDxLEN) you want. When the sound is to stop, you set the sound pointer to a word that is 0 (to avoid clicks) and set the AUDxLEN (loop) to 1. If you start sounds at a specific point in time, like waiting for VBLANK, it's easier to use some sort of timing to wait at least 4 raster lines instead of using the audio interrupt, like the copper (which I use). I just poke the correct values into the copper list and the copper moves them into the sound registers when the time comes. The protracker playroutine uses a cheap timer interrupt wait loop to do it: STARTSOUND: MOVE.W n_dmabit(A6),$DFF096 ;Audio DMA off MOVE.L n_start(A6),(A5) ;Set sampledata pointer MOVE.W n_length(A6),4(A5) ;Set length MOVE.W n_period(A6),6(A5) MOVEQ #0,D0 MOVE.B n_volume(A6),D0 move.b pt_timeout,$bfe701 ;TimerB HI move.b pt_timeout+1,$bfe601 ;TimerB LO move.b #%000011001,$bfef01 ;set commandbits: OneShot & CLK & Start WAIT1: pt_timerwait3 btst #0,$bfef01 ;timeout on timerB? (ICR TimerB) bne.s pt_timerwait3 ;nope... STARTIT: MOVE.W n_dmabit(A6),D0 BSET #15,D0 MOVE.W D0,$DFF096 WAIT2: move.b pt_timeout,$bfe701 ;TimerB HI move.b pt_timeout+1,$bfe601 ;TimerB LO move.b #%000011001,$bfef01 ;set commandbits: OneShot & CLK & Start pt_timerwait4 btst #0,$bfef01 ;timeout on timerB? (ICR TimerB) bne.s pt_timerwait4 ;nope... STOPIT: MOVE.L n_loopstart(A6),(A5) ;SET TO POINT TO A 0 WORD MOVE.L n_replen(A6),4(A5) ;SET TO 1 pt_rtnend Hope this helps. |
11 December 2004, 10:44 | #7 |
Registered User
Join Date: Sep 2002
Location: Germany
Posts: 349
|
Yes, I had a look at a lot of tracker playback routines and I was very surprised that it is such "complicated" to do an easy sample playback. Anyway my program works now and your example is very helpful, thanks.
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
XBox 1 video playback | Peter | Retrogaming General Discussion | 19 | 18 January 2011 16:33 |
Wrong playback of a ripped module | Another World | New to Emulation or Amiga scene | 6 | 17 December 2008 17:55 |
Amiga (WinUAE) video playback? | Lernatix | Amiga scene | 2 | 18 November 2007 16:17 |
Playback problem from recording | RickyC | support.Other | 0 | 31 May 2007 13:38 |
DivX Playback | Echo | support.Hardware | 10 | 24 January 2003 18:45 |
|
|