0

I'm trying to imagine a way to change the volume of a PCM stream without the use of floating point numbers, to be able to do the job on simple dedicated hardware. I found very interesting this thread: How to change the volume of a PCM data stream (failed experiment) But they use floating point numbers.

Now, PCM samples are signed int, so if I would sum or subtract a value to the samples, I have to increase or decrease the absolute value, otherwise I'm just shifting the wave up or down. More, I have to be sure that the positive samples does not become negative and vice versa (because they may be smaller than the value I'm subtracting). In this case the value of the sample should stop on 0.

So, the question: is this approach correct? have I to expect any quality loss?

Thanks.

Axel
  • 1
  • 3

1 Answers1

0

Ok, I think I have an answer: Since I sum or subtract (even with the tricks to keep the sign), I'm just shifting the wave up and down of a fixed value.

To do the job, I need to multiply the sample to a fixed value, obtaining a stretching of the wave.

Now, if I would try to do this just with integer values, let's say, with a multiplier from 0 to 7 for the volume on 24 bit samples and mixing 32 channels, I would need to perform the operations on 32 bit integers, to avoid overflows. While with 64 bit calculations I would be able to handle 24 bit samples 24 bit for the volume and 65536 channels. If there are no errors in my calculations.

Axel
  • 1
  • 3