Version 2022.11: Audio Effects, More Array And String Functions


Version 2022.11: Audio Effects, More Array And String Functions

Add audio effects to your game with GameMaker 2022.11. Unlock the true potential of arrays and strings with new functions.

New Array Functions

There are some new handy array functions for you. I’ll highlight my favourites here:

  1. array_create_ext(): Create a new array with a function for each element
  2. array_find_index(): Find the index of a qualifying value in the array
    1. You use a “predicate” function to find a qualifying value. A predicate is your own function which runs for each array element. When your predicate returns true on an element, that element “qualifies” and array_find_index() returns the index of that element.
  3. array_filter(): Create a new array with only elements that qualify, using a predicate function
  4. array_foreach(): Run a function on every array element, alternative to a custom for loop
  5. …and many more, such as array_reduce(), array_map(), etc. which can be discovered in the manual

These new functions will let you read and manipulate arrays in new and easier ways. You can iterate through an entire array, or just a part of it, either forwards or backwards.

Some array functions also have _ext() alternatives, which modify the source array instead of returning a modified copy. These have less performance overhead, resulting in faster processing when you have a large number of arrays to modify.

New String Functions

These new strings functions make reading and modifying them easier.

The string() function has been upgraded. It now lets you create a “template string” with placeholders, and insert values into those placeholders:

var _fav_numbers = string(“My three favourite numbers are: {0}, {1} and {2}!”, 4, 10, 36);

This will result in the string: “My three favourite numbers are: 4, 10 and 36!”. There is also string_ext() which takes an array with your values, instead of separate arguments.

show_debug_message() was also updated to support template strings, just like the string() function.

There are some new string functions I really like:

  1. string_split(): Split a string into separate, smaller strings, and get an array of those strings
  2. string_join(): Opposite of the previous function – pass an array of strings, and get those strings joined into one big string
  3. string_foreach(): Run a function on every character in an array, allows you to iterate through it

Read all about these string functions in the manual.

Runtime Selection

When you’re installing GameMaker for the first time, or updating your runtime, you’ll now see a window asking you which runtimes you want to install:

undefined

This saves your disk space by letting you only install runtimes you are using.

You can change your installed runtimes by going into Preferences -> Runtime Feeds -> Modify Current Runtime Modules. If you don’t have a runtime installed, you’ll be given the option to install it when you select it in the Targets window.

Audio Effects

The crème de la crème of this release: audio effects!

You can apply the following effects to any sounds playing in your game:

  1. Reverb
  2. Delay
  3. Bitcrusher
  4. High-pass filter
  5. Low-pass filter
  6. Gain

More effects will be added in future versions.

You can easily apply an effect to all the sounds in your game, by applying it to the main bus:

// Create effect and modify properties
var _ef_reverb = audio_effect_create(AudioEffectType.Reverb1);
_ef_reverb.size = 0.6;
_ef_reverb.mix = 0.5;

// Apply to the main bus
audio_bus_main.effects[0] = _ef_reverb;

To apply effects to only particular sounds:

  1. Create a new audio emitter
  2. Create a new audio bus
  3. Apply your emitter to your bus
  4. And then apply effects to that bus

Every sound played through your emitter will go through your new bus, which has the effect applied to it. Your own buses in the end go to the main audio bus, so any effects applied on main will be audible on other buses too.

// Create and connect emitter and bus
var _my_emitter = audio_emitter_create();
var _my_bus = audio_bus_create();
audio_emitter_bus(_my_emitter, _my_bus);

// Create and apply effect
var _delay = audio_effect_create(AudioEffectType.Delay);
_delay.mix = 0.5;
_my_bus.effects[0] = _delay;

// Play ambience sound
audio_play_sound_on(_my_emitter, snd_ambience, true, 1);

The route for the jump sound played in the code above looks like this:

undefined

If you need to play a sound through an emitter/bus combo multiple times throughout your game, create the emitter and bus once (e.g. in a Create event) and destroy/free them when no longer needed (e.g. Clean Up event).

More Additions

  • You can now write binary literals starting with 0b, and write underscores (_) in number literals which are only visual (e.g. 12_34.3_21, which is the same as 1234.321)
  • You can now choose whether pasting (CTRL+V) in the Image Editor creates a new brush or a new layer
  • Pinch to zoom is now supported on laptop trackpads
  • There’s a new preference that fixes issues with filename case sensitivity on Mac and Linux

Download GameMaker 2022.11 and start creating now.

Happy GameMaking!


Written by Gurpreet S. Matharoo

Lead Technical Writer at GameMaker, Gurpreet creates documentation and tutorials to make game making easier for you. He loves using the computer to bring new things to life, whether it's games, digital art, or Metal music.