Game Maker Sounds The following sound formats can be used in Game Maker:
Wave Files (.wav) Midi Files (.mid, .rmi, .midi) DirectMusic Files (.sgt)
Game Maker has built-in functions to play and stop sounds, to set sound volume, and panning and functions to add effects to a sound. List of Sounds
Normal sound: Sounds played normally. It can either be a Wave or a Midi file. Background music: Music intended to be played as background music. Can be a Midi file. 3D sound: Should be a Wave file. Multimedia Player Sound: Sounds/music that can be in any file format. In order for a player to be able to hear the sound, the player's computer must be able to support the file format.
Usage Sounds can be set under any of the four options above, provided that they're in the proper format to be used under the options. Sounds can have the following effects applied to them.
Chorus Flanger Gargle Echo Reverb
The volume and panning (that is, how physically to the left or right a sound is) can also be adjusted, and whether the song is preloaded can be set. If an external sound editor is supplied, it can be used to edit the sound. This is all done via Edit > Insert Sound, where this screen comes up:
Your sounds when imported are listed on the left in the sound files GameMaker uses what is called an event driven approach. Whenever something happens in the game the objects trigger events. For each object you must indicate to which events it responds and what actions it must perform when the event occurs. In the middle of the object property form there is a list of events to which the object must react. Initially it is empty. You can add events to it by pressing the button labeled Add Event. A form will appear with all different types of events. Here you select the event you want to add. See list of events later on in the document for more details.
Back Ground Music Create a new sound resource Load the file needed from where you have it saved 1. Open the Object Properties form (image above) 2. Create an object called background music without a sprite and Click Create event
3. Include a Play Sound action in the Create event.
4. In the action properties, select the music sound and set the Loop property to true. This makes the music loop back to the start when it finishes.
5. Click OK to close the action, and click OK again to close the object.
6. Add the background music to the base room
7. Insert the background music object to the room and click anywhere on the grid and a blue circle with a question mark will appear. This will stay invisable as there is no sprite and will serve to play your background music only.
Test it to see if it works.
Sound Effects Creating and playing sound effects: Create a new sound resource Load the file needed from where you have it saved 1. Open the Object Properties form 2. Select object you want the sound effect to be attached to and Click Create event to select it and view its actions. See the list of events for details on which one you want e.g. key press or collision. 3. Include a Play Sound action in the Create event. 4. Include a Play Sound action in the event and select the new sound. Leave the Loop property set to false so it doesn’t repeat like the background music. 6. Close the action form and Object properties form.
Test it to see if it works. Repeat on all the objects you want sound effects to work on.
If you have finished inserting your sounds, they work and have saved them ready to hand in, then you can have a go at experimenting with scripts. This is an extension task if you want to have a go at programming. Have a read through of the following information and try inserting scripts via scripts > import scripts There are five basic functions related to sounds, two to play a sound, one to check whether a sound is playing, and two to stop sounds. Most take the index of the sound as argument. The name of the sound represents its index. But you can also store the index in a variable, and use that.
sound_play(index) Plays the indicates sound once. If the sound is background music the current background music is stopped.
sound_loop(index) Plays the indicates sound, looping continuously. If the sound is background music the current background music is stopped.
sound_stop(index) Stops the indicates sound. If there are multiple sounds with this index playing simultaneously, all will be stopped.
sound_stop_all() Stops all sounds. sound_isplaying(index) Returns whether (a copy of) the indicated sound is playing. Note that this functions returns true when the sound actually plays through the speakers. After you call the function to play a sound it does not immediately reach the speakers so the function might still return false for a while. Similar, when the sound is stopped you still hear it for a while (e.g. because of echo) and the function will still return true. It is possible to use further sound effects. In particular you can change the volume and the pan, that is, whether the sound comes from the left or right speaker. In all these cases the volume can only be reduced. These functions do not work for files that play through the media player (like mp3 files).
sound_volume(index, value) Changes the volume for the indicated sound (0 = low, 1 = high).
sound_global_volume(value) Changes the global volume for all sounds (0 = low, 1 = high). sound_fade(index, value, time) Changes the volume for the indicated sound to the new value(0 = low, 1 = high) during the indicated time (in milliseconds). This can be used to fade out or fade in music.
sound_pan(index, value) Changes the pan for the indicated sound (-1 = left, 0 = center, 1 = right).
sound_background_tempo(factor) Changes the tempo of the background music (if it is a midi file). factor indicates the factor with which to multiply the tempo. So a value of 1 corresponds to the normal tempo. Larger values correspond to a faster tempo, smaller values to a slower tempo. Must lie between 0.01 and 100.