www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - read Ogg/Mp3 file

reply "Namespace" <rswhite4 googlemail.com> writes:
Has anyone experience with reading of .Ogg or .Mp3 files and can 
give me a briefing?
Or does anyone know if sndfile.h was ported to D?
Jul 08 2012
next sibling parent Jacob Carlborg <doob me.com> writes:
On 2012-07-08 12:03, Namespace wrote:
 Has anyone experience with reading of .Ogg or .Mp3 files and can give me
 a briefing?
 Or does anyone know if sndfile.h was ported to D?

Try running it through DStep: http://forum.dlang.org/thread/jt9i6l$2go5$1 digitalmars.com -- /Jacob Carlborg
Jul 08 2012
prev sibling next sibling parent Johannes Pfau <nospam example.com> writes:
Am Sun, 08 Jul 2012 12:03:06 +0200
schrieb "Namespace" <rswhite4 googlemail.com>:

 Has anyone experience with reading of .Ogg or .Mp3 files and can 
 give me a briefing?
 Or does anyone know if sndfile.h was ported to D?

I haven't used it yet, but here's a derelict-style binding for sndfile: https://github.com/p0nce/DerelictSndFile
Jul 08 2012
prev sibling next sibling parent reply Benjamin Thaut <code benjamin-thaut.de> writes:
Am 08.07.2012 12:03, schrieb Namespace:
 Has anyone experience with reading of .Ogg or .Mp3 files and can give me
 a briefing?
 Or does anyone know if sndfile.h was ported to D?

I'm using libvorbis to read and OpenAL to playback .ogg files. The functions you need to import are really minimal. There are good samples on the vorbis side how to read in ogg files and openal is also not really complicated. I can post code if you want. Kind Regards Ingrater
Jul 08 2012
parent reply Benjamin Thaut <code benjamin-thaut.de> writes:
Am 08.07.2012 16:32, schrieb Namespace:
 On Sunday, 8 July 2012 at 13:42:39 UTC, Benjamin Thaut wrote:
 Am 08.07.2012 12:03, schrieb Namespace:
 Has anyone experience with reading of .Ogg or .Mp3 files and can give me
 a briefing?
 Or does anyone know if sndfile.h was ported to D?

I'm using libvorbis to read and OpenAL to playback .ogg files. The functions you need to import are really minimal. There are good samples on the vorbis side how to read in ogg files and openal is also not really complicated. I can post code if you want. Kind Regards Ingrater

Yes .ogg files and even .wav works since today. But reading mp3 should be even simple as .ogg files, or not?

Well .ogg and .mp3 are quite similar in compression technology. But you will need a mp3 library to read them. I don't know a opensource one.
Jul 08 2012
parent Benjamin Thaut <code benjamin-thaut.de> writes:
Am 08.07.2012 16:59, schrieb Namespace:
 Well .ogg and .mp3 are quite similar in compression technology. But
 you will need a mp3 library to read them. I don't know a opensource one.

I cannot open and read them like .wav files, simply with FILE* and fread? o.O I thougth i only need the structure of mp3 files and then i can read them.

Well yes, if you write your own mp3 decoder then you can do that. But the sound information within mp3s is compressed using inverse fourier transform and some other fancy math stuff. It will take quite some time to write all the code neccessary for reading the whole format. Kind Regards Benjamin Thaut
Jul 08 2012
prev sibling next sibling parent "Namespace" <rswhite4 googlemail.com> writes:
On Sunday, 8 July 2012 at 13:42:39 UTC, Benjamin Thaut wrote:
 Am 08.07.2012 12:03, schrieb Namespace:
 Has anyone experience with reading of .Ogg or .Mp3 files and 
 can give me
 a briefing?
 Or does anyone know if sndfile.h was ported to D?

I'm using libvorbis to read and OpenAL to playback .ogg files. The functions you need to import are really minimal. There are good samples on the vorbis side how to read in ogg files and openal is also not really complicated. I can post code if you want. Kind Regards Ingrater

Yes .ogg files and even .wav works since today. But reading mp3 should be even simple as .ogg files, or not?
Jul 08 2012
prev sibling next sibling parent "Namespace" <rswhite4 googlemail.com> writes:
 Well .ogg and .mp3 are quite similar in compression technology. 
 But you will need a mp3 library to read them. I don't know a 
 opensource one.

I cannot open and read them like .wav files, simply with FILE* and fread? o.O I thougth i only need the structure of mp3 files and then i can read them.
Jul 08 2012
prev sibling parent "Namespace" <rswhite4 googlemail.com> writes:
 Well yes, if you write your own mp3 decoder then you can do 
 that. But the sound information within mp3s is compressed using 
 inverse fourier transform and some other fancy math stuff. It 
 will take quite some time to write all the code neccessary for 
 reading the whole format.

 Kind Regards
 Benjamin Thaut

Ah, ok, i thought it would be so easy like reading .wav files.
Jul 08 2012