Using Ruby to Generate SoX Commands

This may seem crazy, but I am hoping to use Ruby as the source of a
rather long chain of tools. I want to use Ruby to generate a shell
script to run a long (LONG) series of commands for SoX. SoX is a general
purpose command line audio manipulation tool with some awesome, powerful
features. The chain would be:

Ruby > shell script > SoX

Come to think of it… I might be able to dispense with the shell script
step, right? Ruby can sort of pop out and run a command in the shell and
then pop back in. Sorry for the technical terms… Ha!

SoX has all kinds of commands like:

$ sox -n output.wav synth 9600s sine 123.471 fade 48s 9600s 9552s

What this does is generate an audio sine wave (the note is a B) and run
it through a fade, which is a little envelope generator (a volume
control). If all you want to do is have something very simple like that,
then it’s easy enough to run off the command line. But of course, to
make music, one needs to generate hundreds, or even thousands or tens of
thousands of these commands and then mix them and move them and combine
them. SoX can do all of this, but it gets ridiculous.

I want to generate the SoX commands in Ruby. This is a thing that people
do, right? The shell simply doesn’t have the capability to handle all
the variables easily (and no interesting stuff like random numbers, and
so on). I think Ruby is appropriate for this.

On Mon, Jan 13, 2014 at 4:02 PM, Ron S. [email protected] wrote:

then pop back in. Sorry for the technical terms… Ha!
thousands of these commands and then mix them and move them and combine
them. SoX can do all of this, but it gets ridiculous.

I want to generate the SoX commands in Ruby. This is a thing that people
do, right? The shell simply doesn’t have the capability to handle all
the variables easily (and no interesting stuff like random numbers, and
so on). I think Ruby is appropriate for this.

I’m not sure what your question is, but yes, Ruby can be used to
generate and drive the execution of arbitrary commands, or to generate
intermediate shell scripts or everything in between. There might even
be a gem for using SoX from Ruby [… google, google, google…].
Here:

https://github.com/afhbl/rsox

If you have any specific question, let us know.

Jesus.

Thank you, Jesus. This is one of those situations where I don’t know
enough to know what questions I should be asking, so I was just trying
to describe what I am going for. You answered questions I didn’t know I
was asking!

Given the rate at which audio tools/formats change; I prefer to just use
the slower command-line tools than programming APIs which are more
likely to change (and easier for horrible programmers like myself to
misuse).

Thank you, Eric. Duct Tape is the perfect metaphor for audio in Linux. I think what happens is… Someone gets a very exciting project to 90% and then gets a job and drops it. And everyone has different ideas about what should be done with sound. Some people will assume when you are saying you are having trouble with sound that… you are trying to set up a surround sound multimedia computer and they will regale you with stories of their victories and they don’t care that you aren’t doing that…

“Ron S.” [email protected] wrote:

This may seem crazy, but I am hoping to use Ruby as the source of a
rather long chain of tools. I want to use Ruby to generate a shell
script to run a long (LONG) series of commands for SoX. SoX is a general
purpose command line audio manipulation tool with some awesome, powerful
features. The chain would be:

Ruby > shell script > SoX

My duct-tape audio suite does this: http://dtas.80x24.org/README
(it also uses ffmpeg/avconv/metaflac/mp3gain/ecasound/…)

Given the rate at which audio tools/formats change; I prefer to just use
the slower command-line tools than programming APIs which are more
likely to change (and easier for horrible programmers like myself to
misuse).

I used sox years ago for a part of one of my scripts which atomated the
creation of (mpg|avi)->DVD conversion. It’s ironic you mentioned it as sox
was one of the culprit which changed their syntax between upgrades.

Has anyone used snd to make synthesizers? I’m interested in hacking on
something like that nowdays.

~Stu