Author Topic: "Noisy" mp3 ouput with BassMix and LAME  (Read 2405 times)

sorrento

  • Posts: 8
"Noisy" mp3 ouput with BassMix and LAME
« on: 2 Dec '06 - 21:06 »
I'm trying to work out how to encode all output and I'm pretty certain the way I need to go is to create a mixing stream with an encoder and then add all my streams to that as tracks are required to be played.  I want to eventually broadcast this stream, but for the moment I just wanted to write it to a file and listen to the output.

Various sources (including this forum) have led me to believe that I can simply keep appending mp3 output to a file to create the mp3 so in my encoder callback I'm simply doing that.  THe problem is that my output mp3 has clicks and pops in it, however if I simply set lame to encode to a file (no encodeproc) then the output file is perfect.

So I am now running 2 encoders on the mixer, one via my encodeproc (and into a file) and one letting LAME create a file to compare the outputs.

Skipping all the header data in the output mp3s and anaylising in a HEX editor I can see that I have a repeating pattern of every 4096 chunk of data being identical except for a 44 byte chunk of data (haven't work out it's offset, but presumably the start) and I assume this is causing my clicks and pops.  This pattern repeats throughout the file, identical for 4052 bytes, different for 44 bytes, identical.....

I expect that there's some kind of header data in every 4096 chunk of data returned from LAME but unfortunately I don't know enough to work out what's going on.

If anyone has any ideas then I'd love to hear them!

This is how I'm setting up the mixer and LAME:
Code: [Select]
  FmasterStream:=BASS_Mixer_StreamCreate(44100, 2, BASS_MIXER_NONSTOP);
  Fenc1:=BASS_Encode_Start(FmasterStream, PChar('lame -r -x -s 44100 -b 256 -'),BASS_ENCODE_NOHEAD or BASS_ENCODE_AUTOFREE,@MyEncodeProc,integer(self));
  Fenc2:=BASS_Encode_Start(FmasterStream, PChar('lame -r -x -s 44100 -b 256 - d:\output.mp3'),BASS_ENCODE_NOHEAD or BASS_ENCODE_AUTOFREE,nil,integer(self));

Thanks in advance for any advice you can offer.

sorrento

  • Posts: 8
Re: "Noisy" mp3 ouput with BassMix and LAME
« Reply #1 on: 2 Dec '06 - 22:06 »
Sorry never mind, I was not dereferencing the pointer to the buffer as it was being written to the file, funny that the data was "nearly" perfect anyway.