This is slightly off-topic ; I need to display waveforms of .ogg files for the html5-based player used by the CMS that I'm working on.
So far I can read .wav files and generate an image from it ; I'm using the method described here and it works fine for 8 and 16 bits wav files, but converting the files on the web server is not an option here, so I need to parse ogg files on the fly.
Here is my test page ; Under the graph is a dump of the table I'm using for plotting the signal line to the image ; I need to generate *this* but from an ogg file ; well, ideally from any audio file.
-Is the structure of an ogg/vorbis file really different from that of a wav file ?
-Is'nt it just a matter of passing different values to fread(), or is it an entirely different beast (probably due to the variable bitrate encoding) ?
The reason I'm asking this here is that Qtractor does exactly that, it can display the waveform of any audio clip format that you give it! If it's really not the place to ask, please file/disregard this message..
Re: Read & display waveforms
well, you seem willing to parse audio files under a php script, isn't it?
let's take a look: wav files are kind of raw files re. sample audio data. that meaning they're not encoded. you read a frame (8bit or 16bit sample) and go on with it, provided you read the header portion of the file giving you the fundamental characteristics of the digital audio data that follows...
now. ogg, mp3 and flac are different beasts. in the sense that digital audio data are encoded and those files have some special structure, way more complex than a raw stream you find on wav files (after the header, that is).
so. you probably want to know, that to read ogg files (or any other encoded format), you should bring a decoder implementation into the scene: for example, qtractor does use libvorbis et al. for ogg audio files. now there's a question whether is there any libvorbis aware php extension out there. i'll bet there are, some :)
i'll leave you there. homework exercise ;)
cheers
Re: Read & display waveforms
> now. ogg, mp3 and flac are different beasts. in the sense that digital audio data are encoded and those files have some special structure, way more complex than a raw stream you find on wav files (after the header, that is).
Dang.
> now there's a question whether is there any libvorbis aware php extension out there.
Oh, there are, but they all require installing either php extensions and/or binaries, and that is not an option as I'm developping a CMS, that is it has to work in restristed (read "free") web environnements.
But there's hope; Since the browser can read the audio, why not let him do *all* the work ? Guys look at this I bet you gonna like it :)
Re: Read & display waveforms
indeed, there's hope.
by reading the js code in that pocket full of htnl5 you can certainly get the audio data stream somehow.
the provided
soundData
object seems to have some pretty darn data members for you to explore (.waveData
,.waveDataL
,.eqDataL
,.bass
,.mid
,.treb
, ...). might be just what you're asking for :)use the source luke ;)
byee
Add new comment