[directmusic] MP3 encoded wav tracks, a pain in the neck..

  • From: "Jason Booth" <jason@xxxxxxxxxxxxxxxx>
  • To: <directmusic@xxxxxxxxxxxxx>
  • Date: Mon, 6 Jan 2003 14:01:01 -0500


So my experience with MP3 encoded wav tracks continues:

- I've verified on 3 computers (one running 2k, one running 2kserver,
and one running XP) that the compression codec used in MP3 encoded wavs
has some huge and obvious errors. The main one being a small but very
audable gap in the audio placed about 2 seconds into every file.=20

        Also, the encoder doesn't seem to be included natively on winXP
machines, which is extremely annoying considering this is the only way
to deliver MP3 based playback with Direct Music. (note that the decoder
is present).

        This combined with the offset errors makes working with mp3
encoded wav tracks within direct music a real pain in the arse. My
workaround is as follows:


- Save the original track, record it's play time and sample count

- Add a 2.1 second sine wav to the beginning of the track

- compress the file as a wav-encoded MP3 using a third party program

- Load the file into Direct Music, record it's play time and sample
count

- Subtract the difference between the new sample count and the original
files sample count to find the offset

- quickly realize that the max offset is about 37000 samples, far less
than 2 seconds

- Subtrack the time difference and use this to offset the wav file in
the segment

- visually check the file to make sure that the sine wav isn't present
in the segment file, and hope the offset is accurate to not cause drift
over time..



        I have a feeling that this still won't be accurate, simply
because the time scale (in seconds.000) isn't going to be sample
accurate. Somehow, I'll need to convert the time scale offset into
sample counts, then see what the difference between the resulting sample
count and my correct offset is, and use both offsets (time + samples) in
direct music to get the correct offset.. Also, Direct Music reports the
mp3 encoded wav as being a slightly different number of samples than
Sound Forge does, which makes me wonder which count is correct.


Now I have to ask the really annoying end user question: Did anyone
actually try to use MP3 encoded wavs for anything even close to a real
project before they shipped Direct X 9? I can't believe how convoluded
this process is, or that anyone used MP3 encoded wavs without noticing
the gap it places in every file 2 seconds into the stream.





Other related posts: