kcat / alure

Alure is a utility library for OpenAL, providing a C++ API and managing common tasks that include file loading, caching, and streaming
zlib License
70 stars 20 forks source link

Capture and real-time support #26

Closed LAGonauta closed 6 years ago

LAGonauta commented 6 years ago

Hello,

I am planing on implementing voice communication for a game, but currently Alure does not support capturing voice and playing realtime audio (such as voice received from the internet).

I guess could workaround the second problem by creating a custom decoder that is activated when a specific string is passed to it and the Read method would get the data from a custom voice mixer, but that is far from ideal and the first problem makes this moot anyway.

Is there any plan to add this feature to the library? Thanks.

kcat commented 6 years ago

Eventually capture support will probably be added. For the time being, though, you can use OpenAL's capture API, which is guaranteed to be there since OpenAL is already there.

Using a custom decoder would be the correct way to play a stream from an external source, be it a network connection or a recording device. Just be aware that an external source may generate samples at a subtly different rate than it's played back at, even if they're both set to the same sample rate (no two pieces of hardware have perfectly synchronized clocks). It can become a complicated issue to deal with if you want to avoid potential clicks and pops in playback.

LAGonauta commented 6 years ago

I never thought to use OpenAL API directly for that until you raised the possibility now, good idea. Thanks. The capture API is very simple, so should be easy.

I will use the custom decoder for voice playback, then. Luckily the voice playback channel is never constantly open (30s to 60s, tops), so with buffers big enough there should never be an underrun that causes a pop. The "file" will never have an end, but I guess I can just report it having UINT64_MAX as length and return 0 samples as read when it is done.

LAGonauta commented 6 years ago

Just implemented everything and it is working :+1: Therefore I am closing this issue. Thanks.

hhyyrylainen commented 5 years ago

Hi, I'm also interested in recording support. Could this issue be reopened?

ethindp commented 4 years ago

I'm looking at the alrecord.c example to figure out how the AL capture API works (is that the right example for OpenAL soft?). Would the context that Alure uses allow me to use AL capture without needing to open a new context? (I edited this comment because I'd missed some details in the source code file -- no context is acquired/opened.)

kcat commented 4 years ago

I'm looking at the alrecord.c example to figure out how the AL capture API works (is that the right example for OpenAL soft?).

Yes.

Would the context that Alure uses allow me to use AL capture without needing to open a new context?

Capture doesn't use a context, just a device you open with alcCaptureOpenDevice. The capture functions will take that device handle directly, which won't interfere with Alure using a different device and context.

ethindp commented 4 years ago

Thanks! :)

On 3/8/20, kcat notifications@github.com wrote:

I'm looking at the alrecord.c example to figure out how the AL capture API works (is that the right example for OpenAL soft?).

Yes.

Would the context that Alure uses allow me to use AL capture without needing to open a new context?

Capture doesn't use a context, just a device you open with alcCaptureOpenDevice. The capture functions will take that device handle directly, which won't interfere with Alure using a different device and context.

-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/kcat/alure/issues/26#issuecomment-596257850

-- Signed, Ethin D. Probst