Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Audio sounds weird

This thread is locked; no one can reply to it. rss feed Print
Audio sounds weird
julian smit
Member #13,064
July 2011

Hey everyone, I'm working on some easy games and came to the point i wanted to add music to the game, i made 2 functions, one for sound effects using (.wav)
and one for songs, the problem is when i loaded songs in al_load_sample, it used way to much memory so i searched for another way and found al_load_audio_stream, which works but it sounds horrible, now i think this has to do with the loading part since i'm not sure if i did that right, and i'm looking for some advice to load it and make it sound better.

Here's the code i'm using now:

#SelectExpand
1song = al_load_audio_stream(sfx, 1, 1024 * 2); 2al_set_audio_stream_playmode(song, ALLEGRO_PLAYMODE_ONCE); 3al_attach_audio_stream_to_mixer(song, al_get_default_mixer());

Thanks for the support so far!
Julian.

Trent Gamblin
Member #261
April 2000
avatar

Define sounds horrible. Is it breaking up because I would recommend at least two 4k buffers.

julian smit
Member #13,064
July 2011

yeah, with "sounds weird" i mean a bit breaking up, i tried to make it sound better but this was the best i could get it. now my question would be how many buffers and how many samples should i need to load the song.

#SelectExpand
1song = al_load_audio_stream(sfx, buffers, samples);

weapon_S
Member #7,859
October 2006
avatar

julian smit
Member #13,064
July 2011

yes, i've tried that and it sounds actually exactly the same, for other programs, i've never tested that.

Elias
Member #358
May 2000

Does non-streaming sounds also break? (In which case the disk buffer used in streaming wouldn't be the cause.)

--
"Either help out or stop whining" - Evert

julian smit
Member #13,064
July 2011

non-streaming sounds are working fine.

Elias
Member #358
May 2000

Does it also sound broken when you play the audio file with ex_stream_file?

--
"Either help out or stop whining" - Evert

julian smit
Member #13,064
July 2011

It's fixed now, i forgot the event, stupid of me. but thanks for the support ;).

Go to: