Skip to content

Visualisers

elpoep edited this page Feb 15, 2025 · 5 revisions

Visualisers are the best feature elpAudio has. Visualisers can be written very very simple.

VARIABLES

  • __visual_freq - visualiser bars, used in default visualisers
  • __speed - text speed, used for floating text thing
  • view_wport/global.pwidth - elpAudio player width
  • view_hport/global.pheight - elpAudio player height
  • __visualiser - chosen visualiser number (starts with 0, so 6th visualiser will be 5th)
  • room_speed - maximum FPS of the player (can be modified but wait for lags)
  • fps - frames per second

It is mandatory to put InitVisVars(x,y,width,height) into your visualiser file. What is this function? Here is an answer:

InitVisVars(x of visualiser draw, y of visualiser draw, width of visualiser draw, height of visualiser draw) VisReset() is a function that returns true if user has clicked the "Reset visualisers" button when RMB on settings button. Can be usefull if you have added sprites, sounds, surfaces, etc.

visualiser draw is where drawable objects will be drawn. Example:

InitVisVars(x,y,width,height) //initialize visualiser
if !MinVisVars(144,64) exit //will not execute code if visualiser's width and height are less than arguments.
if !variable_local_exists('myinit') myinit=0;
if myinit=0 {
myinit=1;
coins=0;
hp=1;
}
if VisReset() {
coins=0
hp=1
myinit=0
}

DO NOT set your variables as these names:

health;
score;
other;
self;
sprite;
lives;
x; // Use those variables if 
y; // you need to move some buttons

They are GameMaker preserved functions, and these:

xx;
yy;
w;
h;

They can break elpAudio visualiser if they will be reassigned! Better use '_' symbol before variable names. Example:

InitVisVars(x,y,width,height)
if !MinVisVars(144,64) exit
if !variable_local_exists('__test') __test=0
if test=0 {
__test=1
player_x=0
player_y=0
}

Every variable initialiser can end with ; to prevent future errors, but it is not a mandatory.

CODING

The code from 11th to 17th line is a simple INIT functions for your script. With that, you can do your own game and load images, sounds, etc.

You can do even your own Omega Flowey bossfight from Undertale if you know GML so good. Or, if not, more easy-to-do functions come in future!

/// code below will add sprite
myspr=sprite_add("visualisers\mygame\player.png",8,0,1,16,16);
/*
sprite_add - 
argument 0 - filename - sprite's filename. Note that working directory is elpAudio's directory, not visualisers directory.
argument 1 - frames - how many frames does this sprite has (only horizontal :( )
argument 2 - smooth - smooth image (using billinear interpolation)
argument 3 - removebg - elpAudio will remove color that contains in (1;1) pixel (top-left pixel)
argument 4/5 - sprite's origin x/y
*/

///draw sprite
draw_sprite(myspr,(current_time*0.08) mod 8,xx+15,yy+10)
/*
draw_sprite - 
argument 0 - sprite - sprite variable
argument 1 - index - image index
argument 2/3 - coordinates where to draw this sprite
*/

TODO

SOUND PLAYER

To manipulate sounds there are so many built-in sound_* functions. Those functions are easy-to-use, but it only supports WAV and MP3s. Simple code for playing song with built-in functions:

if !variable_local_exists('myinit') myinit=0
if myinit=0 {
myinit=1; mysnd=sound_add("hooray.wav",1);
sound_play(mysnd);
}
if VisReset() {sound_delete(mysnd)}

The code above adds a sound "hooray.wav" with preload and then plays it once. But, instead of built-in functions, elpAudio has a FMOD support. And even a mega simple function for playing music is here. Simple code for playing song with FMOD functions:

if !variable_local_exists('myinit') myinit=0
if myinit=0 {
myinit=1; 
eaPlay(4);
}

eaPlay stops a current song and plays new song from position of a current playlist. So, if 4th song is, for example, "D:\Music\PULSE - Let The Hustlers Play.wav", and eaPlay(4) was called then elpAudio will play "D:\Music\PULSE - Let The Hustlers Play.wav".

Clone this wiki locally