Description 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
Reactions are currently unavailable
You can’t perform that action at this time.
Here's an example:
raylib-ruby/examples/audio/audio_mixed_processor-broken.rb
Lines 33 to 60 in 8491d2d