I'm chewing on the previous post and trying to find a way to calculate the binary value of the D15-D8 bits when attenuation changes.
I think I'm getting somewhere. Just need to experiment a bit. Thanks for your guidance so far.
I think I'm getting somewhere. Just need to experiment a bit. Thanks for your guidance so far.
Just right math based on volume and gain is need in reverse order based on volume_db, I would be glad to see formula, I'm so lazy right now to try to get formula in vicewersa order based on volume_db to get volume_byte and gain_byte 8bit values, also it will be great having predefined step size and trought volume_db and predefined step get right volume_byte and gain_byte, that would be great! My hope somebody with good math brain can do it easy : ) The rest is easy to implement into allready half implemented Muses library from github , or even new from stratch can be done.
There is some unc;lear things in datasheet about mute. For example what is going on when volume_byte is 0 or 255, datasheet says that it is mute but nothing about if it is realy mute if gain is changed from zero, it need to be tested!
There is some unc;lear things in datasheet about mute. For example what is going on when volume_byte is 0 or 255, datasheet says that it is mute but nothing about if it is realy mute if gain is changed from zero, it need to be tested!
Last edited:
My maths is not that good either, but I'll get it figured out eventually.
Here is an observation: If I don't need gain, we can disregard gain in the formula (because I'm not using opamps with the Muses anyway):
0 - ((volume_byte x 0.5) - 8) + (gain_byte x 0.5) = volume_db
To look like this: 0 - ((volume_byte x 0.5) - 8) = volume_db
Example:
(with gain) 0 - ((0b11101111 x 0.5) - 8) + (0.5 x 0.5) = -111.25db
(without gain) 0 - ((0b11101111 x 0.5) - 8) = -111.5db
Here is an observation: If I don't need gain, we can disregard gain in the formula (because I'm not using opamps with the Muses anyway):
0 - ((volume_byte x 0.5) - 8) + (gain_byte x 0.5) = volume_db
To look like this: 0 - ((volume_byte x 0.5) - 8) = volume_db
Example:
(with gain) 0 - ((0b11101111 x 0.5) - 8) + (0.5 x 0.5) = -111.25db
(without gain) 0 - ((0b11101111 x 0.5) - 8) = -111.5db
Right! Gain is by default 0 and step is by default 0.5, independent volume left/right, and also zero cross active . There is allready some other default values which can be used to form bits from D15 to D0,, you need to change only bit value you need for example bits from D7 to D4 for accesing channel left or right and the rest to change is only volume_byte (bits D15 to D8)
mute is achieved when you set volume_byte zero or 255.
mute is achieved when you set volume_byte zero or 255.
Last edited:
Check if you agree with my formula for calculating the binary bits: binary = (-2 x dB) + 16
That is for volume only. No gain.
That is for volume only. No gain.
I'm trying ChatGPT but seems hard to get what I want, always give wrong formula. Question for ChatGPT was:
if I type my formula 0- getting removed from an unknown reason, so I type -1x but always getting 238 instead of 239, so I added +1 at the end, hope formula is right?
volume_byte = ((volume_db - 8 + gain_byte x 0.5) / -0.5) + 1
example:
volume_byte = ((-111.25 - 8 + 0.5 x 0.5) / -0.5) + 1
volume_byte = 239
I am not sure if formula is right! : )
-1 x ((volume_byte x 0.5) - 8) + (gain_byte x 0.5) = volume_db
how to calculate volume_byte if volume_db and gain_byte is known
if I type my formula 0- getting removed from an unknown reason, so I type -1x but always getting 238 instead of 239, so I added +1 at the end, hope formula is right?
volume_byte = ((volume_db - 8 + gain_byte x 0.5) / -0.5) + 1
example:
volume_byte = ((-111.25 - 8 + 0.5 x 0.5) / -0.5) + 1
volume_byte = 239
I am not sure if formula is right! : )
I hate to bring up this point in this thread full of excited hardware people, but if you want perfect channel-matched attenuation and can stand a bit of latency, use ADC-->Raspberry Pi-->ALSA volume control (via amixer, etc.)-->DAC. The R-Pi GPIO interface allows one to connect a "knob" or whatever control to the Pi and run a loop that scans for user input, changing the volume as needed. It's a pretty easy project. You can define the volume curve, how fast the volume will change, add muting, etc. Whatever you can dream up.
For years I have been using a preamp that consists of a computer plus a USB audio interface (with multiple ACD and DAC channels) that gives me source selection, volume control, is a streamer/player, etc. and does DSP. Oh, and it comes with a very fancy "display" too!
For years I have been using a preamp that consists of a computer plus a USB audio interface (with multiple ACD and DAC channels) that gives me source selection, volume control, is a streamer/player, etc. and does DSP. Oh, and it comes with a very fancy "display" too!
I would not use volume at all but variable power supply as a volume control! Take a look at this project -> https://www.diyaudio.com/community/threads/direct-digital-power-dac-ddpd.395974/ There is digital to nalog conversion done at LC filter + speakers! : ) Dynamic sound uncoparable to anything I heard. Any software volume attenuation & you getting bits off from original material. For example, if you have 24bit audio track do not expect 24 bits after software attenuation! Having variable power supply as a volume control and your bits is always as like on input. : ) I'm finishing that small ddpd in next few days, concept with small blue alu case, oled, and things is almost done. My opinion about concept - digital music with analog circuity? The simply, one does not go with the other! Converting from digital to analog than converting from anlog to digital for example inside an class D than again convertnig to analog and how many conversions is done? What to expect? Resolution lost!
I have bought this one https://vi.aliexpress.com/item/1005005979396066.html for big brother of the mini ddpd, its next project with ganFets in full bridge, dsp, pcm2dsd, dsd2pcm, optic, usb, bluetooth... volume control this time from 0V to +48V, I will look for better supply after test, maybe an diy with better regulation.
I have bought this one https://vi.aliexpress.com/item/1005005979396066.html for big brother of the mini ddpd, its next project with ganFets in full bridge, dsp, pcm2dsd, dsd2pcm, optic, usb, bluetooth... volume control this time from 0V to +48V, I will look for better supply after test, maybe an diy with better regulation.
Last edited:
@savan I am not worried about losing bits when doing volume control digitally. 24 Bits is way more than the full range of human hearing and it is very rare for ANY audio equipment to actually be capable of achieving such a range due to a lower S/N ratio.
Anyway, you linked to an entire hardware project. What I describe can be done using off-the-shelf components and small program similar to a batch file, or you can control everything using keyboard and mouse. There is no need for all of this wasted development effort, which was sort of the point of my post, and once you have the audio signal inside the computer you can do many other things with it.
Anyway, you linked to an entire hardware project. What I describe can be done using off-the-shelf components and small program similar to a batch file, or you can control everything using keyboard and mouse. There is no need for all of this wasted development effort, which was sort of the point of my post, and once you have the audio signal inside the computer you can do many other things with it.
ok, I agree, but someone can pay attention to the fact that the resolution is not lost only on that software volume control, you have to count on all other hw conversions, how many conversions is done between audio in and speakers, in the end you get 2/3 or 1/2 or even more in worst case of all that. It is not insignificant. Your idea is ok for digital music for sure!
There is no need for all of this wasted development effort, which was sort of the point of my post
@CharlieLaub I'm afraid I don't see the point. This "wasted development" as you call it is certainly not wasted in my case. I do DIY as a hobby and I like learning new things. So all this "development" is not a waste for me.
I'm not sure if you mean that ADC, etc. has "perfect channel-matched attenuation" and the Muses doesn't. That would be an unfair statement because the stereo channels of the Muses can be controlled very precisely by the firmware and code of an MCU. Attenuation in the Muses is not digital either. It is merely controlled digitally while attenuation is done with a resistance ladder circuit, much like a potentiometer with variable resistance, but with very precise and small steps. 231 steps if gain is not used, and more steps if external opamps are used for gain.
If I misunderstood your "perfect channel-matched attenuation", please enlighten me.
@savan I do not understand where you get the idea that HALF of the bits are lost... or more (!) - that is just nonsense.
If you have a 24-bit interface, you get 24 bits of audio data in from your ADC (this will include some noise of course). Audio manipulations inside the computer are typically done on a float representation of the audio data, not fixed bits like in hardware. There is no significant loss of bits until you start doing volume control. Most volume is controlled over the range of 0dB to -40dB and in the value stays exact until you need to covnert back to a fixed bit representation. Even 40dB of attenuation is only going to result in a loss of 6 to 7 bits of output data. You are still left with at least CD quality data when the playback level is down to a whisper and the amount of resolution that is left over is still quite high. It will be plenty compared to the room S/N when the playback level is low. As you turn up the volume, you gain resolution and dynamic range as there is less bit loss from the volume-change process.
If you have a 24-bit interface, you get 24 bits of audio data in from your ADC (this will include some noise of course). Audio manipulations inside the computer are typically done on a float representation of the audio data, not fixed bits like in hardware. There is no significant loss of bits until you start doing volume control. Most volume is controlled over the range of 0dB to -40dB and in the value stays exact until you need to covnert back to a fixed bit representation. Even 40dB of attenuation is only going to result in a loss of 6 to 7 bits of output data. You are still left with at least CD quality data when the playback level is down to a whisper and the amount of resolution that is left over is still quite high. It will be plenty compared to the room S/N when the playback level is low. As you turn up the volume, you gain resolution and dynamic range as there is less bit loss from the volume-change process.
Inside the computer, data manipulation is just multiplication and is exact because it is done on floating point data. There is also no added distortions or noise while inside the computer. Therefore the channel balance when doing manipulations on stereo signals remains perfect. I have yet to see an analog system having that sort of characteristic, even with all of the tweaks and such that have been used with digitally controlled analog volume controls over the years. This is certainly not a new topic.@CharlieLaub I'm afraid I don't see the point. This "wasted development" as you call it is certainly not wasted in my case. I do DIY as a hobby and I like learning new things. So all this "development" is not a waste for me.
I'm not sure if you mean that ADC, etc. has "perfect channel-matched attenuation" and the Muses doesn't. That would be an unfair statement because the stereo channels of the Muses can be controlled very precisely by the firmware and code of an MCU. Attenuation in the Muses is not digital either. It is merely controlled digitally while attenuation is done with a resistance ladder circuit, much like a potentiometer with variable resistance, but with very precise and small steps. 231 steps if gain is not used, and more steps if external opamps are used for gain.
If I misunderstood your "perfect channel-matched attenuation", please enlighten me.
It says right in the Muses datasheet that I just opened from the link in post #1 of this thread that the channel matching error is 0.5 to 1dB depending on level, e.g. mismatched to this level. It's the same problem with all of these types of devices and was the same problem 10-20 years ago whether we are talking resistive ladder, VCA, etc.
It says right in the Muses datasheet that I just opened from the link in post #1 of this thread that the channel matching is 0.5-1dB depending on level, e.g. mismatched to this level. It's the same problem with all of these types of devices and was the same problem 10-20 years ago whether we are talking resistive ladder, VCA, etc.
Ok, point taken.
I have been listening to my system via Muses attenuation for some days and I can't say I have heard any mismatch - not that I was listening for any. Maybe if it's measured, it would be glaringly obvious. I'm now upset that you made me aware of it. 😡 Just kidding!
PS: If it's a consistent mismatch throughout the volume range, it's easily compensated for with a balance setting, which I'm building into my attenuator anyway. And if it's not consistent, it's still possible to do curve fitting after some tests, since I have access to the code.
Ok, you're right, it's not half the bits lost, but 6-7 enough for the next stage where a "few" more are lost. Enough in case your audio track is for example 16-bit to hear the difference. It all depends on hv : ) I definitely accept sw solution! And if it is possible to transfer digital bits directly to the speakers, then better! One of the reasons for ddpd development.
Post 13 is the last analog thing I going to develop, the thing is allready developed but without analog relays, I found that resolution is leaked inside max14667 so I want to try to add analog relays but now controled by max. and want to try all the revised things with Hypex Nilai and also with old UCD modules, definitelly all the next things will be fully ddpd concept oriented.. I lost a lot of my free time to analogy and never got fully satisfied. Analogy and digitaly simply just don't go together wel. Tthe only my full satisfaction was sound of ddpd.
Post 13 is the last analog thing I going to develop, the thing is allready developed but without analog relays, I found that resolution is leaked inside max14667 so I want to try to add analog relays but now controled by max. and want to try all the revised things with Hypex Nilai and also with old UCD modules, definitelly all the next things will be fully ddpd concept oriented.. I lost a lot of my free time to analogy and never got fully satisfied. Analogy and digitaly simply just don't go together wel. Tthe only my full satisfaction was sound of ddpd.
Last edited:
Ok, point taken.
I have been listening to my system via Muses attenuation for some days and I can't say I have heard any mismatch - not that I was listening for any. Maybe if it's measured, it would be glaringly obvious. I'm now upset that you made me aware of it. 😡 Just kidding!
PS: If it's a consistent mismatch throughout the volume range, it's easily compensated for with a balance setting, which I'm building into my attenuator anyway. And if it's not consistent, it's still possible to do curve fitting after some tests, since I have access to the code.
The problem is (if I am remembering correctly) that the deviations are not consistent and may be different for each IC, so you probably need to run a calibration for each one individually. Trying to correct small deviations via a balance setting is clever. How does the balance control work - is that separate circuitry or does it use the same attenuation chip?
BTW, are you aware of the old PGA chips for volume control? Eg. PGA2311:
https://www.ti.com/lit/ds/symlink/pga2311.pdf
I once owned a preamp that used this chip and besides being a short-lived cheap asian product it worked well.
PS: If it's a consistent mismatch throughout the volume range, it's easily compensated for with a balance setting, which I'm building into my attenuator anyway. And if it's not consistent, it's still possible to do curve fitting after some tests, since I have access to the code.
Just set independently volume left, volume right : )
The problem is (if I am remembering correctly) that the deviations are not consistent and may be different for each IC, so you probably need to run a calibration for each one individually.
That's only a concern if I would be considering selling commercially. At this stage I only intend building for myself and a few friends.
Trying to correct small deviations via a balance setting is clever. How does the balance control work - is that separate circuitry or does it use the same attenuation chip?
With the Muses, left and right channels can be addressed independently. Balance is handled with a separate variable holding the amount of balance which can be dialled in either via IR remote or rotary encoder knob on the front panel. The software can either treat balance as a percentage of attenuation (preferred method), or a fixed number/fraction of dB's.
BTW, are you aware of the old PGA chips for volume control? Eg. PGA2311:
https://www.ti.com/lit/ds/symlink/pga2311.pdf
I once owned a preamp that used this chip and besides being a short-lived cheap asian product it worked well.
I'm aware of the PGA chips, but not the PGA2311 in particular. Never used one. I think I recall Wayne using, or even preferring PGA attenuator chips at one stage, but I can't be sure of it.
- Home
- Amplifiers
- Pass Labs
- Digital Control of Attenuation – Repository for DIY