Comments (3)
This is the unfortunate reality of integer numbers. The lowest possible 16-bit number is -2^15, but the highest possible is 2^15-1. When dealing with float inputs, you have to apply some scaling, and there is no correct answer.
- Do you scale positive numbers differently from negative numbers? There will be (tiny) discontinuities at the zero crossings.
- Do you scale to 2^15-1? Then you lose one value for negative numbers.
- Do you scale to 2^15? Then you lose one value for positive numbers.
There's no right answer. But in reality, the differences between these is imperceptible.
Soundfile does not implement this, but merely passes the data on to libsndfile, which does the transformation.
If you need a perfect float representation, you could always use a native float format, such as MAT5, or (IIRC) Flac or WAV with the FLOAT subtype.
from python-soundfile.
Yes. I understand that. I was mostly wondering why the scaling is different on write and read, but it is a problem with libsndfile then?
At least, this is the behavior I observe:
- Write: different scaling factor for negative and positive values
- Read: Equal scaling factor for all values
Anyhow, I understand that I'm complaining about a 1/2**15
max quantization error vs a1/2**16
max error, and these differences, as you say, are probably imperceptible.
from python-soundfile.
The problem is not that read and write are different, but that +1 is not representable. If you use values <1, it should be symmetric.
from python-soundfile.
Related Issues (20)
- Can this package take a list of ADC values and convert it to an audio file? HOT 3
- Unable to copy value of extra_info to a new variables HOT 1
- OGG file not recognised HOT 1
- raise LibsndfileError(err, prefix="Error opening {0!r}: ".format(self.name)) soundfile.LibsndfileError: Error opening 'soundwave.wav': System error. HOT 10
- [src/libmpg123/layer3.c:INT123_do_layer3():1771] error: part2_3_length (1920) too large for available bit count (1568) HOT 1
- Breadcrumbs from old pysoundfile to python-soundfile are partially broken HOT 1
- Incorrect stereo configuration when writing file causes unhelpful error message (especially if not using NumPy) HOT 1
- Writing integer values through the non-numpy interface results in a wav of all 0s HOT 13
- numpy is a dependency, but this is not declared HOT 3
- Feature request: Support interleaved stereo data HOT 4
- buffer_read doesn't work in basic test HOT 2
- module 'soundfile' has no attribute 'SoundFileRuntimeError' HOT 5
- Value Error: array is too big when loading .flac file
- soundfile crashes when trying to export long .ogg file HOT 1
- soundfile.LibsndfileError: Error opening <_io.BytesIO object at 0x0000022B81C21850>: Format not recognised. HOT 2
- Cannot suppress warnings when decoding mp3
- Cannot open Ogg FLAC file: unknown error in flac decoder HOT 1
- miniforge3/lib/python3.9/site-packages/soundfile.py", line 1229, in _init_virtual_io def vio_get_filelen(user_data): MemoryError: Cannot allocate write+execute memory for ffi.callback(). You might be running on a system that prevents this. For more information, see https://cffi.readthedocs.io/en/latest/using.html#callbacks
- Cannot write Ogg files over 96 seconds long at 44.1 kHz HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-soundfile.