Skip to content
/ rsox Public
forked from faridco/rsox

libsox binding for Ruby

Notifications You must be signed in to change notification settings

tism/rsox

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

libsox binding for Ruby

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 74.5%
  • Ruby 25.5%