8

I'm trying to create a basic algorithm that does packet loss concealment for core audio. I simply want to replace the missing data with silence.. in the book learning core audio, the author says that in lossless PCM, zeros mean silence. I was wondering if I'm playing VBR (ie compressed data), would putting zeros suffice for silence as well?

In my existing code.. when I plug zeros into the audio queue.. it suddenly jams (ie it no longer frees up consumed data in the audio queue callback..) and i'm wondering why

abbood
  • 23,101
  • 16
  • 132
  • 246
  • For the most popular compressed formats, replacing missing data, say with a ramp to silence after un-compression, isn't the only problem. (Re)Synchronizing with a compressed data stream after the drop-out is also a huge problem. You can't just start decoding anywhere, and have the data make any sense. – hotpaw2 Nov 27 '12 at 07:44

1 Answers1

3

PCM is the raw encoded sample. All 0 (when using signed data for samples) is indeed silence. (In fact, all of any value is silence, but such a DC offset has the potential to damage your amplifier and/or speakers, if it isn't filtered out.)

When you compress with a lossy codec, you enter a digital format where it is not trivial to just add silence. Think of adding data to a ZIP file to add null bytes to the end of a file. It isn't as simple as just inserting them arbitrarily into the ZIP file.

If you want to add silence to a compressed file, you must do so using the appropriate codec. Then, you have to fit it into the bitstream, which is also not trivial. Usually the stream is broken up by frames, but you can't even split on those frames in some formats. MP3 and AAC use a bit reservoir where unused data in prior frames can be used to encode more complicated frames later on, making splitting the file very difficult.

Brad
  • 159,648
  • 54
  • 349
  • 530
  • what if i convert the compressed data format (ie MP3 or AAC) into PCM.. *then* add the silence in the form of zeroes.. that should be a straightforward operation right? – abbood Nov 26 '12 at 15:03
  • That's correct. Just keep in mind that if you want to re-compress, you will lose additional quality in the audio. – Brad Nov 26 '12 at 15:15
  • re-compressing won't be necessary.. b/c i'll just play the music immediately after i de-compress it and insert the silent parts.. that being said.. my only worry is latency.. my application is real time: a phone broadcasts music to other phones which should get the audio packets and play them in sync.. if the de-compression time is constant.. than that will only add a constant buffering time at the beginning.. but if it's variable.. then i'm in trouble – abbood Nov 26 '12 at 15:16
  • Then there is no problem. You have to get it to PCM for playback anyway. – Brad Nov 26 '12 at 15:16