This looks like a very nice effort!

On Fri, Sep 4, 2015 at 1:58 PM, Andrew Kelley <superjo...@gmail.com> wrote:

> On Fri, Sep 4, 2015 at 10:43 AM Ian Esten <i...@ianesten.com> wrote:
>
>> And an observation: libsoundio has a read and a write callback. If I was
>> writing an audio program that produced output based on the input (such as a
>> reverb, for example), do I have any guarantee that a write callback will
>> only come after a read callback, and that for every write callback there is
>> a read callback?
>>
>
> I don't think that every sound driver guarantees this. I see that
> PortAudio supports this API but I think they have to do additional
> buffering to accomplish it in a cross platform manner.
>

I wrote a lot of the PortAudio code for OS X. I don't recall exactly (it
was a long time ago), but I'm pretty sure the only reason I had to use
multiple callbacks and "link" them into one PortAudio callback was to
support some very odd case, like input from one device and output to
another (even there, I think it was fine unless you did something weird,
like SR converting only one of them or something). I recall some discussion
about my having to do this that indicated that no one else had needed to do
it before.

I've worked with a few native APIs and PortAudio, and I don't think any API
natively has problems with a single callback for read and write as long as
you are using the same device. Different devices and, of course, all bets
are off. I could be mistaken -- it's been a while, and I haven't used them
all.


> If you're writing something that is reading from an input device and
> writing to an output device, I think your best bet is to use a ring buffer
> to store the input.
>

Personally, I think the single callback is extremely useful for real-time
processing -- no need for the extra latency caused by a ring buffer. With
two callbacks you could avoid the latency if both callbacks are on the same
thread and you know which is going to be called first.... but I suspect
that's not guaranteed either.


BTW, on this page you say that PA supports SR conversion:
https://github.com/andrewrk/libsoundio/wiki/libsoundio-vs-PortAudio

I am pretty sure PA won't do that. It does have pretty good support for
whatever SR conversion the native platform supports, but it won't do any
conversions itself.

bjorn


-- 
Bjorn Roche
@shimmeoapp
_______________________________________________
dupswapdrop: music-dsp mailing list
music-dsp@music.columbia.edu
https://lists.columbia.edu/mailman/listinfo/music-dsp

Reply via email to