2025-03-28 12:16:58 +01:00
2025-03-28 12:10:48 +01:00
2025-03-28 12:08:48 +01:00
2025-03-28 12:08:48 +01:00
2025-03-28 12:10:48 +01:00
2025-03-28 12:10:48 +01:00
2025-03-28 12:16:58 +01:00

scaled_soundfile

A thin wrapper around the soundfile module to allow saving files of any scales.

It is made so you can use it as an in-place replacement for soundfile if you only used the read and write functions.

import soundfile as sf

sf.write("toto.wav", x, fs)
x, fs = sf.read("toto.wav")

is replaced with

import scaled_soundfile as sf

sf.write("toto.wav", x, fs)
x, fs = sf.read("toto.wav")

The write function rescales the input to normalize it and maximize the number of bits it is saved on. The RMS of the original sound is saved in the 'comment' metadata field as part of a JSON object. The files are saved as 'PCM_24'.

The read function loads the normalized data, and rescales it so that the RMS matches the original by reading the 'comment' metadata field if it exists.

In the current version of soundfile (and libsndfile) this only works with WAV files.

Installation

pip install git+https://git.web.rug.nl/dBSPL/scaled_soundfile.git
Description
A thin wrapper around the soundfile module to allow saving files of any scales.
Readme LGPL-3.0 46 KiB
Languages
Python 100%