Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
libsox binding for Ruby
C Ruby
branch: master

Merge pull request #1 from tism/master

Add DBL2NUM definition for 1.8.7
latest commit 1c6ca6b7af
@afhbl authored
Failed to load latest commit information.
ext Add 1.8.7 compatibility
spec signal->encoding->compression now may be accessed
README.md
input.mp3 signal->encoding->compression now may be accessed
input.wav signal->encoding->compression now may be accessed
rsox.gemspec version bump

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

Something went wrong with that request. Please try again.