Giter VIP home page Giter VIP logo

Comments (3)

bastibe avatar bastibe commented on July 20, 2024

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.

jon-petter avatar jon-petter commented on July 20, 2024

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.

bastibe avatar bastibe commented on July 20, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.