Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Extract sound level values with wavpack? (Read 6511 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Extract sound level values with wavpack?

Hi, thanks for your work,

i have just found wavpack as great tool for audio files. I need to extract level values from a wave file, the clear sound data as a collection of numbers. Is it possible with wavpack or its tools? Should run in linux. Thank you for your hints!

regards waver7

Extract sound level values with wavpack?

Reply #1
Quote
I need to extract level values from a wave file, the clear sound data as a collection of numbers.


Could you explain in more detail what you want to do?  Extract PCM?  Use a Wavpack decoder.  Extract loudness?  Use replaygain.  RMS?  Use an audio editor or similar tool.

Extract sound level values with wavpack?

Reply #2
Try SoX with the stats command.

Quote
stats [−b bits|−x bits|−s scale] [−w window-time]

Display time domain statistical information about the audio channels; audio is passed unmodified through the SoX processing chain. Statistics are calculated and displayed for each audio channel and, where applicable, an overall figure is also given.

For example, for a typical well-mastered stereo music file:

Image soxpng/grohtml-255919.png

DC offset, Min level, and Max level are shown, by default, in the range ±1. If the −b (bits) options is given, then these three measurements will be scaled to a signed integer with the given number of bits; for example, for 16 bits, the scale would be −32768 to +32767. The −x option behaves the same way as −b except that the signed integer values are displayed in hexadecimal. The −s option scales the three measurements by a given floating-point number.

Pk lev dB and RMS lev dB are standard peak and RMS level measured in dBFS. RMS Pk dB and RMS Tr dB are peak and trough values for RMS level measured over a short window (default 50ms).

Crest factor is the standard ratio of peak to RMS level (note: not in dB).

Flat factor is a measure of the flatness (i.e. consecutive samples with the same value) of the signal at its peak levels (i.e. either Min level, or Max level). Pk count is the number of occasions (not the number of samples) that the signal attained either Min level, or Max level.

The right-hand Bit-depth figure is the standard definition of bit-depth i.e. bits less significant than the given number are fixed at zero. The left-hand figure is the number of most significant bits that are fixed at zero (or one for negative numbers) subtracted from the right-hand figure (the number subtracted is directly related to Pk lev dB).

For multi-channel audio, an overall figure for each of the above measurements is given and derived from the channel figures as follows: DC offset: maximum magnitude; Max level, Pk lev dB, RMS Pk dB, Bit-depth: maximum; Min level, RMS Tr dB: minimum; RMS lev dB, Flat factor, Pk count: average; Crest factor: not applicable.

Length s is the duration in seconds of the audio, and Num samples is equal to the sample-rate multiplied by Length. Scale Max is the scaling applied to the first three measurements; specifically, it is the maximum value that could apply to Max level. Window s is the length of the window used for the peak and trough RMS measurements.

Extract sound level values with wavpack?

Reply #3
yes i think sox is the right one.

sox test.wav -n stats
DC offset  -0.130354
Min level  -0.964447
Max level  0.705353
Pk lev dB      -0.31
RMS lev dB    -12.34
RMS Pk dB    -11.52
RMS Tr dB    -12.78
Crest factor    3.99
Flat factor    0.00
Pk count          2
Bit-depth      16/16
Num samples    22.5k
Length s      0.511
Scale max  1.000000
Window s      0.050

In this table i point to the entry "Num samples". How can i extract these 22.5k sample data as numeric values? So 22,5k on Data?

Extract sound level values with wavpack?

Reply #4
There is lots of information readily available. Google wav file format and then have a look at wikipedia.

Extract sound level values with wavpack?

Reply #5
Thank you. The problem was, that the knowledge of the wav-file structure dont show me how to extract the values from the data chunk. That is the reason of this thread. Furthermore i need a solution for unix.

Extract sound level values with wavpack?

Reply #6
Whether you want to count the number of samples, or access their values, there must be open source routines to do this. I would google open source wave file.

If you convert the sample values to a text file, it will be much larger than the original wave file. It would be better to find a routine to load the wave file directly into whatever you want to use.

cheers,
David.

Extract sound level values with wavpack?

Reply #7
Thank you. The problem was, that the knowledge of the wav-file structure dont show me how to extract the values from the data chunk. That is the reason of this thread. Furthermore i need a solution for unix.


You really need to explain what you're asking for in a little bit more detail.  Its hard to even guess what you actually want from this question.

Extract sound level values with wavpack?

Reply #8
Iam looking for a command, that extract the 01001101 10111110 00001111 11110101 (Bytes of data (data chunk)) ... read out the sample values. Only the sound data. I dont know what i should explain more.

@2Bdecided ok, i take a look. Normaly i hoped to get a smal command, no c-code.

Extract sound level values with wavpack?

Reply #9
Iam looking for a command, that extract the 01001101 10111110 00001111 11110101 (Bytes of data (data chunk)) ... read out the sample values. Only the sound data. I dont know what i should explain more.


If thats all you want, then the normal decoder and use:

wvunpack -r in.wv output.samples

Extract sound level values with wavpack?

Reply #10
I don't know if this will help you, but both Audacity and GoldWave have tools for saving the sample data as text.    One issue with this might be that you are looking at the audio editor's data, not the original file.  For example, Audacity will show the floating-point values (where 0dB is +/- 1.0).

In Audacity: Analyze -> Sample Data Export.  (Choose the Linear  Measurement scale.)

Here's an example of what Audacity gives you:
Quote
sample-data5.txt  2 channels (stereo)
Left channel then Right channel on same line.
Sample Rate: 44100 Hz. Sample values on linear scale.
Length processed: 100 samples 0.00227 seconds.


-0.00183   0.18970
-0.00186   0.14175
-0.02280   0.14066
-0.01584   0.16815
-0.02466   0.11380
-0.08188   0.06107
-0.09854   0.05853
-0.14084   0.03131
-0.20316   0.03732
-0.14594   0.12439
-0.07410   0.19080
-0.13168   0.18982
-0.22549   0.20508
-0.19412   0.27438
-0.15729   0.28787
-0.24057   0.23837
-0.23859   0.23926
-0.13712   0.25116
-0.11496   0.21194
-0.09512   0.19464
-0.00565   0.20648
0.04703   0.21762
0.07034   0.26285
0.09454   0.23392
0.01279   0.12692.....


GoldWave can convert to 16-bit or 24-bit integer (or in this case convert-back to 16-bit integer).  In In GoldWave: Save As -> Save As Type -> Numerical Text.

This is from GoldWave.  A different file, mono this time, 16-bits:
Quote
465
-97
-221
-29
208
-158
-143
128
-29
-210
-145
259
21
-69
97
51
-133
-110
405
-24
-325
-115
164
13
-188
188
162
-61
-243
216
177
-220
-91
27
13
-228
196
197
-182
-28
163
149
-193
2
116


Both of these programs will show the results in decimal (not binary).  And of course, I'm just showing you the first few bytes.



You can look at the bytes of any file with a Hex Editor.  In this case, you'll be looking at the hexacecimal bytes.  (You can also get the decimal value.) 

The byte values can be somewhat  useful for 8-bit mono WAV files, except that there are of course thousands of samples per second...  It gets a LOT trickier with 16-bit, stereo files, etc., because it's hard to know what each byte represents.  And of course, it does you no good to look at compressed WavPack data.

Extract sound level values with wavpack?

Reply #11
Hi again,

@saratoga: The command wvunpack -r in.wv output.samples creates a raw file. Later i will try to get binary data with a hex-bin converter.

@DVDdoug: The solution with Audacity is interessting. Goldwave is unfortunately a windows prog. i need a console solution. Goldfinger has the best output, but now i try it with Audacity. I dont knew the Audacity analyse -> sample export data function befor. Thanks.

After it i'll check the converted decimal values from the hex-code, from different files.

Thank you for all hints.


Extract sound level values with wavpack?

Reply #12
@saratoga: The command wvunpack -r in.wv output.samples creates a raw file.


If by raw file, you mean it writes the actual sample data to disk, then yes. 

Later i will try to get binary data with a hex-bin converter.


Ok so you don't actually want the actual sample data.  You want to convert it to some other format.  Explain what that format is.

Extract sound level values with wavpack?

Reply #13
.. the acual sample data ideally in 01010111

my_Post