-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/mixer #4687
Feature/mixer #4687
Conversation
Thanks a lot @leiradel for delivering this to us on time. We owe you big time. |
The diff I used is over at https://hastebin.com/buhogaqahi.cpp .... Getting the following error:
|
Tried loading a 33MB Ogg file using that example code snippet. Unfortunately it slows everything down to a crawl and it seems to not play back the audio anyway. Does it need to be all copied into RAM before it plays any music? Is it performed on a task/thread? |
Alright, I understand that by doing this I am kinda overloading the sound system since this is spawned for every audio_driver_flush call so a 33mb Ogg file would indeed result in this kind of crawling performance loss. I guess we can dispatch these audio load calls from anywhere in the code instead of them being spammed from here right? @RobLoach tells me that this sound file works for him - http://www.kozco.com/tech/piano2.wav however this one crashes for him - |
Worked with the following audio files: The following wav file crashed it: |
Here is the stack trace of nav.wav - [Thread debugging using libthread_db enabled] |
Mixing the two audio streams together with the core's audio works very well, congratulations on that! Guess it's just a matter of ironing out some of the rough edges. |
Are you calling one of the I'm not loading files using tasks, and I don't think the audio mixer should bother with tasks. That is missing are functions that take memory buffers instead of file paths, so the caller can load the audio data however it wants (i.e. loading synchronously, using tasks, by embedding the data into the executable) and just pass it to the audio mixer. I'll take a look at it today or tomorrow (I'll travel with the family next Saturday and we have to make preparations.) |
Hm, I believe you're calling the load function every frame. Load audio data only once, the only function that must be called every frame is |
It looks like a regular WAV file, I'll have to take a look:
|
OK, the audio mixer should indeed not bother with tasks. I was talking more about creating a 'task' inside 'tasks' for creating a sound effect. But we can take a look at that instead now that we know how it works. |
I believe we should not add a specific task for that. It's just a matter of loading the file data asynchronously, which the tasks already do, so all that is missing is an audio mixer API that takes memory buffers instead of file paths. Also, I believe we should stream OGG data from the file system using a RFILE instead of having everything in memory. |
You might be right. Try to figure out why the crash happens with that wav file that was posted, and I will start thinking of ways to integrate this into RA. |
|
Added an audio mixer.
To test, add this to audio_driver.c, inside function
audio_driver_flush
(around line 615). You should have both the WAV and the OGG repeating while still hearing the core audio.Regular operation needs only the line
audio_mixer_mix(audio_driver_output_samples_buf, output_frames);
inaudio_driver_flush
.