Hello, I am hoping someone can point me to a website or tell me what search term to google to help me with my problem. I am writting a software driver for BeOS that plays 16 bits sound samples thru a 12 bit DAC adapter on the printer port. (Yes, I know that it is no longer needed but it is fun to work on). If you just truncate off the lower bits the system runs fine but there is lots of noise when very quiet parts are playing (even no sound for the very very quiet parts) What I would like to do is amplify the low values (-16 to +16) when converting the 16 bit samples to 12 bits. I could make my own convertion table but I am trying to find out how this is normally handled, but I don't even know what terms to search for. Any help?
Help, search term needed.
Started by ●September 15, 2008
Reply by ●September 15, 20082008-09-15
earlcolby.pottinger@sympatico.ca wrote:> Hello, I am hoping someone can point me to a website or tell me what > search term to google to help me with my problem. > > I am writting a software driver for BeOS that plays 16 bits sound > samples thru a 12 bit DAC adapter on the printer port. (Yes, I know > that it is no longer needed but it is fun to work on). > > If you just truncate off the lower bits the system runs fine but there > is lots of noise when very quiet parts are playing (even no sound for > the very very quiet parts) > > What I would like to do is amplify the low values (-16 to +16) when > converting the 16 bit samples to 12 bits. I could make my own > convertion table but I am trying to find out how this is normally > handled, but I don't even know what terms to search for. Any help?What you could do is automatically adjust the output volume so it fits to the bit size. The word for that would be "compander". It's an old technique that was most useful in the analog days for very similar purposes, noise suppression. So long, Thomas
Reply by ●September 15, 20082008-09-15
On Sep 15, 12:38�pm, Thomas Richter <t...@math.tu-berlin.de> wrote:> What you could do is automatically adjust the output volume so it fits > to the bit size. The word for that would be "compander". It's an old > technique that was most useful in the analog days for very similar > purposes, noise suppression.http://www.cs.wfu.edu/~burg/nsf-due-0340969/worksheets/NonlinearCompanding.pdf Is this what you mean? I think I duplicate this using a 32K entry lookup table.
Reply by ●September 15, 20082008-09-15
earlcolby.pottinger@sympatico.ca writes:> Hello, I am hoping someone can point me to a website or tell me what > search term to google to help me with my problem. > > I am writting a software driver for BeOS that plays 16 bits sound > samples thru a 12 bit DAC adapter on the printer port. (Yes, I know > that it is no longer needed but it is fun to work on). > > If you just truncate off the lower bits the system runs fine but there > is lots of noise when very quiet parts are playing (even no sound for > the very very quiet parts) > > What I would like to do is amplify the low values (-16 to +16) when > converting the 16 bit samples to 12 bits. I could make my own > convertion table but I am trying to find out how this is normally > handled, but I don't even know what terms to search for. Any help?You don't really want to amplify anything. What you want to do is dither from 16 bits to 12 bits. That will restore the "very very quiet parts" you now lose and will improve the sound of the other parts, but the result will necessarily be noisier than 16 bits. However, I think you'll be surprised at how good a proper-dithered 12-bit system can sound. -- % Randy Yates % "...the answer lies within your soul %% Fuquay-Varina, NC % 'cause no one knows which side %%% 919-577-9882 % the coin will fall." %%%% <yates@ieee.org> % 'Big Wheels', *Out of the Blue*, ELO http://www.digitalsignallabs.com
Reply by ●September 15, 20082008-09-15
earlcolby.pottinger@sympatico.ca wrote:> On Sep 15, 12:38 pm, Thomas Richter <t...@math.tu-berlin.de> wrote: > >> What you could do is automatically adjust the output volume so it fits >> to the bit size. The word for that would be "compander". It's an old >> technique that was most useful in the analog days for very similar >> purposes, noise suppression. > > http://www.cs.wfu.edu/~burg/nsf-due-0340969/worksheets/NonlinearCompanding.pdf > > Is this what you mean? I think I duplicate this using a 32K entry > lookup table.Yes, that's basically it. Not that this is necessarily optimal, but it seems to be close to what you've been asking for. With mu-law encoding, you still need at the other end an expander that restores the original signal (not what you can arrange for, likely), so instead the following technique might come useful: You first average over a couple of samples to detect the amplitude of the signal, and amplify it by a factor that adjusts *slowly* with this amplitude. This is more or less the technique underlying the old analog "Dolby" coding (plus adjustments in the frequency domain you don't have to bother). It will cause less distortion that direct mu-law encoding - it will "only" limit the dynamics of the music. Greetings, Thomas
Reply by ●September 15, 20082008-09-15
On Sep 15, 12:46�pm, Randy Yates <ya...@ieee.org> wrote:> You don't really want to amplify anything. What you want to do is dither > from 16 bits to 12 bits. That will restore the "very very quiet parts" > you now lose and will improve the sound of the other parts, but the > result will necessarily be noisier than 16 bits. However, I think you'll > be surprised at how good a proper-dithered 12-bit system can sound.Thanks for the pointer. However, dithering will not work well in this case. While BeOS will supply the sound samples at a number of diffirent sample rates (8K, 16K, 32K, 44.1K, 48K plus a few others) with all samples being 16 bits in size. I however prefer to support the user selecting their choice of output frequency that is indepentant of the supplied samples. The code supports 100K, 50K, 48K, 44.1K, 32K, 16K and 8K. The lower two frequencies being the preferred ones as they give the lowest CPU load but that loud dithering does create noise. I will have to think about it after I does some experiments with the suggested companding. Maybe optimizing for a high output rate with dither is the way to go, but I would like to test other ideas first. Again thanks for your suggestion, it make food for thought.
Reply by ●September 15, 20082008-09-15
On Sep 15, 12:53�pm, Thomas Richter <t...@math.tu-berlin.de> wrote:> so instead the following > technique might come useful: You first average over a couple of samples > to detect the amplitude of the signal, and amplify it by a factor that > adjusts *slowly* with this amplitude. This is more or less the technique > underlying the old analog "Dolby" coding (plus adjustments in the > frequency domain you don't have to bother). It will cause less > distortion that direct mu-law encoding - it will "only" limit the > dynamics of the music.Aaaarrrrgggg, guess what I have tried that and it did not work so I dropped the idea. Then just yesterday I realized out of the blue that I had a big bug in my code. That is the whole reason I started this thread:- beacuse I want ideas before I start coding again. And now you tell me I was doing the right thing from the start (minus the bugs of-course). Time to start coding.
Reply by ●September 15, 20082008-09-15
<earlcolby.pottinger@sympatico.ca> wrote:>On Sep 15, 12:46�pm, Randy Yates <ya...@ieee.org> wrote:>> You don't really want to amplify anything. What you want to do is dither >> from 16 bits to 12 bits. That will restore the "very very quiet parts" >> you now lose and will improve the sound of the other parts, but the >> result will necessarily be noisier than 16 bits. However, I think you'll >> be surprised at how good a proper-dithered 12-bit system can sound.>Thanks for the pointer. However, dithering will not work well in this >case. While BeOS will supply the sound samples at a number of >diffirent sample rates (8K, 16K, 32K, 44.1K, 48K plus a few others) >with all samples being 16 bits in size. I however prefer to support >the user selecting their choice of output frequency that is >indepentant of the supplied samples. The code supports 100K, 50K, >48K, 44.1K, 32K, 16K and 8K. The lower two frequencies being the >preferred ones as they give the lowest CPU load but that loud >dithering does create noise.Dithering may help (it is not certain to help) but what you mainly want to do is compress the 16-but signal prior to dithering (if present), rounding it to 12 bits, and sending it to the DAC. You do not, however, want to use instantaneous compression, which is merely a lookup table on the 16 bit value. You instead want an audio compression algorithm. I am sure there are software examples of this you can grab for free and play with. But typically a feed-forward compressor has three parts: an RMS level detector, a transfer function, and a gain-control stage. RMS detectors involve a filtering stage, which for audio corresponds to a time constant between 50 msec and 300 msec, and sometimes have different attack and decay profiles. The desired transfer function, in your case, would be something like the following: 0 dB of gain through the gain control stage with full-scale input, +24 dB gain if the input is below about -60 dB of full scale, and a linear transfer function between these extremes. This is a compression ratio of only (60+24)/24 or 1.4 to 1, which is relatively mild, and you will probably not have to play with your filter much (if at all) to avoid audible pumping artifacts. Separately, you may also find that dithering helps. Hope this helps. Steve
Reply by ●September 15, 20082008-09-15
On Sep 15, 10:50�am, glen herrmannsfeldt <g...@ugcs.caltech.edu> wrote:> earlcolby.pottin...@sympatico.ca wrote: > > (snip) > > > If you just truncate off the lower bits the system runs fine but there > > is lots of noise when very quiet parts are playing (even no sound for > > the very very quiet parts) > > The usual solution is called dither.Another vote for dithering, maybe I should write two diffirent drivers at the same time.
Reply by ●September 15, 20082008-09-15
On Sep 15, 10:36�am, spop...@speedymail.org (Steve Pope) wrote:> <earlcolby.pottin...@sympatico.ca> wrote: > >On Sep 15, 12:46�pm, Randy Yates <ya...@ieee.org> wrote: > >> You don't really want to amplify anything. What you want to do is dither > >> from 16 bits to 12 bits. That will restore the "very very quiet parts" > >> you now lose and will improve the sound of the other parts, but the > >> result will necessarily be noisier than 16 bits. However, I think you'll > >> be surprised at how good a proper-dithered 12-bit system can sound. > >Thanks for the pointer. �However, dithering will not work well in this > >case. �While BeOS will supply the sound samples at a number of > >diffirent sample rates (8K, 16K, 32K, 44.1K, 48K plus a few others) > >with all samples being 16 bits in size. �I however prefer to support > >the user selecting their choice of output frequency that is > >indepentant of the supplied samples. �The code supports 100K, 50K, > >48K, 44.1K, 32K, 16K and 8K. �The lower two frequencies being the > >preferred ones as they give the lowest CPU load but that loud > >dithering does create noise. > > Dithering may help (it is not certain to help) but > what you mainly want to do is compress the 16-but signal > prior to dithering (if present), rounding it to 12 bits, > and sending it to the DAC. > > You do not, however, want to use instantaneous compression, which > is merely a lookup table on the 16 bit value. �You instead want > an audio compression algorithm. � I am sure there are software > examples of this you can grab for free and play with. > But typically a feed-forward compressor has three parts: an RMS level > detector, �a transfer function, and a gain-control stage. > > RMS detectors involve a filtering stage, which for audio corresponds > to a time constant between 50 msec and 300 msec, and sometimes > have different attack and decay profiles. > > The desired transfer function, in your case, would be something > like the following: 0 dB of gain through the gain control stage > with full-scale input, +24 dB gain if the input is below about -60 > dB of full scale, and a linear transfer function between these > extremes. �This is a compression ratio of only (60+24)/24 or > 1.4 to 1, which is relatively mild, and you will probably not > have to play with your filter much (if at all) to avoid audible > pumping artifacts.I have you know that you lost me by the time you reached "feed-forward compressor ", I think I need to sit down at home and reread your reply a few times before I get what you are saying. (I am at work now)> Separately, you may also find that dithering helps. �And another vote to dither.> Hope this helps.Yes and No, it just makes me know all the more how much I don't know.






