Jump to content
IGNORED

Very simple sound engine (With example)


Gemintronic

Recommended Posts

I keep seeing questions about sound. I've tried posting this before but got no feedback. So, this is my attempt with a full working example :)

 

Basically, at the top of your main game loop you have a variable for a sound effect. If its value is greater than 0 the sound plays. The sound effect value gets decremented and gets its volume turned off at 0.

 

Using the same sound effect variable you can get different noises depending on the duration. So, that saves on using extra variables.

 rem /** Declare the 2 variables for sound.  Putting higher values in changes the duration and sound **/
 dim sounda = a
 dim soundb = b

main
 rem /** if a sound variable is greater than 0 play sound effect and decrease its value.  Kill sound if 0 **/
 if sounda > 0 then sounda = sounda - 1 : AUDC0 = 8 : AUDV0 = 4 : AUDF0 = sounda else AUDV0 = 0
 if soundb > 0 then soundb = soundb - 1 : AUDC1 = 2 : AUDV1 = 4 : AUDF1 = soundb else AUDV1 = 0

 rem /** if FIRE or up is pressed start playback of sound effects by putting a value in the sound variables **/
 if joy0fire then sounda = 50
 if joy0up then soundb = 50

 rem /** Start main program loop again **/
 goto main

simplesound.bas

  • Like 3
Link to comment
Share on other sites

Works great, thanks! I was playing around with the Tinkernut program where he shows how to make an Atari game on YouTube and added sound to it.

 

https://www.youtube.com/watch?v=Ww3her2zk_I&t=330s

 

The bB page has a Tinkernut version with sound effects:

 

randomterrain.com/atari-2600-memories-batari-basic-commands.html#ex_tinkernut_world_deluxe

 

 

The bB page also has other sound effect/music examples:

 

randomterrain.com/atari-2600-memories-batari-basic-commands.html#expro_sound

Link to comment
Share on other sites

Thanks for pointing that out. I can play the Tinkernut game in Stella, but I can't load the 53k .bas file in Visual Batari Basic. Visual Batari just says not responding.

 

Do you have the latest version of VbB:

 

atariage.com/forums/topic/123849-visual-bb-10-a-new-ide-for-batari-basic/page-28#entry3537039

Link to comment
Share on other sites

  • 9 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...