GLBasic forum

Main forum => GLBasic - en => Topic started by: spicypixel on 2013-Nov-19

Title: Android Music & SFX GLB 11 & 12
Post by: spicypixel on 2013-Nov-19
I am getting very confused that the only version of GLB that works at all for Android regarding sound is Version 10 (and there's latency on the sfx there too). GLB v11 and v12 both fail BIGTIME in playing WAV or OGG files. I have created an APK using GLB 10 that works fine albeit the latency which I believe is a java android issue anyway, although I have a Sony Xperia SP on 4.1.2 so I would have though that would have been fixed by now so is this latency a GLB issue instead?

Working fine on GLB 10
Music: OGG 44100Hz, 96Kbs (low but fine), Mono, 16Bit
SFX: WAV 44100Hz, Mono, 16Bit

Unless I'm creating a Charlie Chaplin game I might be struggling with v11 & v12, unless anyone can tell me different lol :D
Title: Re: Android Music & SFX GLB 11 & 12
Post by: erico on 2013-Nov-19
Here v10 and 11 works similar, I haven´t tried v12 yet.
Sound stutter a bit when repeated, some kind of samples/duration seem to not stutter that much.
Title: Re: Android Music & SFX GLB 11 & 12
Post by: spacefractal on 2013-Nov-19
Engine is the same. If you are concern about it. There is a alternative API in androidextras.

I'm uses 22kz my self. No reason do uses more than that.
Title: Re: Android Music & SFX GLB 11 & 12
Post by: MrTAToad on 2013-Nov-19
I haven't tried V12 yet on Android, but I dont see music being a problem...
Title: Re: Android Music & SFX GLB 11 & 12
Post by: MrPlow on 2013-Nov-19
my ogg file works fine on my Android app on GLBv12...I also used full paths for the sounds...

LOADSOUND "Media/clockclick2.ogg",1,1
Title: Re: Android Music & SFX GLB 11 & 12
Post by: spicypixel on 2013-Nov-19
So if I use...

LOADSOUND GETCURRENTDIR$ + "Media/sfx/filename.wav", sfx%, 2
PLAYMUSIC GETCURRENTDIR$ + "Media/music/filename.ogg", sfx%, 2

This works fine for both v11 & v12?

If this is the case there really should be a sticky at least until this path bug is fixed surely. I have searched for Android sound on the forum and have had a number of conflicting discussions on this topic. Thanks for the replies I will indeed try the paths to see if it fixes the issue.
Title: Re: Android Music & SFX GLB 11 & 12
Post by: MrTAToad on 2013-Nov-19
You shouldn't need to use GETCURRENTDIR$() - Doing LOADSOUND "Media/xx" should be enough
Title: Re: Android Music & SFX GLB 11 & 12
Post by: SnooPI on 2013-Nov-19
Quote from: spacefractal on 2013-Nov-19
Engine is the same. If you are concern about it. There is a alternative API in androidextras.

I'm uses 22kz my self. No reason do uses more than that.

yes, work fine for me (with glb 11 and 12)

22kz is is the right frequency for android (until glb use the very good 3d audio library : opensles   ;) gernot)

spicypixel you should use audacity to convert your sound and music.
audacity.sourceforge.net (http://audacity.sourceforge.net)
Title: Re: Android Music & SFX GLB 11 & 12
Post by: spicypixel on 2013-Nov-19
Already use Audacity cheers

In GLB12 I get no audio whatsoever in my APK. I'm using this for loading sounds & playing music.

sfx_paws%   = GENSOUND()
LOADSOUND "Media/sfx/paws.wav"  , sfx_paws%, 2

PLAYMUSIC "Media/music/puzzle.ogg", TRUE

Top of my code I have a SETCURRENTDIR("Media") command anyway but apparently this makes no difference. I get no audio in 12.
Title: Re: Android Music & SFX GLB 11 & 12
Post by: spicypixel on 2013-Nov-19
Here is a stripped version of my game with only the sound bits, could someone test this and see what results they get please.
Title: Re: Android Music & SFX GLB 11 & 12
Post by: erico on 2013-Nov-19
It dosen´t work here on v10 neither with my own working ogg files. (don´t bother this, my win dosen´t play oggs anyway)
Your ogg seems to be fine, looks like path problems.

back on the music stuttering, I might not have expressed myself correctly, I meant all sounds play perfectly but sounds you want to repeat (machine gun shots for ex)...those don´t quite kick in in loop and sometimes are completely skipped.

Let me look at the code example again...

edit:will do an apk to check this better
Title: Re: Android Music & SFX GLB 11 & 12
Post by: erico on 2013-Nov-19
The paths you did there did not work for me, so just in case I changed things to:

Code (glbasic) Select
SETCURRENTDIR("Media")
SETSCREEN 640, 480, 0

GLOBAL sfx_paws%, sfx_bark%, sfx_bone%, sfx_button%, sfx_touch%

sfx_paws%   = GENSOUND() ; LOADSOUND "Media/sfx/paws.wav"  , sfx_paws%, 2
sfx_bark%   = GENSOUND() ; LOADSOUND "Media/sfx/bark.wav"  , sfx_bark%, 1
sfx_bone%   = GENSOUND() ; LOADSOUND "Media/sfx/bone.wav"  , sfx_bone%, 1
sfx_button% = GENSOUND() ; LOADSOUND "Media/sfx/button.wav", sfx_button%, 1
sfx_touch%  = GENSOUND() ; LOADSOUND "Media/sfx/touch.wav" , sfx_touch%, 2

PLAYMUSIC "puzzle.ogg", TRUE


SHOWSCREEN
MOUSEWAIT
END


That way plays fine here, but the music plays garbled full of ticks. That dosen´t happen with my ogg game music and neither playing your music on a desktop player.

If it is the ticks that are bothering you, it may be related to the synth instruments in song?
I didn´t try v12 as I haven´t installed yet.

I hope this info helps you somehow, I should get v12 these days and I may test it better there.
Title: Re: Android Music & SFX GLB 11 & 12
Post by: erico on 2013-Nov-19
Wait, the code I posted didn´t work on v11.

I will get v12 going and let you know, I must check that sound routine is working on my game too.
I still suspect it relates to path.
Title: Re: Android Music & SFX GLB 11 & 12
Post by: spicypixel on 2013-Nov-19
Quote from: erico on 2013-Nov-19
The paths you did there did not work for me, so just in case I changed things to:

Code (glbasic) Select
SETCURRENTDIR("Media")
SETSCREEN 640, 480, 0

GLOBAL sfx_paws%, sfx_bark%, sfx_bone%, sfx_button%, sfx_touch%

sfx_paws%   = GENSOUND() ; LOADSOUND "Media/sfx/paws.wav"  , sfx_paws%, 2
sfx_bark%   = GENSOUND() ; LOADSOUND "Media/sfx/bark.wav"  , sfx_bark%, 1
sfx_bone%   = GENSOUND() ; LOADSOUND "Media/sfx/bone.wav"  , sfx_bone%, 1
sfx_button% = GENSOUND() ; LOADSOUND "Media/sfx/button.wav", sfx_button%, 1
sfx_touch%  = GENSOUND() ; LOADSOUND "Media/sfx/touch.wav" , sfx_touch%, 2

PLAYMUSIC "puzzle.ogg", TRUE


SHOWSCREEN
MOUSEWAIT
END


That way plays fine here, but the music plays garbled full of ticks. That dosen´t happen with my ogg game music and neither playing your music on a desktop player.

If it is the ticks that are bothering you, it may be related to the synth instruments in song?
I didn´t try v12 as I haven´t installed yet.

I hope this info helps you somehow, I should get v12 these days and I may test it better there.

Did you try and play the sound files? I know I didn't include them in the test only the playmusic command. Im presuming you're testing with 11? Thanks for the feedback erico.
Title: Re: Android Music & SFX GLB 11 & 12
Post by: erico on 2013-Nov-19
I tried only the music file puzzle.ogg

Works on desktop with VLC fine. Its own analyses points to a correct file format.
It works on android here from v10...but here, it plays with lots of clicks and hisses.

V11 didn´t find the the file I suspect, so it didn´t play at all.
I´m installing v12 here now will let you know more and also test my stuff.
Title: Re: Android Music & SFX GLB 11 & 12
Post by: erico on 2013-Nov-19
Got v12 running, at first it didn´t want to compile android, after deleting things here and there and restarting it works and compile.
But that puts me on your position, no sound working at all on android.

I will try the path things now...
Title: Re: Android Music & SFX GLB 11 & 12
Post by: spicypixel on 2013-Nov-19
Here is the same puzzle.ogg at 44100Hz, 16bit, Mono and this does play correctly (no clicks) in v10, so you have two oggs to play with now. See if we can get these audio issues tied down once and for all regarding file rates, glb versions and such :) Thanks again for your continued testing.
Title: Re: Android Music & SFX GLB 11 & 12
Post by: SnooPI on 2013-Nov-19
spicypixel try this :

- clean your project
- put all sounds and music in a shoebox
- use SETSHOEBOX function before loadsound an playmusic

Title: Re: Android Music & SFX GLB 11 & 12
Post by: erico on 2013-Nov-19
Got it working on v12.
Thanks to FiveSprite´s post on glb12 thread. :-[

I took out the setcurrentdir command and added like"Media/" to all loading commands. So it looks like this for example:
PLAYMUSIC "Media/daXX - Paranoimia - daXX Remix.ogg", FALSE

So all sounds, wav and ogg, are playing perfectly on android here.
But this is on my code.

Will try that on your code and file now Spicy.

edit: tested with your files, things play on android but the sound is noisy...feels like a bad sound convertion...will look the later file too
Title: Re: Android Music & SFX GLB 11 & 12
Post by: erico on 2013-Nov-19
Your last ogg file plays fine on android under your test example.
Here the apk, check it out.

So it is probably a sound conversion problem.

Will take a closer look into the ogg waves and format now. I know some simple sound conversion can destroy a tune and that some synth instruments really require pro equipment to play otherwise it craps all up on the speakers.

ps: both sound waves look ok (if a bit low on volume) all is fine on this front. Playing your file on android winamp reproduces it correctly, so I guess GLB does not like 22050hz? Will re-check this... Forum limit file size is 8mb, can´t upload the zipped apk.
Title: Re: Android Music & SFX GLB 11 & 12
Post by: erico on 2013-Nov-19
Ok, it is not a conversion problem, I resampled it here to 22050 with the higher quality file (even setting high quality ogg when saving) and I get the same result, music full of clicks. Again, playing same files on a music player on android plays fine.

Using your full quality music in app also did play fine.
So maybe 22050 is not android GLB´s taste?

Tried the 44100 version but reduced ogg quality on save to 0...file is smaller but I get the same problem.
Plays fine on player, stutters under a GLB app.
Title: Re: Android Music & SFX GLB 11 & 12
Post by: erico on 2013-Nov-19
We could test a range of varieties of ogg files to check which are going good.

But now I wonder, this has absolutely nothing to do with android APIs right?
I have below zero knowledge on android APIs, before we test it, does anyone know if this could play a role?
Title: Re: Android Music & SFX GLB 11 & 12
Post by: spicypixel on 2013-Nov-20
I was out last night but have just read through your comments and testings. It does seem that the fault is inherent with GLB if the same file plays flawlessly under a music player on Android. I like the tune so will keep it, although it does look like I will have to keep the 44100Hz version to play correctly. Strange but true....

I will also remove the SETCURRENTDIR command and reference the graphics and sound via the "Media/xxx" method if this indeed is the only way to solve things. I would still like some other feedback though on what are the correct settings for playback with GLB. Or if there is some limitation on the audio engine that we are not aware of.
Title: Re: Android Music & SFX GLB 11 & 12
Post by: spacefractal on 2013-Nov-21
uses full path for android and uses 22khz momo. this is what im do and that seen fine. you cant hear different from 44kz and 22kz anyway on Android at all and is fully suitable for games.
Title: Re: Android Music & SFX GLB 11 & 12
Post by: erico on 2013-Nov-21
That is going fine for me in WAV, but in OGG it is glitchy on 22khz.
Title: Re: Android Music & SFX GLB 11 & 12
Post by: fuzzy70 on 2013-Nov-21
Quote from: spacefractal on 2013-Nov-21
you cant hear different from 44kz and 22kz anyway on Android at all and is fully suitable for games.

In some ways true. If playing through 99% of phones/tablets tiny little single speaker then yes. Put your headphones/earbuds on & the difference is quite noticeable dropping to 22khz. The same goes for mono through headphones in that the most music runs the risk of becoming flat/dull when converted down to mono unless it was composed/written with that in mind.

I have to admit I might be slightly biased with regards to this as I am an Audio/Visual technician by trade so my hearing notices such differences as it's a requirement for my work  =D

Lee 
Title: Re: Android Music & SFX GLB 11 & 12
Post by: erico on 2013-Nov-21
Fit me in that description too.

I´m keeping my music (OGG) in stereo 44 for the exact reasons you stated, even though size is going to be big.
But OGG is quite an adaptable format, using 44 with lower codec quality could do the trick and be passable, problem is GLB is not playing OGGs correclty on android if not in high quality.

I have a sound card capable of 24bits 115khz and a sound system able to mostly reproduce it on desktop, so even changing to the onboard sound system couses me shwricks. :D

It would be nice to know how much we can push OGG on android with GLB, since if a game has 10 songs it could easily mean 20-30mb of music data alone. Is anyone compiling to android, probably a higher API, and using a lower quality OGG with success?
Title: Re: Android Music & SFX GLB 11 & 12
Post by: spicypixel on 2013-Nov-21
There's definitely an issue when using 22KHz compared to 44KHz on GLB (I'm sure not with all tunes??) in OGG format. The puzzle.ogg I uploaded represents such an issue as erico has stated. The tune is pretty much unrecognisable when using 22KHz with the attached files I have put up. This is not a conversion issue and can only be a playback issue (certain frequencies?).
Title: Re: Android Music & SFX GLB 11 & 12
Post by: erico on 2013-Nov-21
Some extra info.
Here the oficial codec support from android:
http://developer.android.com/guide/appendix/media-formats.html

As you can see, OGG+vorbis is natively supported on that platform.
There isen´t much extra information/reserves about specs of the music file so I take it plays all variations.

Digging around the interwebs, I found a post about OGG that raised my question about possible relationship with API:
QuoteAndroid 2.3 and up uses OpenSL ES API, which has great support for MP3. All previous versions and bugs and difficulties with audio here and there. I would still go with MP3 for earlier API versions. Ogg would be a pain to implement. In fact, before Android 2.3 API (version 9, I believe), there were lots of complaints about developing any kind of audio applications for Android.

CORRECTION Android does have .ogg compatibility starting with API version 8.

I´m not sure this has any role into the problem. My GLBv12 states it is using ANDROID API-8 when compiling.
Title: Re: Android Music & SFX GLB 11 & 12
Post by: spacefractal on 2013-Nov-21
Im would uses adpcm sound if that was possible. Most target people would not notice it, not on android, and is a kind trade off and also to safe file size and memory.

For jungool, we used 22 kHz adpcm mono for sound and stereo 96kbit mp4 for music. For greedy mouse it's 22khz PCM mono for sound and 44khz 128kbit ogg stereo for music.

On android you even need to dither your graphics to rgb565 to avoid color banding, but was not required that in greedy mouse.

So it's bits of trade offs here and there.

There is a alternative sound/music API in androidextras to tryout as well.