Difference between revisions of "Article Tutorials/Intro to sounds"

From GiderosMobile
(Created page with "Now that we can display images and text on the screen, you’ll be wanting to make noise!<br> First, we’ll start with just sound effects.<br> Download all audio for this t...")
 
Line 5: Line 5:
 
Download all audio for this tutorial from: Gideros Mobile Tutorial Audio file (2.4Mb)<br>
 
Download all audio for this tutorial from: Gideros Mobile Tutorial Audio file (2.4Mb)<br>
  
The easiest and cheapest way to get cool sound effects for your application is to use the funky BFXR which you can download from here:<br>
+
<s>The easiest and cheapest way to get cool sound effects for your application is to use the funky BFXR which you can download from here:<br>
 
 
http://www.bfxr.net/ ('''Note''': This site is offline but you can get its software for Windows here and for Mac in this link: )<br><br>
 
 
 
 
 
  
 +
http://www.bfxr.net/</s> ('''Note''': This site is offline but you can get its software for Windows and for Mac [https://github.com/plicatibu/gideros_external_tutorials/tree/master/bluebilby.com_2013-04-18_gideros-mobile-tutorial-playing-music-and-sound-effects here].)<br><br>
  
 
This is a free-to-use and download application which lets you create sound effects and export the wav files of your effects for using in your application.<br>
 
This is a free-to-use and download application which lets you create sound effects and export the wav files of your effects for using in your application.<br>

Revision as of 00:03, 4 December 2019

Now that we can display images and text on the screen, you’ll be wanting to make noise!

First, we’ll start with just sound effects.

Download all audio for this tutorial from: Gideros Mobile Tutorial Audio file (2.4Mb)

The easiest and cheapest way to get cool sound effects for your application is to use the funky BFXR which you can download from here:

http://www.bfxr.net/ (Note: This site is offline but you can get its software for Windows and for Mac here.)

This is a free-to-use and download application which lets you create sound effects and export the wav files of your effects for using in your application.

If you download the standalone version, you will need to install Adobe Air, but it’s worth it.

Jason-Oakley-Playing-Music-And-Sound-Effects-bfxr.png


Click on the buttons until you find an effect you like and use Export Wav to save it into your Gideros Studio Project folder.

Create a new Project and add a new main.lua file to it. Use Add Existing Files to add your wav sound (eg laser.wav).

Type this into the main.lua file:

local laserfx = Sound.new("laser.wav")
laserfx:play()


This creates an object called “laserfx” and loads the laser.wav file into it. The next line plays your sound effect. Pretty simple, huh?

Every game needs a funky tune in the background, so lets add in a tune. There’s plenty of free mp3s on the internet, so go grab your own and add it to the Project.

I grabbed a free tune from No Soap Radio (www.nosoapradio.us). They have a lot of game tunes, all totally free – even for commercial use!

local gametune = Sound.new("DST-AngryMod.mp3")
gametune:play()


Now, if you launch your application you will hear the sound playing. Awesome!
The ‘play’ parameter has two options:

• StartPosition
• Loops

You can start your tune partway through the song by specifying the StartPosition option. You can tell the tune how many times to loop (play over again) by specifying the Loops option.

Eg.

local gametune = Sound.new("DST-AngryMod.mp3")
gametune:play(100,5)


If you want to play the song repeating forever, use this:

gametune:play(0, true)


Set the volume of your tune or sound effect:

sndChannel:setVolume(0.5)


“0.5” is at half volume. You can set your volume anywhere from 0 to 1.

Stop your tune from playing:

Soundchannel=gametune:play(0,true)
Soundchannel:stop()


To unload and free up memory when you’re finished with your tune, use:

gametune = nil




Note: This tutorial was written by Jason Oakley and was originally available here: http://bluebilby.com/2013/04/18/gideros-mobile-tutorial-playing-music-and-sound-effects/.