When I want to process an audio in a byte level, I always convert it in .wav format and then do my processing. For example in my last project, I was trying to generate a kind of special waveform image of my audio file to use it in a video clip. Then I converted my .mp3 file to .wav file (mono, 8 bit, 6KHz) using an online tool and then I maked my waveform picture programmatically.
Now I want to be able to do my processing on an .mp3 file directly without conversion, like the code below:
aFrom := 60000; // From 00:01:00.000
aLength := 20000; // 20 Second
aChannels := 1; // mono
aBitsPerChannel := 8;
aFreq := 6000;
aBufSize := Open_MP3_As('d:\Until The Last Moment.mp3',
aBuffer, aFrom, aLength,
aChannels, aBitsPerChannel, aFreq);
for i := 0 to aBufSize - 1 do
begin
// Processing aBuffer[i]
end;
this is just an example of showing what in my mind is. As you can see, the metadata and the details of the .mp3 file is not important for me.
This would be very useful because I can embed this ability to my audio tools and let the user use my tools very faster and easier. I know that it could be a very complicated code because at the first time, the .mp3 file must be converted to .wav file (with the specific given parameters), then it must remove the header, slice it and put it in the aBuffer and return the amount of samples in aBuffer.