Funzioni audio di base

Ci sono cinque funzioni collegate ai file audio: per eseguirlo, controllare se è in esecuzione, fermarlo.

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.

Oltre ai file midi e wave (e mp3) c’è un quarto tipo che può essere suonato: direct music.
Hanno l’estensione .sgt.
Questi file spesso fanno riferimento ad altri file per informazioni aggiuntive.
Per trovare questi file il sistema deve sapere dove sono salvati.
A questo punto puoi usare le funzioni seguenti per impostare la cartella di ricerca per i file.
Osserva che sei tu che devi aggiungere i file, non lo fa Game Maker automaticamente.

sound_set_search_directory() dir Imposta la cartella in cui si trovano i file direct music.
La stringa dir non deve contenere il backslash finale.

Lascia un commento