Skip to content

Instantly share code, notes, and snippets.

@lucaswilric
Created May 21, 2014 08:20
Show Gist options
  • Save lucaswilric/011e4e3b94ccf59b9368 to your computer and use it in GitHub Desktop.
Save lucaswilric/011e4e3b94ccf59b9368 to your computer and use it in GitHub Desktop.
Use SoX to amplify all WAV files in the current directory as much as possible without clipping
#!/usr/bin/env ruby
# PVC: Easy as shell pipes
# https://rubygems.org/gems/pvc
require 'pvc'
# SoX: Sound eXchange
# http://sox.sourceforge.net/
destination_dir = 'amplified'
Dir.mkdir destination_dir unless Dir.exists? destination_dir
Dir.glob('./*.wav').each do |f|
ratio_db = PVC.new("sox", f, "-n", "stat", "-v").run.stderr.chomp
PVC.new("sox", "-v", ratio_db, f, "amplified/#{f}").run
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment