libsox binding for Ruby
C Ruby
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
ext
spec
README.md
input.mp3
input.wav
rsox.gemspec

README.md

RSox is a libSoX binding for Ruby


Install

gem install rsox

Usage

rewritten example0.c from sox

require 'rsox'

sox = RSox.new

input = sox.open_read 'file.mp3'
output = sox.open_write 'file.wav', input.signal

chain = sox.chain input, output
chain.add 'input', input
chain.add 'vol', '3dB'
chain.add 'flanger'
chain.add 'output', output

chain.flow

processing samples in Ruby

require 'rsox'

sox = RSox.new

input = sox.open_read 'file.mp3'
output = sox.open_write 'file.wav', input.signal

chain = sox.chain input, output
chain.add 'input', input
chain.add 'vol', '3dB'
chain.add 'flanger'
chain.add 'block' do |buffer|
  # samples in buffer
  buffer.size # or buffer.length

  # access samples
  buffer[0]             # or buffer.at(0)
  buffer[buffer.size-1] # last sample

  # each sample is a 32bit signed integer converted to Fixnum
  buffer[0].class == Fixnum
end

# all output data will be passed to `block` effect
# and processed by Ruby code block
chain.flow

Thanks

Roman Golomidov for idea and support