0

I'm trying to get the loop start and end point metadata from an audio sample. I'm using soxi with the -V verbose flag. The data I need shows up in the terminal but isn't captured, nor piped to the next command.

Showing the data with soxi:

$ soxi -V sample.aif

soxi INFO formats: detected file format type `aiff'
soxi INFO aiff: AIFF Loop markers:
soxi INFO aiff: Loop 0: start:  75576
soxi INFO aiff:  end:   103868
soxi INFO aiff:  count:      1
soxi INFO aiff:  type:  
soxi INFO aiff: forward
soxi INFO aiff: Unity MIDI Note: 52
soxi INFO aiff: Low   MIDI Note: 50
soxi INFO aiff: High  MIDI Note: 53

Input File     : 'sample.aif'
Channels       : 1
Sample Rate    : 44100
Precision      : 24-bit
Duration       : 00:00:03.80 = 167665 samples = 285.145 CDDA sectors
File Size      : 507k
Bit Rate       : 1.07M
Sample Encoding: 24-bit Signed Integer PCM

But when I pipe that output into a text file the top section still appears in the terminal and only the bottom section is piped to the text file:

$ soxi -V sample.aif >> data.txt

soxi INFO formats: detected file format type `aiff'
soxi INFO aiff: AIFF Loop markers:
soxi INFO aiff: Loop 0: start:  75576
soxi INFO aiff:  end:   103868
soxi INFO aiff:  count:      1
soxi INFO aiff:  type:  
soxi INFO aiff: forward
soxi INFO aiff: Unity MIDI Note: 52
soxi INFO aiff: Low   MIDI Note: 50
soxi INFO aiff: High  MIDI Note: 53

$ cat data.txt

Input File     : 'sample.aif'
Channels       : 1
Sample Rate    : 44100
Precision      : 24-bit
Duration       : 00:00:03.80 = 167665 samples = 285.145 CDDA sectors
File Size      : 507k
Bit Rate       : 1.07M
Sample Encoding: 24-bit Signed Integer PCM

Why can't I capture that top section of output, which contains the data I need?

Dan Weaver
  • 711
  • 8
  • 20

1 Answers1

2

The -V parameter of soxi outputs the verbose part to stderr (fd 2)

To include the verbose part as well, redirect stderr to stdout (fd 1)

$ soxi -V sample.aif 2>&1 | tee -a data.txt
lambda-larry
  • 343
  • 1
  • 7
  • 1
    Excellent, thanks. Is it documented anywhere that verbose output to stderr? Or is that a convention I don't know? EDIT - found it in sox man page, redirected from soxi man page – Dan Weaver Jun 10 '23 at 01:39
  • Yes, it was described in the [soxi(1)](https://linux.die.net/man/1/soxi) man page, which refered to [sox(1)](https://linux.die.net/man/1/sox) man page. – lambda-larry Jun 10 '23 at 01:44