GMS 2 iOS vs Android audio processing, headphones mode vs speaker


In the mobile phone game I'm working on, I've built a music-making sequencer of sorts. The way it works is that separate audio tracks (3 instruments with notes and 2 'drummers') are being played simultaneously, playing different notes at different moments, playing different songs this way.
The sound quality is great when I export to Windows, but exporting to Android is a disaster - individual notes disappear, it seems almost as it the Android os is adding its own 'filtering' on the overall sound and cuts off some of its ingredients sometimes - is that possible?
None of that happens on iOS, the sound is great, but... only with headphones. There's this 'click' sound at the beginning of each note when playing through the phone speaker. To be more specific, what actually happens is that when I start the app with sound via speaker - there's this distortion, then when I plug in the headphones, the distortion continues. BUT if I start the app with headphones plugged in, the sound sounds correct, AND THEN when I pull out the headphones it still sounds correct through the speaker.
So it almost seems like the sound is processed differently by the OS whether you're in headphones mode or speaker mode - is that possible?
In all these scenarios the CPU usage is fine.
Due to poor sound quality on Android I have pretty much given up making an Android version of the app, and focusing on iPhones - so finding out about the difference between sound processing by iOS when using headphones vs phone speaker is the most important.
Send help!


Friendly Tyrant
Forum Staff
Tbh, I would file bug reports for both the iOS and Android issues... Not sure anything can be done on Android due to the market fragmentation and different device specs, etc... but on iOS I would say you shouldn't be having these issues and if it works correctly on Windows/Mac then it should be okay on iOS too. One thing I would say is that you should ensure your imported sounds are OGG originally and not MP3. MP3 has the odd property of adding in extra milliseconds to sounds and when converted to OGG (which is what GMS does) this can give issues, which on different platforms could be a cause of some of things that you're getting. Also, test different playback types from the IDE, specifically I'd use the "Uncompress on load, not streamed" option to start with then test the others and see if anything changes.


Thanks for your reply!
I will do some testing according to your suggestions and report back.
I've been using WAVs with Uncompressed - Not Streamed. The logic being that I would get better sound quality with WAV as opposed to OGG?

Someone suggested that both Windows and iPhones in 'headphones mode' apply an overall limiter to their audio output and that's why it sounds good there, but iPhone in 'built-in speaker mode' does not and audio is distorting because it is too loud. I think that very possibly my mix is too loud, but I'm not sure how to control it well - I wish the GM2 sound mixer had a peak meter wink wink YoyoGames. ;)
But the distortion is not a continuous crackling sound - there is a 'pop' sound at the start of each 'jump'. So this suggests to me that it is not loudness distortion, but popping which occurs when there is a sudden change in voltage of the sound wave - when you 'jump' to a new place in the sound file. And I made tests where I turned each sound waaaay down individually, and turned down master gain - the 'pop' sound is always there, just proportionally less loud.

So another possible lead, related to the sudden jump in voltage of the sound wave, is that there's something wrong with my cross-fading mechanism. I'm experimenting with it right now. So far inconclusive. It doesn't really make sense to me for it to sometimes work and sometimes not, but I see a theoretical problem with how I implemented it, so maybe when it works it is just by some fluke - it is definitely something I've encountered before in game dev lol.
The way this cross-fading mechanism works is that each instrument/track is doubled and one of the doubled tracks is always muted. At the moment of jumping to a new note, the jump is made in the muted track whose volume is right away brought up and the first track's volume is brought down to mute. It works perfectly, somehow, lol - early version of this sequencer had a pop sound at each jump - this mechanism removed 100% of these pops on Windows and Android and iPhone via headphones.
But when I was implementing it I thought there would also need to be a 'grace period' of silence to 'hide' the clipping, before fading up - as opposed to starting the fade-up right at the jump moment. Made some tests last night playing with various parameters/lengths of the silence/fading, but haven't really seen a difference so far.