English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 18 July 2006, 05:23   #1
cdoty
RasterSoft Dev
 
cdoty's Avatar
 
Join Date: Feb 2005
Location: Manteno IL
Posts: 58
Send a message via ICQ to cdoty Send a message via AIM to cdoty
Sampled sound player?

I haven't implemented anything, I want to hear some feedback first...

I'm now looking to add a simple 4 channel sampled sound player to my game. The sound would be started by a routine to play a sound. The sound would be stopped in the VBlank routine.

Is a VBlank routine fast enough to control sound playback? I want to be able to stop the sound before it loops.

I could add some silence to the end of the sound, and set the end point before the silence. This would allow a little bit of timing error of the VBlank.

Is this the way it's *normally* done, or is there a better way?
cdoty is offline  
Old 18 July 2006, 17:18   #2
jrom
Wannabe asm coder ;)
 
jrom's Avatar
 
Join Date: May 2002
Location: The Netherlands
Age: 47
Posts: 459
dunno if its any help at all... but you might want to check out this thread.
jrom is offline  
Old 24 July 2006, 07:07   #3
snyp
'Difficult'.
 
snyp's Avatar
 
Join Date: May 2006
Location: No fixed abode
Age: 46
Posts: 105
"Mapping the Amiga" by Rhett Anderson and Randy Thompson.

$DFF0A4 AUD0LEN Channel 0 Waveform Length
Status: *W Paula
The length of your data in words is stored here. So, your data must be
an even number of bytes, and may not exceed 131,070 bytes. (i.e. 65536
times two.)
However, it is possible to play waveforms longer than 131,070 bytes due
to the fact that the Amiga buffers the contents of the AUDxLC and AUDxLEN
registers by using backup registers. So, you may change the AUDxLC and
AUDxLEN registers while the Amiga is playing a sound, and when it is
finished, it will start with the new data! Any of the Amiga's audio
channels can cause a level 4 interrupt just before your sound starts a new
waveform cycle. When this interrupt occurs, you know it's safe to change
the registers. One warning however: Interrupts caused by high-frequency
waveforms can occur quite rapidly. Even more rapidly than the operating
system can keep up! It's best to leave the audio interrupts alone, unless
you actually need them. Just wait a little while before changing the AUDxLC
and AUDxLEN registers and all will work fine.

-

basically, once you know your waveform's playing, just load 0 into the channel's length register and it shouldn't loop
snyp is offline  
Old 24 July 2006, 11:22   #4
bobbybearing
Zone Friend
 
bobbybearing's Avatar
 
Join Date: Oct 2003
Location: France
Age: 51
Posts: 161
check http://ada.untergrund.net coding forum : there is an article about PAULA by philippe rivaillon
you can also find it here
bobbybearing is offline  
Old 24 July 2006, 19:30   #5
cdoty
RasterSoft Dev
 
cdoty's Avatar
 
Join Date: Feb 2005
Location: Manteno IL
Posts: 58
Send a message via ICQ to cdoty Send a message via AIM to cdoty
Quote:
Originally Posted by snyp
"Mapping the Amiga" by Rhett Anderson and Randy Thompson.

$DFF0A4 AUD0LEN Channel 0 Waveform Length
Status: *W Paula
The length of your data in words is stored here. So, your data must be
an even number of bytes, and may not exceed 131,070 bytes. (i.e. 65536
times two.)
However, it is possible to play waveforms longer than 131,070 bytes due
to the fact that the Amiga buffers the contents of the AUDxLC and AUDxLEN
registers by using backup registers. So, you may change the AUDxLC and
AUDxLEN registers while the Amiga is playing a sound, and when it is
finished, it will start with the new data! Any of the Amiga's audio
channels can cause a level 4 interrupt just before your sound starts a new
waveform cycle. When this interrupt occurs, you know it's safe to change
the registers. One warning however: Interrupts caused by high-frequency
waveforms can occur quite rapidly. Even more rapidly than the operating
system can keep up! It's best to leave the audio interrupts alone, unless
you actually need them. Just wait a little while before changing the AUDxLC
and AUDxLEN registers and all will work fine.

-

basically, once you know your waveform's playing, just load 0 into the channel's length register and it shouldn't loop
Yeah, I was reading Mapping the Amiga. I wasn't sure the length register was 'cached'.

That should be easy enough. Thanks.
cdoty is offline  
Old 23 August 2007, 06:17   #6
cdoty
RasterSoft Dev
 
cdoty's Avatar
 
Join Date: Feb 2005
Location: Manteno IL
Posts: 58
Send a message via ICQ to cdoty Send a message via AIM to cdoty
Sorry to dig up an old thread.

I implemented this method, and learned a lot from the source in this thread:
http://eab.abime.net/showthread.php?t=23347

Is 8 screen lines a reasonable amount of time to wait before changing the pointer and length?

Last edited by cdoty; 23 August 2007 at 06:31.
cdoty is offline  
Old 23 August 2007, 18:34   #7
Kalms
Registered User
 
Join Date: Nov 2006
Location: Stockholm, Sweden
Posts: 237
Quote:
Originally Posted by cdoty View Post
Sorry to dig up an old thread.

I implemented this method, and learned a lot from the source in this thread:
http://eab.abime.net/showthread.php?t=23347

Is 8 screen lines a reasonable amount of time to wait before changing the pointer and length?
(all figures are assuming PAL)

8 screen lines will be enough, if the previous sound was playing at 3906Hz or a higher frequency.

For a slower sound, you need to wait longer. In the pathologically worst case, you would need to wait 65536 buscycles, which means waiting 289 screen lines. Some details in:
http://ada.untergrund.net/forum/inde...&page=0#msg476

and in: http://ada.untergrund.net/forum/inde...um=1&topic=267

You will get around the "how long do I wait?" problem by letting the end-of-audio interrupt clear the sample settings.
Kalms is offline  
Old 25 August 2007, 16:21   #8
blade002
Zone Friend
 
blade002's Avatar
 
Join Date: Dec 2005
Location: Australia
Age: 50
Posts: 2,616
Quote:
Originally Posted by Kalms View Post
(all figures are assuming PAL)

8 screen lines will be enough, if the previous sound was playing at 3906Hz or a higher frequency.

For a slower sound, you need to wait longer. In the pathologically worst case, you would need to wait 65536 buscycles, which means waiting 289 screen lines. Some details in:
http://ada.untergrund.net/forum/inde...&page=0#msg476

and in: http://ada.untergrund.net/forum/inde...um=1&topic=267

You will get around the "how long do I wait?" problem by letting the end-of-audio interrupt clear the sample settings.
If this is the Kalms from TBL, then its an honour

( Couldnt resist it )
blade002 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
Protracker player with support for external sound fx phx Coders. Releases 172 15 January 2024 19:44
Sampled loop in cracktro absence request.Music 2 30 June 2012 11:33
MOD-player with external sound effects phx Coders. Asm / Hardware 14 18 June 2012 10:41
Sampled Sounds Solid Snake Retrogaming General Discussion 2 08 January 2007 17:34
Player Manager speed/sound problem Guest support.Games 3 10 April 2002 23:46

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 23:49.

Top

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