I’m doing a program that analyses music, but I’m having a problem with FSOUND_Sample_Load. Why does it have to load the entire song at once? Why can’t it load and decompress only the samples that I lock with FSOUND_Sample_Lock?
When I load a 60 minute mp3, it takes some 600 MB of RAM…
I had the crazy idea of splitting the mp3 into X parts (perhaps each part should be 1 MB uncompressed), and then process the parts. However, I don’t quite know how to split it correctly… I split it at a even 417 byte boundary (each mp3 frame should be 417 bytes, right?), but given such parts, FSOUND_Sample_Load sometimes complains about it not being correct… And I still haven’t figured out how to deal with ogg or wma files…
Does anyone have an idea on how to achieve this?
- kittelmann asked 16 years ago
I had this new idea of using a stream instead (since that is lazy loaded), and then use FSOUND_Stream_GetSample from a DSP to get the samples. If I then put the frequency as high as possible, and then return nothing but silence from the DSP, then perhaps it could be possible.
What do you think about that?
No, I just realized that using a DSP is a bad solution, since a DSP is supplied with sound at at most some 700kSamples per seconds, which means that it’s a much slower solution than using sample_lock (which runs at an equivalent of some 3MSamples/second at my comp).
I guess I have to go for manual splitting of the files, but it’s a pain. Too bad fmod doesn’t have a solution for this.
What I do now is to split the mp3 and load it X frames at a time. I pick out X frames and then append a ID3 tag (is it neccessary to add the tag?). Then I feed that block of memory to FSOUND_Sample_Load. However, what is really interesting is that I get Y samples out, but about 25% of the times I call FSOUND_Sample_Load I get Y/2 samples 😮 . Excatly. I have checked that the frame header (incl. sync, stereo bits, bitrate, and so on) are identical every time I call FSOUND_Sample_Load.
Does anyone have a clue to what the problem might be? Is there a problem calling FSOUND_Sample_Load on the same index multiple times?
But if I have a mp3 which when loaded as one piece contains 10Msamples, and when loaded as 2 equal sized pieces (half the length of the original mp3) contain for instance 5M samples + 2.5 Msamples; is it not doing something wrong then 👿 .
All headers in the loaded frames are the same (appart from pad), and the memLength fed to FSOUND_Sample_Load are the same. FSOUND_GetError returns 0 after all calls.
I can accept that the mp3 decoding isn’t as perfect when loading the data this way, but I don’t want to loose half of the samples when loading parts of the song.
Please login first to submit.