Hi I am a developer of video games and apps for Android and windows, hopefully soon for mac as well, I've been making video games for fun for about 14 years, and in February 2015 decided to get serious and started Roadhammer Gaming, a company aimed at producing video games and software for a fair amount of platforms. Future plans are to open a unique 3d immersed gaming facility, set up kind of like laser tag or paintball crossed with startrek's Holodeck to be open for business based on a set fee for a set amount of game play time. I am currently the owner and sole employee of my company. In my spare time I like hiking, motorsports, the beach, horror movies, sci fi movies and rpg style video games.

Report RSS GM Android Audio Modder extension for game devs!

Posted by on

GM Android Audio Modder can be used in GMS 1.4+, GMS 2x .
Project minimum SDK is 14 or higher, recomended target sdk & build tools is 26. This extension is also compatible with Android OS 6 and up's permissions rules and regulations.

Screenshot 20171201 112955

Screenshot 20171201 113101

splash3

Features:
- Find music on Android device
- Move music files to public folder
- Set any music file to ringtone
- Make your own public game folders
- Get file extension type for audio files found
- Get the path address to audio files found
- Move music files and any file type recognized by GMS'S from the Included files folder of your game to a public folder
- Alert the Android operating system that a new file is available
- Record audio and save as .wav, .raw, .mp3 or set to ringtone
- Set any audio found or recorded as Android Device's default ringtone

Testing is easy, All the test code is in a script called tester. The 2 buttons to the right of the stereo are used to cycle through all the
things you can test in the new part of the extension. The important object to test this demo game is object ctrlr in the Android music
folder in the resource tree of the project. You can find the test controlls in the left pressed and left released events, and all the related
working/modifiable code is in the script called tester.if recording only or transfering files from your game's included files you don't have
to press Y to bring up the music player. (to test functions 5 and 7 you still must bring up the music player with the Y button to load the
music from the user's device of course) When the app opens simply tap the 8ball, name your folder and press ok. When the game
starts press Y to start the player and test the functions by pressing the up/down arrose to the right of the stereo. Depending on the test,
tap or hold the stereo to perform the test.
The testable functions: ** see below for TEST PROJECT TECHNICAL INFO on the test aspect of this project
Test # 0 = record as wav and save to new folder, hold down on stereo while recording, release to stop recording.
Test # 1 = record as raw and save to new folder, hold down on stereo while recording, release to stop recording.
Test # 2 = record as wave and set as ringtone and save to ringtone folder, hold down on stereo while recording, release to stop recording.
Test # 3 = record as mp3 and save to new folder, hold down on stereo while recording, release to stop recording.
Test # 4 = Copy audio from device to new folder - music player must be open
Test # 5 = Copy audio from device and set as ringtone - music player must be open
Test # 6 = Copy audio from game to new folder
Test # 7 = get file extension of tracks found on device, usefull to import music for game to play that has to be of the .ogg format for example -
music player must be open
Details:
Other important objects:
obj_main: draws all the info text.
controller: sets up the permissions and all global variables, names folder on gamestart.
obj_controller: make another/more folder(s).
The functions:
TrackAdress(int); Returns absolute path of selected track number
StartRec(string,int); Name the file, select recorder type, example: "name.ext", 0 = wav, raw or ringtone. 1 = mp3. (mp3 recorder is different from
wav/raw recorder)
StopRec(int); Save the file, 0 is for .wav, 1 is for .mp3, 2 is for set as ringtone and 3 is for .raw
GetFileExt(The trasck number); is to get the file extension of any file, so for example if you have .ogg music files on your android device you can
use this function with gms' audio_create_stream function to get and mod the music in-game.
SaveFromAs(string, string, string, int); This function has several uses, with it you can save music found on the device to a new folder, save files from
your games included files to a new folder, set music from the device or your game's included files as the default ringtone for the device, so the format
for using this function has 2 different setups and here are the examples:
if you are moving music found on the device to a new folder or setting one as a ringtone:
SaveFromAs(string, string, string, int); Input path, output path, file name, 0 or 1: 0 is move the audio file, 1 is move the file to the ringtones directory
and set as the default ringtone
If you are moving files from the included files of your game to new folder:
SaveFromAs(string, string, string, int); bytes data string,output path,file name,size in bytes
To use it you must create a buffer with the file stored in it and encode the data to string using the buffer_base64 gms function, full example:
fname = "starter.wav";//Other included files to try: "startup.ogg" "test50.txt" "Saveimg.png"
if(file_exists(fname)){
file = file_bin_open(fname,0);
size = file_bin_size(file);
gameTransfer = buffer_create(1024, buffer_grow, 1);
for(var i=0;i<size;i++;){
buffer_write(gameTransfer, buffer_u8, file_bin_read_byte(file));
}
file_bin_close(file);}
var dataString = buffer_base64_encode(gameTransfer, 0, buffer_get_size(gameTransfer));
SaveFromAs(dataString,global.myFolder,fname,size);
} else {
show_debug_message("file open failed");
}
Note that only files recognized by GMS can be used, for example you CANNOT use .mp3 files because gms's buffers do not recognize them
because .mp3 is coppywrite protected. Recognizable files include .wav, .raw, .ogg, .txt, .png and other image files
GetFldr(string); "Folder_Name/More_floder_names" This function is used to get the output path to a public folder, you supply the name, and to
make folders inside of folders just use the / character followed by the next folder's name
OsUpdt(string); Folder address/file_name.ext This function updates the android os of a new file so other apps on the device can find and use them.
exitTheApp(); This is a bug fix for GMS 1.4.1804 that allows you to close your app/game in code by simply calling this function.
FUNCTIONS FOR GM Android Music part of extension:
PauseMusic() - pauses the music if playing
MusicStopped() - use to check if music is stopped
NumberOfTracks() - use to find number of tracks
ResumeMusic() - plays music if paused
PlayMusic(Track_Number) - play a particular song
GetCurrentSongName() - gets the currently playing song name
GetCurrentArtistName() - gets the currently playing artist name
MusicPlaying() - use to check if music is playing
NextTrack() - play the next song
PreviousTrack() - play the previous song
GMASInit() - Call at game start, automatically requests permissions * see IMPORTANT note
GetSongName(Track_Number) - get the name of a particular song
GetArtistName(Track_Number) - get the name of a particular artist
MusicPaused() - use to check if the music is paused
StopMusic() - stop the music
GoToTrack(Track_Number) - go to a particular track, simillar to PlayMusic()
Final() - end all music and music player processes
GetSongLength(Track_Number) - gets the length in milliseconds of a requested song
GetCurrentSongLength(Track_Number) - gets the song length in milliseconds of the song currently playing
GoToSeek(Time_In_Milliseconds) - go to any position in the song by inputting the milliseconds
GetElapsedTime() - gets the time the song has been playing in milliseconds
* IMPORTANT!! If your app isn't going to allow user to change their ringtone, DO NOT ask for WRITE_SETTINGS permissions group,
Remove these permissions in the manufest: WRITE_SETTINGS, CHANGE_CONFIGURATION and MODIFY_AUDIO_SETTINGS
(double click extension and select android tab to view/change) The reason for this is as follows as per the new google play rules and
regulations stating that no app shall request permissions it doesn't use and/or need.
** TEST PROJECT TECHNICAL INFO:
//arguments, set testtype variable to trigger desired argument (0-6 only!) in create event of object ctrlr:
//0=record as wav
//1=record as raw
//2=record as wave and set as ringtone
//3= record as mp3
//4= Copy audio from device to new folder
//5= Copy audiofrom device and set as ringtone
//6= Copy audio from game to new folder
//7= get file extension of tracks found on device, usefull to import music for game to play that has to be of the .ogg format for example
//8-11 stop recording and process, triggered automatically in left released event of object ctrlr
//left mouse pressed
if argument0=0 StartRec("newWav.wav",0);
if argument0=1 StartRec("newRaw.raw",0);
if argument0=2 StartRec("newRing.wav",0);
if argument0=3 StartRec("NewMp3.mp3",1);
if argument0=4 SaveFromAs(TrackAdress(3),global.myFolder,"coppied",0);
if argument0=5 SaveFromAs(TrackAdress(3),global.myFolder,"newRingtone",1);
if(argument0=6)
{fname = "starter.wav";
if(file_exists(fname))
{file = file_bin_open(fname,0);
size = file_bin_size(file);
gameTransfer = buffer_create(1024, buffer_grow, 1);
for(var i=0;i<size;i+=1;){var byte=file_bin_read_byte(file);buffer_write(gameTransfer,buffer_u8,byte);}
var buffaddress = buffer_get_address(gameTransfer);
SaveFromAs(buffaddress,global.myFolder,"starter.wav",size);
file_bin_close(file);}
if !file_exists(fname) show_debug_message("file_open_bin has failed to open the file");
}
if(argument0 = 7)
{var ext="";
var k=0;
global.nOfOggs= -1;//reset variable
repeat(global.tracknum){
ext=GetFileExt(k);
if(ext= ".ogg" || ext= ".OGG") {
global.nOfOggs+=1;
global.audioadd[global.nOfOggs] = audio_create_stream(string(TrackAdress(k)));
}
k+=1;
}
if global.nOfOggs> -1 newplay=1;//catch in step event to play all found .ogg sounds in game as playlist
}
//Left mouse released
if argument0=8 StopRec(0);
if argument0=9 StopRec(1);
if argument0=10 StopRec(2);
if argument0=11 StopRec(3);

Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: