Comments (13)
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.
No effect with SFC_SET_SCALE_FLOAT_INT_READ on OGG files
from libsndfile.
Sorry, really busy this week. Its unlikely I'll have a chance to look at this before the weekend.
from libsndfile.
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.
Sorry, really busy this week. Its unlikely I'll have a chance to look at this before the weekend.
No problem.
from libsndfile.
Patch for this issue http://pastebin.com/wME3zFRm or my pull request
from libsndfile.
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.
@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.
I see. Thank you for the fast answer.
from libsndfile.
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.
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.
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.
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)
- Libsndfile OGG Page Issue? HOT 3
- libsndfile SF_INFO struct frames field contains wrong value for mp3 file HOT 1
- libsndfile links libmp3lame using an absolute path on macOS HOT 5
- Broken AUTOGEN_SCRIPT path HOT 1
- Segmentation fault at sf_open when using SndfileHandle HOT 1
- sndfile-convert always normalizes files that exceed the `-1..+1` range HOT 1
- convert 44.1kHz wav to 48kHz opus, the pitch becomes higher HOT 2
- choosing bitrate when writing MP3 files HOT 2
- Potential security issues with ALAC code
- sf_set_string() supports a very limited set of strings HOT 1
- Library fail to open some .mp3 file. HOT 1
- Cmake lint error sndfile-info.dir/all] Error 2
- Shared Library build HOT 3
- Reading an Ogg file without EOS reports length as 6.6 million years
- AIFF file from lamedecoder (multichannel MPEG decoder) not decodeable? HOT 1
- What dependencies are required to use libsndfile? HOT 4
- Can't add cue points to existing audio file
- Why not use symbol versioning to link with libc ? HOT 2
- Mac osx 10.13 - cannot build libsndfile HOT 2
- make incomplete, cast discards 'const' qualifier from pointer target type
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 libsndfile.