Audio sounds weird
julian smit

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:

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!

Trent Gamblin

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

julian smit

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.

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


So you have tried: song = al_load_audio_stream(sfx, 2, 1024 * 4);
exactly like Trent suggested?
Do other programs stream audio normally?

julian smit

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


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

julian smit

non-streaming sounds are working fine.


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

julian smit

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

Thread #607974. Printed from