Skip to content
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

Callbacks slow down the applications #3

Open
wilsonsilva opened this issue Oct 23, 2023 · 0 comments
Open

Callbacks slow down the applications #3

wilsonsilva opened this issue Oct 23, 2023 · 0 comments
Labels
help wanted Extra attention is needed

Comments

@wilsonsilva
Copy link
Owner

Here's an example:

ProcessAudio = FFI::Function.new(:void, [:pointer, :uint]) do |buffer, frames|
# samples = buffer.to_a
# average = 0.0 # Temporary average volume
#
# frames.times do |frame|
# left = samples[frame * 2]
# right = samples[frame * 2 + 1]
#
# left = (left.abs ** $exponent) * (left < 0.0 ? -1.0 : 1.0)
# right = (right.abs ** $exponent) * (right < 0.0 ? -1.0 : 1.0)
#
# average += (left.abs / frames) + (right.abs / frames)
# end
#
# # Moving history to the left
# $average_volume.shift(399)
# $average_volume << average # Adding last average value
end
# Initialization
# --------------------------------------------------------------------------------------
SCREEN_WIDTH = 800
SCREEN_HEIGHT = 450
Raylib.init_window(SCREEN_WIDTH, SCREEN_HEIGHT, "raylib [audio] example - processing mixed output")
Raylib.init_audio_device # Initialize audio device
# Raylib.attach_audio_mixed_processor(ProcessAudio) # FIXME: Uncomment when callbacks are supported

@wilsonsilva wilsonsilva added the help wanted Extra attention is needed label Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant