I'm working on a dsPIC33, using Audio Codec Board - Proto to read audio samples and for reproduction.

In order to implement a relatively simple signal processing algorithm, I'm reading audio samples and I'm supposed to process them and pass them to DAC for reproduction.

The dsPIC33 I'm using filters the signal using Q15 format, but the samples I'm getting from Codec board are signed 2's complement, 16-bit. Thus far, I managed to get the reading and send it to DAC, without any data manipulation, but now I need to filter the signal.

Is there a way to overcome this format barrier? I suppose that conversions from signed 2's complement to Q15 and vice versa are necessary.

  • $\begingroup$ the dsPIC doesn't filter any signal using any format, it's the software you write that does the filtering using some specific width! $\endgroup$ Jan 18, 2021 at 17:14
  • $\begingroup$ smiljanic997, are you programming the dsPIC33 using C (without float) or assembly language? if the latter, does the instruction set include register shift operators? $\endgroup$ Jan 18, 2021 at 22:14
  • $\begingroup$ i just took a look at the instruction set of the dsPIC30. it has 40-bit accumulators. it's a lot like a 16-bit version of the 56K. i think that, if you program this thing in its assembly language, and if you learn how to do fixed-point arithmetic, you can do decent, high-quality audio filtering (or any other audio operation in the time domain). you might want to learn about noise-shaping, particularly "fraction saving". $\endgroup$ Jan 18, 2021 at 22:24

2 Answers 2


I suppose that conversions from signed 2's complement to Q15 and vice versa are necessary.

Yes & No. Q15 (signed) uses 2's complement, the bits are the same so no conversion is necessary. The difference between a Q15 and Q0 aren't the bit them selves but your interpretation of them. If you multiply two 16-bit numbers you get a 31-bit long result (one less than 32 because of a redundant sign bit). If you want to convert this to Q15 you take the top 16 bits, if you want Q0 you take the bottom 15 bits plus the sign bit.

The problem is that fixed point audio processing is difficult and 16-bit audio processing is extremely difficult. You need to constantly manage head room and optimize signal to noise ratio for each processing step. Fixed point filters require careful management of section ordering, section gain, section topology, noise shaping, rounding strategies, limit-cycle prevention, etc.

If you can afford it, I strongly recommend to do this in 32-bit floating point, which is much, much easier. If you can't, consider 32-bit or at least 24-bit fixed point. If that's not possible either, at the very least use double precision (fixed point) accumulators and filter state variables. If that's also not an option, you have a very rough project ahead of you.


as Hilmar said, "Q15" is a loosely defined terminology which is more often expressed as "Q1.15". it means 1 bit to the left of the binary point (which is the most significant bit and the sign bit) and 15 bits to the right of the binary point.

i dunno the instruction set of the dsPIC33, but if you can do all of the integer operations that you can normally do with a simple processor, you can do simple audio operations, but you may have to store some numbers in double precision using two 16-bit words to store a 32-bit quantity. there has been a lot of audio done in 16-bit fixed-point, but usually it was only voice-quality, not music. however audio CDs are 16-bit numbers, so this is not impossible.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.