SFML community forums

Help => Audio => Topic started by: firefly2442 on March 26, 2013, 05:00:07 pm

Title: OGG File Format Specifications
Post by: firefly2442 on March 26, 2013, 05:00:07 pm
Are there any requirements for OGG files in terms of container type, 16bit vs 32bit, bitrate, single channel vs dual channel, etc. when using SFML?  Or should anything "pretty much work"?  I don't know much about audio files so most of this is a learning experience.

Thanks in advance.
Title: Re: OGG File Format Specifications
Post by: Laurent on March 26, 2013, 06:06:09 pm
Just try, and come back if you find one file that doesn't work ;)
Title: Re: OGG File Format Specifications
Post by: firefly2442 on April 24, 2013, 04:30:30 am
So, I'm not sure if there is something wrong with this file or not...

https://www.dropbox.com/sh/y52rhbt3ypyeuzk/5w5VnFlg1Q

I can play it just fine in VLC.  However, when I play it via SFML, I get terribly bad static and I can barely hear the music.  I thought perhaps it was my code so I used the sound example that comes with SFML and copied over the "orchestral.ogg" file and I got the same issue.  I've tried it on two different computers (both Ubuntu Linux) and have the same issue.

The strange thing is, the WAV version of the file has no problems.  Even other different OGG files can be played via SFML without issues.  I've tried different encoding bitrates but that doesn't seem to help.

Any thoughts?  Thanks. :)
Title: Re: OGG File Format Specifications
Post by: Laurent on April 24, 2013, 07:48:50 am
Quote
I thought perhaps it was my code so I used the sound example that comes with SFML and copied over the "orchestral.ogg" file and I got the same issue.
Sorry but this is not clear. What does that mean?
1. you tried orchestral.ogg with your own code
2. you tried your .ogg with the SFML sound sample
3. you tried orchestral.ogg with the SFML sound sample
Title: Re: OGG File Format Specifications
Post by: firefly2442 on April 24, 2013, 05:07:37 pm
I'm sorry, #2.  I tried my .ogg file with the SFML sound example.
Title: Re: OGG File Format Specifications
Post by: eXpl0it3r on April 24, 2013, 06:20:10 pm
I can't reproduce it. Seems to play without any problems on my Windows 8 box with GCC 4.8 compiled SFML. No difference to VLC nor Media Player Classic.
What version of OpenAL and libsndfile have you installed on your system?
Title: Re: OGG File Format Specifications
Post by: firefly2442 on April 25, 2013, 06:06:39 pm
OpenAL: 1.1.14-4
libsndfile: 1.0.25-5
Title: Re: OGG File Format Specifications
Post by: firefly2442 on April 30, 2013, 05:19:58 am
I ran the program "sndfile-info" on my beat.ogg file and interestingly it is not able to read it.  Running it on the stock orchestral.ogg file from SFML works just fine though.

I used LMMS to create the beat.ogg file that I'm testing.  Perhaps there is a bug upstream in exporting ogg files?...
Title: Re: OGG File Format Specifications
Post by: Shammah on July 08, 2013, 08:34:17 pm
I am having the exact same issue. I've converted my MP3s to OGG using Audacity, and I'm getting horrible static, cracking and distortion. When I convert them to WAV or FLAC, the file plays just fine.

I'm using Arch Linux x64
openal 1.15.1-1
libsndfile 1.0.25-2
sfml 2.0-1

My project is pretty much empty, and all I've done was open up a soundbuffer, put the soudnbuffer in a sound and play it. When I play the OGG file in any other media player it works just fine without any cracking.
Title: Re: OGG File Format Specifications
Post by: Laurent on July 08, 2013, 09:09:53 pm
https://github.com/SFML/SFML/issues/310 ?
Title: Re: OGG File Format Specifications
Post by: Shammah on July 08, 2013, 10:13:57 pm
Well indeed what do you know. I've re-opened up my OGG in Audacity, normalized it to -1.0f, re-exported and it now plays back flawlessly... Doing this for every one of my music files would be highly inconvenient though, as stated on the issue page.

What makes me wonder though, is that other players like Audacity itself and VLC were able to play the OGG back flawlessly. I highly doubt that they normalize it themselves. If, they however do it, they have found a way to do it efficiently without hogging the CPU, so wouldn't this also be possible for SFML?

EDIT: I've just read that the issue lies in a conversion issue from libsndfile itself. Is it maybe an idea to use libvorbis instead for OGG music? It would require extra code; a special case for OGGs, and an additional dependency though. Or perhaps use sf_read_float in the special case of OGGs, as that apparantly seems to work.
Title: Re: OGG File Format Specifications
Post by: Laurent on July 08, 2013, 10:32:27 pm
Quote
I highly doubt that they normalize it themselves. If, they however do it, they have found a way to do it efficiently without hogging the CPU, so wouldn't this also be possible for SFML?
They don't normalize, they don't have to. I do because I want to keep the API as simple as possible, and thus only use a single sample format (16-bits signed integers).

Quote
I've just read that the issue lies in a conversion issue from libsndfile itself. Is it maybe an idea to use libvorbis instead for OGG music?
libsndfile uses libvorbis itself. That wouldn't change anything: the issue is that SFML wants integer samples while the OGG music file contains float samples. Thus a conversion has to happen, and for it to work libsndfile has to know what the maximum value is (to find the scale factor to apply), but it can't do that if it doesn't parse the whole music first, which takes forever.