Page 1 of 1

Easy sound & music setup tutorial

PostPosted: Sun Feb 21, 2010 5:48 pm
by Hblade
Easy sound & music setup
    The easiest way to play music & sound effects

First, we begin by opening up Global Code
Screen1.JPG
    Thumbnail, click to enlarge

The following assumes you have the Sound Pack

Place all of the files included in the sound pack into your Data folder
Screen2.JPG
    Thumbnail, click to enlarge

Now that you've did that, place the following code in your Global Code
Code: Select all
#define PlaySE(Cursor) PlaySound2("data/Cursor.wav", 1.000000, 1, 0.000000);
#define PlaySE(Choice) PlaySound2("data/Choice.wav", 1.000000, 1, 0.000000);
#define PlaySE(Cancel) PlaySound2("data/Cancel.wav", 1.000000, 1, 0.000000);
#define PlaySE(Buzzer) PlaySound2("data/Buzzer.wav", 1.000000, 1, 0.000000);

#define PlayBGM(Forest) PlayMusic2("data/Deep in the forest.ogg", 1.000000, 0, HIGH_PRIORITY_MUSIC);
#define PlayBGM(HighUp) PlayMusic2("data/High up on the machine.ogg", 1.000000, 0, HIGH_PRIORITY_MUSIC);
#define PlayBGM(City) PlayMusic2("data/City.ogg", 1.000000, 0, HIGH_PRIORITY_MUSIC);
#define PlayBGM(BossArival) PlayMusic2("data/A powerfull enemy is coming.ogg", 1.000000, 0, HIGH_PRIORITY_MUSIC);
#define PlayBGM(CalmingWind) PlayMusic2("data/The calming wind.ogg", 1.000000, 0, HIGH_PRIORITY_MUSIC);
#define PlayBGM(Shop) PlayMusic2("data/Island Shop.ogg", 1.000000, 0, HIGH_PRIORITY_MUSIC);

#define PlaySE(Alarm) PlaySound2("data/Alarm.wav", 1.000000, 19, 0.000000);


The PlaySE(Alarm) function is set to 19, which means it'll repeat the alarm sound 19 times. You can change the repeat time to set what you like. In order to play this forever then stop it when an action is called, replace the 19 with a variable called ALARM_REPEAT, then when you want it to stop, simply make ALARM_REPEAT equal 1.

How to use these functions
In order to use these functions, simply open a code, (rather it be Create Actor, or an event that calls the music / sound to be played) and type in PlaySE(Cursor) or what ever sound effect / music you want to play.

Example: Say you entered a new area, you want it to play the new sound effect, right? When you enter the new area, and you want it to play a new sound, what ever method you used to get to that new area (Rather by teleport or by loading a map file), also include a PlayBGM function, for example, you walk into a dark area, so you want to play something that's kinda darkish. Type PlayBGM(Forest) and the music will start playing simply.

For multiple sound effects, without having to take the extra 8 seconds to click here and there, simply type PlaySE(Cursor) or PlaySE(Choice) or any other sound that you might want to be played.

Hope this helped :D

Easier on the eyes
In case the code looks a bit confusing to new people, the functions that you can call with the code is these:
    PlaySE(Cursor)
    PlaySE(Conferm)
    PlaySE(Cancel)
    PlaySE(Buzzer)
    PlayBGM(Forest)
    PlayBGM(HighUp)
    PlayBGM(City)
    PlayBGM(BossArival)
    PlayBGM(CalmingWind)
    PlayBGM(Shop)
    PlaySE)Alarm)

Re: Easy sound & music setup tutorial

PostPosted: Sun Feb 21, 2010 6:35 pm
by Bee-Ant
Good so far,
but still, there's a simpler way...
Here is a function for PlaySE :
Code: Select all
void PlaySE(char Name[32],int loop)
{
char DataName[64];
sprintf(DataName,"data/%s.wav",Name);
PlaySound2(DataName,1,loop,0);
}


Usage :
PlaySE(Cursor,1);
//it will play Cursor sound with 1 loop

Same goes with the PlayBGM, just change the PlaySound2 to PlayMusic2 :D

Re: Easy sound & music setup tutorial

PostPosted: Sun Feb 21, 2010 6:40 pm
by Hblade
yeah I know, but this requires less code :3

Re: Easy sound & music setup tutorial

PostPosted: Sun Feb 21, 2010 6:45 pm
by Bee-Ant
Hblade wrote:yeah I know, but this requires less code :3

Didnt i post a very reduced code??

Re: Easy sound & music setup tutorial

PostPosted: Sun Feb 21, 2010 6:54 pm
by Hblade
Sorry yeah I got confused, I meant to say yours requires less code, but mine looks fancier >.>

Jk, both are nice, right?