Volume control (digital attenuator) for USB

With something like this as SPDIF input I think the master clock out can be used as masterclock on STM32F series audio path.
WONDOM | STORE

But as you see from documentation it is all somewhat complicated and maybe explains why it is not easily obtained in 2021 even if digital external attunation sounds simple
 
Last edited:
Yes please share it. On what hardware does it run?

It is a Python script that is designed to run on a raspberry pi running CamillaDSP. I use a RPi4 running Ubuntu Server 21.04 64 bit. I should mention I am not a programmer and have only recently started playing around in Python so I am very open to improvement suggestions.

CamillaDSP has a really nice Python library (pycamilladsp) so it is a very easy to pull a variety of information from CamillaDSP.

The display I am using is a NHD-2.7-12864WDW3 which is a 128x64 pixel OLED using a SSD1322 controller. Newhaven Display provides a nice datasheet that summarizes how to connect display pins. I have it connected using 8 bit 6800 parallel and the script identifies how the pins are connected to the RPi. The display is powered from the RPi 3.3V pin.

Although the display is a graphic display it is currently set up to display 8 lines of 21 characters (5x7 pixels per character).

Newhaven Display has example code for a variety of displays using the SSD1322 controller but none are written in Python. As a result my code is almost entirely based on their example code but adapted to Python.

What I added is code to translate each character of a string in to 5 bytes based on a 5x7 font table. Each byte identifies which of the 7 vertical pixels are illuminated and which are not. When you send data to the display it treats each pixel as 4 bits and will write 2 pixels for every byte.

To avoid burn-in the display will go dark after 10 seconds of no volume change. Once the volume is changed the display will again illuminate (and go dark after 10 seconds of no volume change). I tried to differentiate between text that will not change (i.e. labels like "Volume: ", "Sample Rate: ", etc) and things that will change (i.e. volume level, buffer level, etc). Only the text that can change will update after the initial write to display, this reduces CPU usage and improves response time.

I added the line "@reboot python3 /pathtocode/oled8.py 1234" to crontab by running "crontab -e". This ensures that the script will run on startup.

For volume control you can either change the volume in the CamillaDSP GUI or use a remote via a FLIRC USB IR receiver. For the FLIRC IR receiver I have another python script that will update the CamillaDSP volume. This script is based on the code in the link below.

[Deprecated} Using the Flirc USB for remote control with mOde 5.4+

I run this script in a similar manner to the display script by adding "@reboot python3 /pathtoscript/flirc.py 1234" to crontab by running "crontab -e"

The only odd thing with the FLIRC script is that by default in Ubuntu Server 21.04 the owner of "/dev/input/by-id/usb-flirc.tv_flirc-if01-event-kbd" is root. I adjust this by adding "@reboot chown USERNAME /dev/input/by-id/usb-flirc.tv_flirc-if01-event-kbd" to crontab by running "sudo crontab -e".

I will likely modify the script down the line to display less information and use a larger font for volume but have not got around to it yet.

Michael
 

Attachments

  • display.zip
    6 KB · Views: 51
Now i am going tri-amped and must upgrade the 4-gang pot. Somewhat nutty to make a little box with 6-gang pots and likely there'll be tracking errors in among the pots.

what's the problem?
why "digital"?

best adjust the volume direct before the analog amps
...
try PT2325 6 Channel Volume Control_2010
you find a project on this forum
If you need a remote, use a motor-poti with a AtmelAVR

If you need/like to have more look for pga2310 ...
 
Thanks. Very interesting.

Here's a data sheet I found for PT2259, two channels. From 2002 (which isn't old compared to much of my gear) but not much to see about fidelity, tracking precision, etc.

https://www.digchip.com/datasheets/download_datasheet.php?id=792654&part-number=PT2259-S

Also missing is power consumption. Since it operates on 4-9 VDC, might work just fine and be real convenient with a battery and maybe even with no on-off switch (sometimes known as the "no-ffo switch" if mounted upside down as I sometimes do).

BTW, I have a reasonably nice set-up now: DSP and amps have fixed gain but the volume control is in the laptop. I found the audio app "VLC" had a big use-friendly screen interface and - amazing to tell - VLC and iTunes work with an old Apple IR remote control I found sitting around (newer Mac laptops do not have IR sensors).

But some relevant apps - such as Safari browser and my music database and server FileMaker - do not permit volume adjustment except in the peripheral device itself. Nice that VLC has real smart search functions which work with my large music collection folder, so it is almost as easy to use as FileMaker.
 
Well, what do you know, just as I am finding quasi-analog ways of controlling volume after the DSP (thanks everybody), I am now discovering various apps that are very helpful upstream in the laptop.

I've been trial testing two smartphone apps (iPhone for me) that do quite good jobs as remote controls for iTunes player and VLC player. Pity nothing yet for FileMaker, which is my core database.

B.