Jump to content

Photo

Very simple sound engine (With example)


5 replies to this topic

#1 Gemintronic OFFLINE  

Gemintronic

    Jason S. - Lead Developer & CEO

  • 8,780 posts

Posted Tue Dec 20, 2016 1:54 PM

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

Attached Files



#2 Th0rn OFFLINE  

Th0rn

    Space Invader

  • 10 posts
  • Location:Cleveland, Ohio

Posted Thu Dec 22, 2016 12:52 PM

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....her2zk_I&t=330s

 

 

Attached Files



#3 Random Terrain OFFLINE  

Random Terrain

    Visual batari Basic User

  • 27,801 posts
  • Controlled Randomness
    Replay Value
    Nonlinear
  • Location:North Carolina (USA)

Posted Fri Dec 23, 2016 4:53 PM

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....her2zk_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



#4 Th0rn OFFLINE  

Th0rn

    Space Invader

  • 10 posts
  • Location:Cleveland, Ohio

Posted Sat Dec 24, 2016 12:05 PM

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.



#5 Random Terrain OFFLINE  

Random Terrain

    Visual batari Basic User

  • 27,801 posts
  • Controlled Randomness
    Replay Value
    Nonlinear
  • Location:North Carolina (USA)

Posted Sat Dec 24, 2016 2:12 PM

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



#6 Th0rn OFFLINE  

Th0rn

    Space Invader

  • 10 posts
  • Location:Cleveland, Ohio

Posted Sat Dec 24, 2016 2:59 PM

I was using build 554, now thanks to your advice, I am using build 568.  I can view it and compile it now.






0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users