From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=AWL,BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, SPF_PASS,UNPARSEABLE_RELAY shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id E14731F55B for ; Sat, 6 Jun 2020 18:29:27 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1jhdZG-0006Kl-Cm; Sat, 06 Jun 2020 18:29:18 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jhdZE-0006Ke-Ot for sox-users@lists.sourceforge.net; Sat, 06 Jun 2020 18:29:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=In-Reply-To:Content-Type:MIME-Version:References: Message-ID:Subject:To:From:Date:Sender:Reply-To:Cc:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=x4tzzqyfcv57x9oGaF4zNu58D9oPeYNebFJhtuPhnXE=; b=A8gnIa0gDGH/Lhwi1JDZmc2W3o QmvFitHowqbQwwCzOBDzfq1zfmBCgiSnbulNtvvzjXb6HdPiy24NY6ktNKBWZJOdKDTEQ+LHfgWil 6TzWHkhsSFDLO3HZnJlOX52XTESTUEp3IkljabOyGXV8TwjgvZ6xCpE/2HoyWwDnKNOs=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:To: From:Date:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=x4tzzqyfcv57x9oGaF4zNu58D9oPeYNebFJhtuPhnXE=; b=S6X2VGGoZseTYwTZYNBSJQVOVk v4VHOQXfn7fHlvCgedztXsS5Gjg11gu4tUGSH96Nr5NtBjkA4fFJeLE/1rdDJwgxQFKQtwl1fg9uv O2uYspqXrH/ZYCuwwo0UNlfURYy1DVkyie6G3YwaEnQHUvgeiJ96UxBUtpRQ578uwi48=; Received: from ns.stare.cz ([79.98.77.229] helo=mx.stare.cz) by sfi-mx-4.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1jhdZB-00EGQO-WF for sox-users@lists.sourceforge.net; Sat, 06 Jun 2020 18:29:16 +0000 Received: from localhost (stare.cz [local]) by stare.cz (OpenSMTPD) with ESMTPA id b5add131 for ; Sat, 6 Jun 2020 20:02:26 +0200 (CEST) Date: Sat, 6 Jun 2020 20:02:26 +0200 From: Jan Stary To: sox-users@lists.sourceforge.net Message-ID: <20200606180226.GA49799@www.stare.cz> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Headers-End: 1jhdZB-00EGQO-WF Subject: Re: Prevent SoX from doing the clipping? X-BeenThere: sox-users@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sox-users@lists.sourceforge.net Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: sox-users-bounces@lists.sourceforge.net 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