Go Down

Topic: Simple microphone shield to generate WAV files? (Read 900 times) previous topic - next topic

Lucario448

I don't wanna keep deviating this thread, buuuut I have to ask this:

The guts of the 2nd order noise shaper is just:
Code: [Select]

    acc  += sample ;
    acc2 += acc ;
    top = acc2 >> 24   ;
    long feedback = ((long)top) << 24 ;
    acc  -= feedback ;
    acc2 -= feedback ;
    OCR2A = top + 0x80 ;
  • Should all variables have to be signed (accumulators and local ones)?
  • Why the resulting sample has an offset? What if an overflow occurs after the addition?
  • Can sample come from a WAVE file and the shaper still work fine?
  • Will this shaper also work fine at the sample rate of the previously mentioned WAVE file?

Didn't tried it yet, but I'm afraid of hearing a mess rather than the actual sound :smiley-sweat:

MarkT

I don't wanna keep deviating this thread, buuuut I have to ask this:
  • Should all variables have to be signed (accumulators and local ones)?

They are signal samples, signals are ac, so signed.  I posted the link to the full code which has all the variable declarations...
Quote
  • Why the resulting sample has an offset? What if an overflow occurs after the addition?

Offset because its going to a DAC or PWM output.  If you have overflow your signal has clipped, there's nothing you can do about that in the output stage!
Quote
  • Can sample come from a WAVE file and the shaper still work fine?

They are signal samples, as I've said, so they can come from whatever you like.
Quote
  • Will this shaper also work fine at the sample rate of the previously mentioned WAVE file?

Yes, but noise shaping has much more benefit as over-sampling ratio increases.  IE if using 44.1k
samples and 62k PWM you won't get much benefit,  but 11k sampling and 125k PWM will be much
more effective - the noise has to go somewhere, you can only push it around, not remove it!
Quote
Didn't tried it yet, but I'm afraid of hearing a mess rather than the actual sound :smiley-sweat:
You can get this to work with more integrator stages, but you have to deal with scaling and headroom
issues then, and indeed if you get it wrong its a mess.

noise shaping is indistinquishable from magic if you look at the output samples, the total amount of noise
increases (markedly for high order), but the amount of noise at low frequencies reduces, which is
all you care about.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

MarkT

#17
Jan 22, 2019, 12:16 pm Last Edit: Jan 22, 2019, 12:17 pm by MarkT
Here's some simulation of what happens with sigma-delta noise shaping for various orders (top to bottom),
showing the output waveform (top left is original), and the spectrum (before and after some low pass filtering).  The test signal is a synthesized set of sinusoidal tones that show up as equal height spikes
in the spectrum, the noise is the "floor" in each spectrum.

The output waveform is a simulation of some mild low-pass filtering applied to a 16-level DAC output.
You can see the high frequency artifacts building up as the noise shaping order increases, but the spectra
show that this lower frequencies have less and less noise, down to about -120dB (19 bit equivalent).
Without low pass filtering the high frequency noise is more prominant.

Note the top right image is the original spectrum, not a processed one, for reference.

[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Go Up