raylib-go icon indicating copy to clipboard operation
raylib-go copied to clipboard

Missing function AttachAudioStreamProcessor and DetachAudioStreamProcessor.

Open Hultan opened this issue 1 year ago • 10 comments

I can't complete the examples/audio/stream_effects, the last example that is missing in the audio section at raylib.com, because the functions AttachAudioStreamProcessor and DetachAudioStreamProcessor are missing. If anyone could add them, I could (probably) finish off the examples/audio section.

Hultan avatar Oct 17 '24 16:10 Hultan

Right. They are missing in the CGO Version. They have to be added in raylib/raudio.go

JupiterRider avatar Oct 18 '24 14:10 JupiterRider

We also should review DetachAudioStreamProcessor and DetachAudioMixedProcessor in the purego version, which can't work, because it always detaches a new callback.

JupiterRider avatar Oct 18 '24 16:10 JupiterRider

@gen2brain @agrigoryan What do you think about using purego.NewCallback in the cgo version as well? With that, the code would be much cleaner, because we don't need wrapper functions anymore.

Otherwise the code will be much more muddled: https://github.com/gen2brain/raylib-go/commit/c2c8150de9c2eb880a9f04c9c0021b110279a76a

But purego would break Support for OpenBSD and 32-bit Platforms. So maybe it is not a good idea.

JupiterRider avatar Oct 18 '24 18:10 JupiterRider

@JupiterRider If possible that would be nice. I remember I had an issue though, there is a limit of callbacks one can have if you fire NewCallback every time, I had to do something like this https://github.com/gen2brain/webp/blob/main/webp_dynamic.go#L220 and https://github.com/gen2brain/webp/blob/main/webp_dynamic.go#L278.

Though, I don't like breaking support for 32-bit platforms. Luckily there are not many callbacks in raylib.

gen2brain avatar Oct 19 '24 04:10 gen2brain

@gen2brain Do you think SetAudioStreamCallback even works? (added by you in #279) I ask because you can only set one global callback and not one callback per AudioStream.

JupiterRider avatar Dec 15 '24 18:12 JupiterRider

@JupiterRider I don't think I ever tested it.

gen2brain avatar Dec 15 '24 18:12 gen2brain

How can I use AttachAudioStreamProcessor ?

Rockenstien avatar Dec 18 '24 19:12 Rockenstien

@Rockenstien for now manually (by writing your functions in C) or you use the purego version.

@gen2brain do you have any Ideas, how to solve this issue?

JupiterRider avatar Dec 20 '24 16:12 JupiterRider

@JupiterRider Sorry, I have no idea and currently have no time to work on that.

gen2brain avatar Dec 20 '24 18:12 gen2brain

@JupiterRider It is probably something like one C-exported Go function that would always be called; that function can call all Go-added functions to some map.

gen2brain avatar Dec 22 '24 08:12 gen2brain