The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
SDL2_mixer & ogg vorbis file for android. Problems in IC
Giorgos Sarris
Guest

Hi again,

Can anyone help me out with this SDL_mixer issue in android?

I use the latest build of SDL HG and SDL2_mixer.
I made a library 'libSDL2_mixer.so' and a 'libtremor.a' with the SDL example in android.
I target 2.2 android.
I read the ogg vorbis file from the SD card.

When I play an OGG vorbis music file on my Nexus One phone (running 2.3 android) it works ok.

When I play the same file on my Samsung Galaxy II tablet (running ICS 4.0.3 android) it plays fine but when I exit the app (with java's 'finish()') and relead the game I hear the music distorted like echoing (Its like a helicopter sound!!). This does not happen all the time. Half times it does and half not.

Where is the problem?
Do you have any clue?

Both devices open up this:
09-25 12:05:36.862: V/SDL(1441): SDL audio: opening device
09-25 12:05:36.862: V/SDL(1441): SDL audio: wanted stereo 16-bit 44.1kHz, 1024 frames buffer
09-25 12:05:36.870: V/SDL(1441): SDL audio: got stereo 16-bit 44.1kHz, 4096 frames buffer

Thanks,
Giorgos
Distorted sound
image28


Joined: 23 Oct 2010
Posts: 49
Every time I load my app on my Samsung galaxy ace II I get the distorted helicopter sound instead of the .ogg music file it is meant to be playing. Will be trying to figure it out over next few days ( testing different sound files etc... )
Distorted sound
image28


Joined: 23 Oct 2010
Posts: 49
Also I'm loading the ogg file from the apk files assets directory
Code ...
image28


Joined: 23 Oct 2010
Posts: 49
SDL_InitSubSystem(SDL_INIT_AUDIO);


if(Mix_OpenAudio(22050, AUDIO_S16SYS , 2, 2048)) {
LOGD("Unable to open audio!");
exit(1);
}

Mix_Music *music;
music=Mix_LoadMUS("Initiate.ogg");
if ( music == NULL )
{
LOGD("No music file found");
}

if ( ! Mix_PlayingMusic() )
{
Mix_PlayMusic(music, -1);
}
SDL2_mixer & ogg vorbis file for android. Problems in IC
sdl
Guest

Check if your ogg files are encoded using 48000 Hz freq. if it the
case, encode them using standard 44100 Hz freq.

On Tue, 12 Mar 2013, image28 wrote:

Quote:
Every time I load my app on my Samsung galaxy ace II I get the distorted helicopter sound instead of the .ogg music file it is meant to be playing. Will be trying to figure it out over next few days ( testing different sound files etc... )






_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
SDL2_mixer & ogg vorbis file for android. Problems in IC
Gabriele Greco
Guest

On Tue, Mar 12, 2013 at 6:16 PM, image28 wrote:
Quote:
Also I'm loading the ogg file from the apk files assets directory



Are u using libtremor to decode the vorbis streams?


I'm doing the same thing in my game and it works perfectly (but I had to get an updated version of libtremor since there are a few bugged versions around that exhibit their bugs when used with SDL_mixer).



--
Bye, Gabry
SDL2_mixer & ogg vorbis file for android. Problems in IC
Sik


Joined: 26 Nov 2011
Posts: 905
Yeah, there's the issue that phones usually don't support hardware
accelerated Vorbis so they're horribly slow at that. You'll end up
with a scratchy sound because it can't keep up with the streaming (so
there are gaps in the buffer all the time).

If using Tremor doesn't fix it for you may want to consider other
alternatives. I suppose you're probably avoiding the hardware
accelerated formats as they're usually patented... An alternative
would be to decompress the entire Vorbis data in RAM, and if you need
to save space use DPCM, ADPCM or something like that (there's a Sega
Genesis sound engine called TMSE that can decompress two ADPCM streams
at 22KHz simultaneously on the 3.58MHz Z80, to give you an idea of how
lightweight are those two algorithms).

2013/3/13, Gabriele Greco:
Quote:
On Tue, Mar 12, 2013 at 6:16 PM, image28 wrote:

Quote:
**
Also I'm loading the ogg file from the apk files assets directory


Are u using libtremor to decode the vorbis streams?

I'm doing the same thing in my game and it works perfectly (but I had to
get an updated version of libtremor since there are a few bugged versions
around that exhibit their bugs when used with SDL_mixer).

--
Bye,
Gabry

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
wavs work
image28


Joined: 23 Oct 2010
Posts: 49
a standard wav file plays fine, but if I use audacity to compress it into a adpcm wave file SDL_mixer doesn't find the file.... did a search for the sega sound engine but couldn't find it....
SDL2_mixer & ogg vorbis file for android. Problems in IC
Sik


Joined: 26 Nov 2011
Posts: 905
ADPCM WAV files rarely are supported, I meant using your own format.
Audacity won't help you much there (other than saving it as raw and
then using some quick conversion tool), and storing the file directly
may not be a good idea anyway since it doesn't compress as well as
Vorbis.

First try Tremor, it's a much faster decoder for Vorbis files (as it
doesn't use floating point). Resort to other methods only if Tremor
doesn't work and you really need to save RAM. If you have spare RAM
you can also try decompressing the files in RAM and playing that
(mostly useful for sound effects).

2013/3/13, image28:
Quote:
a standard wav file plays fine, but if I use audacity to compress it into a
adpcm wave file SDL_mixer doesn't find the file.... did a search for the
sega sound engine but couldn't find it....





_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
tremor
image28


Joined: 23 Oct 2010
Posts: 49
SDL2_mixer is compiled with tremor.... and decompressing music to ram would take up to much ram, a lot of phones don't have all that much.