general question about lame_encode_buffer()

Jana Cole via Lame-dev <[email protected]> Mon, 13 Sep 2021 03:25:18 +0000
Newsgroups gmane.comp.audio.mp3.lame
Message-ID <[email protected]>
Hello,

I'd be really grateful if you could answer a really basic question I have about LAME.If this isn't the place for beginner questions, just let me know.

I'm new to binary IO, but not new to C++. I'm trying to read in a .wav file and output a correct .mp3 file. I can read in the .wav file and display the values in the RIFF and format chunks.

My code for converting the PCM data to .mp3 frames runs, but my .mp3 file isn't right.

Windows Media Player plays 17 seconds of it, not the whole 37 seconds, and then it quits (and it sounds like the pitches have been shifted up two octaves). 

Audacity won't play the file at all, it gives me an error when it's reading in the file: "MP3 decoding failed. Lost synchronization."

My question: What exactly is in the unsigned char array I passed to lame_encode_buffer()? Is it just mp3 frames? I didn't specify a header or ID3 tags. Are there defaults for them?

Looks like maybe Windows Media Player will try to play whatever you give it. Maybe it doesn't need a header (?)

I checked the API overview and lame.h and I couldn't find an answer to my question. Any help would be gratefully appreciated.

I'm not expecting anybody to fix my code for me &mdash; I'm enjoying learning how to do this &mdash; but if you need to see my code, I posted it here:
https://pastebin.com/dqpiekWk 

I'm on Windows 10, using Visual Studio 2019 and LAME 3.100.

Thank you in advance,

Jana from San Francisco Bay Area







***************************
Thoughts are Things
***************************