On Saturday 25 February 2012, at 15.40.59, Adam Puckett <adotsdothmu...@gmail.com> wrote: > Would it be possible to design a callback that dynamically filled the > buffer as it was being called, or if the buffer didn't exist, create > it and put one sample in it? that way there wouldn't be any "dropped > calls" in the process. Or am I missing something?
Well, no matter how you go about implementing it, what it comes down to is that every sample MUST be in place when the sound card needs it. There's just no way around that. :-) There is one "trick" along those lines, though, often used in video games: Use a shared memory DMA buffer of "substantial" size (half a second or so), and split the mixing code into two parts; 1) one that mixes playing sounds/streams in somewhere down the buffer, for minimal risk of drop-outs, and 2) one that mixes in the initial parts of newly started sounds from pretty the current DMA position (that is, near zero latency), and down to where the other mixer part will take over. However, this won't really eliminate the drop-out problem. All it does is reduce the damage caused by scheduling latency peaks. Instead of the whole stream (soundscape, music, playing effects - everything) glitching or having a dubstep moment, the first few moments of newly started sounds will be lost, while the "old" streams keep playing as usual. I'd say this method is just a complicated band-aid with lots of issues, and not even suitable for musical applications - but if all else fails... -- //David Olofson - Consultant, Developer, Artist, Open Source Advocate .--- Games, examples, libraries, scripting, sound, music, graphics ---. | http://consulting.olofson.net http://olofsonarcade.com | '---------------------------------------------------------------------' -- dupswapdrop -- the music-dsp mailing list and website: subscription info, FAQ, source code archive, list archive, book reviews, dsp links http://music.columbia.edu/cmc/music-dsp http://music.columbia.edu/mailman/listinfo/music-dsp