Code Monkey home page Code Monkey logo

Comments (13)

Marisa-Chan avatar Marisa-Chan commented on May 24, 2024

Problem is in conversion from float to short and int in libsndfile. Libsndfile's code don't care about normalizing floats when converts them to integer and we get samples "short = float * 32767" when float above 1.0 or below -1.0.

from libsndfile.

Marisa-Chan avatar Marisa-Chan commented on May 24, 2024

No effect with SFC_SET_SCALE_FLOAT_INT_READ on OGG files

from libsndfile.

erikd avatar erikd commented on May 24, 2024

Sorry, really busy this week. Its unlikely I'll have a chance to look at this before the weekend.

from libsndfile.

Marisa-Chan avatar Marisa-Chan commented on May 24, 2024

And sndfile-info:

sndfile-info st11.ogg

Version : libsndfile-1.0.26pre2

File : /media/166/st11.ogg
Length : 1818885
Ogg stream data : Vorbis
Stream serialno : 28657
Vorbis library version : Xiph.Org libVorbis 1.3.3
Bitstream is 2 channel, 44100 Hz
Encoded by : Xiph.Org libVorbis I 20020717
Metadata :
Title :
Artist :
End


Sample Rate : 44100
Frames : 4188708
Channels : 2
Format : 0x00200060
Sections : 1
Seekable : TRUE
Duration : 00:01:34.982
Signal Max : 1.18905 (-88.80 dB)

from libsndfile.

Marisa-Chan avatar Marisa-Chan commented on May 24, 2024

Sorry, really busy this week. Its unlikely I'll have a chance to look at this before the weekend.

No problem.

from libsndfile.

Marisa-Chan avatar Marisa-Chan commented on May 24, 2024

Patch for this issue http://pastebin.com/wME3zFRm or my pull request

from libsndfile.

LaurentGomila avatar LaurentGomila commented on May 24, 2024

Hi

Using sf_command(file, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE) seems to take forever (15 seconds now, almost unnoticeable before).

Could it be because this function has to iterate on all the samples of the audio file? Is there an easy fix or workaround?

from libsndfile.

erikd avatar erikd commented on May 24, 2024

@LaurentGomila Yes, that is the case and no there is no easy workaround.

The fundamental problem is that reading floating point samples into short or int arrays is likely to go wrong unless you know beforehand the the maximum sample value.

The best way of avoiding the problem is to only read the data as float or double.

from libsndfile.

LaurentGomila avatar LaurentGomila commented on May 24, 2024

I see. Thank you for the fast answer.

from libsndfile.

LaurentGomila avatar LaurentGomila commented on May 24, 2024

In case SFC_SET_SCALE_FLOAT_INT_READ is not used, can't you at least clamp the float values to 1 instead of getting integers greater than 32767 that wrap to -32768 and produce cracks when the sound is played? Clamping those values should make the "errors" almost unnoticeable.

from libsndfile.

erikd avatar erikd commented on May 24, 2024

Your proposed solution works very poorly for sound files where the float values are in the range [-32768.0, 32767.0].

Files like this do exist in the wild.

from libsndfile.

Marisa-Chan avatar Marisa-Chan commented on May 24, 2024

Oh, how about make dynamic scaller flag? It's starts' from 1.0 and if find
greater value while reading - it will set new maximum. It's will not solve
problem with identic and quality sound but will solve choppy sound.

2012/10/27 Erik de Castro Lopo [email protected]

Your proposed solution works very poorly for sound files where the float
values are in the range [-32768.0, 32767.0].

Files like this do exist in the wild.


Reply to this email directly or view it on GitHubhttps://github.com//issues/16#issuecomment-9827957.

from libsndfile.

LaurentGomila avatar LaurentGomila commented on May 24, 2024

Your proposed solution works very poorly for sound files where the float values are in the range [-32768.0, 32767.0].

I see. But what happened for this kind of values with the previous code, where all values above 1 were overflowing the short integer capacity? It wasn't more correct, was it?

from libsndfile.

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.