LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-24-2012, 09:51 AM   #1
wb0gaz
LQ Newbie
 
Registered: Mar 2011
Posts: 10

Rep: Reputation: 0
sox - simple command including '-r' produces different file result each time


I am using sox to convert sampling rate in a .WAV file, but the output file is not identical each time sox is run (on an identical input file.)

During debug of my project (which processes some files previosuly processed by sox), I have discovered that sox is producing a different file each time it is run, and this caused some fruitless debugging of the dependent project.

Although sequentially processing the same input file produces an output file that sounds the same to the ear, the sequentially processed output files are not the same bit-by-bit. My debug work depends on having consistent source test data (which I am using sox to generate).

Here is a shell script I am using to run a test to isolate the problem I am having with sox:

echo "sum input.wav:"
sum input.wav
echo "sox input.wav -r 8000 output.wav"
sox input.wav -r 8000 output.wav
echo "sum output.wav:"
sum output.wav

Here is the first run of the shell script:

sum input.wav:
01408 142
sox input.wav -r 8000 output.wav
sum output.wav:
16351 103

Here is the next run of the shell script:

sum input.wav:
01408 142
sox input.wav -r 8000 output.wav
sum output.wav:
52497 103

The input file is unchanged (based on sum)
The output file is not identical (based on sum)

Is there a default option in sox that introduces something random into it's process?
If not, is there some other reason sox does not produce an identical output each time it is run?
Can I get sox to produce an identical output each time it is run?

Thank you very much
 
Old 08-25-2012, 10:23 AM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,700

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
The output using-V option might provide a clue to what is going on.
Code:
 sox -V input.wav -r 8000 output.wav
 
Old 08-26-2012, 08:04 AM   #3
wb0gaz
LQ Newbie
 
Registered: Mar 2011
Posts: 10

Original Poster
Rep: Reputation: 0
Wink

Thanks - that got me pointed in the right direction. The dithering process was tripping me up, and the -R option (haven't tested yet, but should take care of it) will make it repeatable.

Learned something new with this...

"−R Run in ‘repeatable’ mode. When this option is given, where applicable, SoX will embed a fixed time-stamp in the output file (e.g. AIFF) and will ‘seed’ pseudo random number generators (e.g. dither) with a fixed number, thus ensuring that successive SoX invocations with the same inputs and the same parameters yield the same output."
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ps command displaying different result each time sugantha Linux - Newbie 2 09-12-2009 01:47 PM
top command result to a file in a readable format in linux rajeevp05 Linux - General 2 02-03-2009 09:47 PM
Virtual File - Result of command execution - possible? bmintern Linux - General 2 10-24-2006 04:43 PM
Output the result of a command to a file darkarcon2015 Linux - Newbie 1 09-24-2005 06:29 PM
How to write down result of performance of a command in a file ukrainet Linux - Newbie 3 12-08-2004 09:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration