sox-users@lists.sourceforge.net unofficial mirror
 help / color / mirror / code / Atom feed
* Prevent SoX from doing the clipping?
@ 2020-06-05  6:54 Danijel DOMAZET
  2020-06-05  8:05 ` Peter P.
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Danijel DOMAZET @ 2020-06-05  6:54 UTC (permalink / raw)
  To: sox-users


[-- Attachment #1.1: Type: text/plain, Size: 798 bytes --]

Hi list,

I have a heavily "overflowed" WAV file (samples written in float 32-bit
format): instead of [-1.0,+1.0], the samples range goes as far as
[-5.0,+5.0].

Using SoX to get raw PCM audio samples from WAV file:

`sox --bits 32 --channels 1 --encoding floating-point --rate 48000
input.wav output.raw`

I get warnings:

    sox WARN sox: `input.wav' input clipped 1163400 samples
    sox WARN sox: `output.raw' output clipped 605664 samples; decrease
volume?

When I look into the output, I see the samples were clipped, and the range
is [-1.0,+1.0] now. However, that is not what I want.

I would like to have exactly the same output as input, just in different
format (RAW instead of WAV). Is there a way to prevent SoX from doing the
clipping?

Thanks!
Danijel Domazet

-- 
- Confidential -

[-- Attachment #1.2: Type: text/html, Size: 1263 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



[-- Attachment #3: Type: text/plain, Size: 158 bytes --]

_______________________________________________
Sox-users mailing list
Sox-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-users

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Prevent SoX from doing the clipping?
  2020-06-05  6:54 Prevent SoX from doing the clipping? Danijel DOMAZET
@ 2020-06-05  8:05 ` Peter P.
  2020-06-05  8:31 ` Måns Rullgård
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Peter P. @ 2020-06-05  8:05 UTC (permalink / raw)
  To: sox-users

* Danijel DOMAZET <p-danijel.domazet@devialet.com> [2020-06-05 09:19]:
> Hi list,
> 
> I have a heavily "overflowed" WAV file (samples written in float 32-bit
> format): instead of [-1.0,+1.0], the samples range goes as far as
> [-5.0,+5.0].
> 
> Using SoX to get raw PCM audio samples from WAV file:
> 
> `sox --bits 32 --channels 1 --encoding floating-point --rate 48000
> input.wav output.raw`
> 
> I get warnings:
> 
>     sox WARN sox: `input.wav' input clipped 1163400 samples
>     sox WARN sox: `output.raw' output clipped 605664 samples; decrease
> volume?
> 
> When I look into the output, I see the samples were clipped, and the range
> is [-1.0,+1.0] now. However, that is not what I want.
> 
> I would like to have exactly the same output as input, just in different
> format (RAW instead of WAV). Is there a way to prevent SoX from doing the
> clipping?
Does the RAW format support 32bit floats? Would it be possible for you
to rescale volume using the "norm" effect?
> 
> Thanks!
> Danijel Domazet
> 
> -- 
> - Confidential -

also confidential
Peter



_______________________________________________
Sox-users mailing list
Sox-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-users

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Prevent SoX from doing the clipping?
  2020-06-05  6:54 Prevent SoX from doing the clipping? Danijel DOMAZET
  2020-06-05  8:05 ` Peter P.
@ 2020-06-05  8:31 ` Måns Rullgård
  2020-06-05  8:39   ` Danijel DOMAZET
  2020-06-06 18:02 ` Jan Stary
  2020-06-06 18:03 ` Jan Stary
  3 siblings, 1 reply; 6+ messages in thread
From: Måns Rullgård @ 2020-06-05  8:31 UTC (permalink / raw)
  To: Danijel DOMAZET; +Cc: sox-users

Danijel DOMAZET <p-danijel.domazet@devialet.com> writes:

> Hi list,
>
> I have a heavily "overflowed" WAV file (samples written in float 32-bit
> format): instead of [-1.0,+1.0], the samples range goes as far as
> [-5.0,+5.0].
>
> Using SoX to get raw PCM audio samples from WAV file:
>
> `sox --bits 32 --channels 1 --encoding floating-point --rate 48000
> input.wav output.raw`
>
> I get warnings:
>
>     sox WARN sox: `input.wav' input clipped 1163400 samples
>     sox WARN sox: `output.raw' output clipped 605664 samples; decrease
> volume?
>
> When I look into the output, I see the samples were clipped, and the range
> is [-1.0,+1.0] now. However, that is not what I want.
>
> I would like to have exactly the same output as input, just in different
> format (RAW instead of WAV). Is there a way to prevent SoX from doing the
> clipping?

No, that isn't possible.  Sorry.

In your specific case, however, a workaround is possible.  If you
override input sample encoding as 32-bit signed integer instead of
float, the values will be copied untouched.  Since the output is
headerless, it doesn't matter what sox thinks the samples are.

-- 
Måns Rullgård


_______________________________________________
Sox-users mailing list
Sox-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-users

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Prevent SoX from doing the clipping?
  2020-06-05  8:31 ` Måns Rullgård
@ 2020-06-05  8:39   ` Danijel DOMAZET
  0 siblings, 0 replies; 6+ messages in thread
From: Danijel DOMAZET @ 2020-06-05  8:39 UTC (permalink / raw)
  To: Måns Rullgård; +Cc: sox-users


[-- Attachment #1.1: Type: text/plain, Size: 1491 bytes --]

Nice workaround idea, works! Thank you Mans.

p.s. Have no idea where the "confidential" thing came from, sorry.


On Fri, Jun 5, 2020 at 10:31 AM Måns Rullgård <mans@mansr.com> wrote:

> Danijel DOMAZET <p-danijel.domazet@devialet.com> writes:
>
> > Hi list,
> >
> > I have a heavily "overflowed" WAV file (samples written in float 32-bit
> > format): instead of [-1.0,+1.0], the samples range goes as far as
> > [-5.0,+5.0].
> >
> > Using SoX to get raw PCM audio samples from WAV file:
> >
> > `sox --bits 32 --channels 1 --encoding floating-point --rate 48000
> > input.wav output.raw`
> >
> > I get warnings:
> >
> >     sox WARN sox: `input.wav' input clipped 1163400 samples
> >     sox WARN sox: `output.raw' output clipped 605664 samples; decrease
> > volume?
> >
> > When I look into the output, I see the samples were clipped, and the
> range
> > is [-1.0,+1.0] now. However, that is not what I want.
> >
> > I would like to have exactly the same output as input, just in different
> > format (RAW instead of WAV). Is there a way to prevent SoX from doing the
> > clipping?
>
> No, that isn't possible.  Sorry.
>
> In your specific case, however, a workaround is possible.  If you
> override input sample encoding as 32-bit signed integer instead of
> float, the values will be copied untouched.  Since the output is
> headerless, it doesn't matter what sox thinks the samples are.
>
> --
> Måns Rullgård
>

-- 
- Confidential -

[-- Attachment #1.2: Type: text/html, Size: 2329 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



[-- Attachment #3: Type: text/plain, Size: 158 bytes --]

_______________________________________________
Sox-users mailing list
Sox-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-users

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Prevent SoX from doing the clipping?
  2020-06-05  6:54 Prevent SoX from doing the clipping? Danijel DOMAZET
  2020-06-05  8:05 ` Peter P.
  2020-06-05  8:31 ` Måns Rullgård
@ 2020-06-06 18:02 ` Jan Stary
  2020-06-06 18:03 ` Jan Stary
  3 siblings, 0 replies; 6+ messages in thread
From: Jan Stary @ 2020-06-06 18:02 UTC (permalink / raw)
  To: sox-users

On Jun 05 08:54:48, p-danijel.domazet@devialet.com wrote:
> Hi list,
> 
> I have a heavily "overflowed" WAV file (samples written in float 32-bit
> format): instead of [-1.0,+1.0], the samples range goes as far as
> [-5.0,+5.0].

How did you obtain this audio file?
Can you put it somewhere for download?

> Using SoX to get raw PCM audio samples from WAV file:

(meaning floating-point PCM?)

> `sox --bits 32 --channels 1 --encoding floating-point --rate 48000
> input.wav output.raw`

This seems pointless: with the format settings before the wav input,
you are overriding what the wav header says.
What does "soxi input.wav" say?

If the input is indeed 32 bit floats @ 48kHz mono,
and the wav header correctly says so,
you don't need to specify that.

You don't need to specify that for the output either,
as SoX will use the same format for the output,
unless told otherwise. So just do

	$ sox input.wav output.raw
	$ play -b 32 -e float -r 48000 output.raw

That does not solve your problem of course.

> I get warnings:
> 
>     sox WARN sox: `input.wav' input clipped 1163400 samples
>     sox WARN sox: `output.raw' output clipped 605664 samples; decrease
> volume?
> 
> When I look into the output, I see the samples were clipped, and the range
> is [-1.0,+1.0] now. However, that is not what I want.

How exactly do you "look" at the raw output float samples?

> I would like to have exactly the same output as input, just in different
> format (RAW instead of WAV). Is there a way to prevent SoX from doing the
> clipping?

You could just strip the WAV header.

	$ sox -n -b 32 -e float file.wav synth 1
	$ sox file.wav file.raw
	$ hexdump -C file.raw

00000000  00 00 00 00 40 c8 6b 3d  28 64 eb 3d 30 0e 30 3e  |....@.k=(d.=0.0>|
          ^^^^^^^^^^^^^^^^^^^^
	  actual audio samples

	$ hexdump -C file.wav

00000000  52 49 46 46 32 ee 02 00  57 41 56 45 66 6d 74 20  |RIFF2...WAVEfmt |
00000010  12 00 00 00 03 00 01 00  80 bb 00 00 00 ee 02 00  |................|
00000020  04 00 20 00 00 00 66 61  63 74 04 00 00 00 80 bb  |.. ...fact......|
00000030  00 00 64 61 74 61 00 ee  02 00 00 00 00 00 40 c8  |..data........@.|
                                         ^^^^^^^^^^^^^^^^^
					 here it starts ...

00000040  6b 3d 28 64 eb 3d 30 0e  30 3e d0 d4 69 3e 76 6a  |k=(d.=0.0>..i>vj|

Putting SoX out of the picture, there will be no clipping;
just strip the wav header (the first 58 bytes in this case).

Jan



_______________________________________________
Sox-users mailing list
Sox-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-users

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Prevent SoX from doing the clipping?
  2020-06-05  6:54 Prevent SoX from doing the clipping? Danijel DOMAZET
                   ` (2 preceding siblings ...)
  2020-06-06 18:02 ` Jan Stary
@ 2020-06-06 18:03 ` Jan Stary
  3 siblings, 0 replies; 6+ messages in thread
From: Jan Stary @ 2020-06-06 18:03 UTC (permalink / raw)
  To: sox-users

On Jun 05 08:54:48, p-danijel.domazet@devialet.com wrote:
> -- 
> - Confidential -

Promise you won't tell anyone before thrying that, obviously.



_______________________________________________
Sox-users mailing list
Sox-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-users

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-06-06 18:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-05  6:54 Prevent SoX from doing the clipping? Danijel DOMAZET
2020-06-05  8:05 ` Peter P.
2020-06-05  8:31 ` Måns Rullgård
2020-06-05  8:39   ` Danijel DOMAZET
2020-06-06 18:02 ` Jan Stary
2020-06-06 18:03 ` Jan Stary

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/sox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).