SW Volume Control

New to XMOS and XCore? Get started here.
AlexAdvice
XCore Addict
Posts: 149
Joined: Sun Feb 23, 2014 11:30 am

SW Volume Control

Post by AlexAdvice »

Hello.
This may be a stupid question, but what is the easiest way to implement software volume control in my situation?

I have XU208 device, Ref.Design 6.15.2, xTIME Composer Studio (Community_14.1.2)
I have the variable: unsigned char adc_vol;
Doesn't matter how I change it, this is the volume level, 0..255
In current project I use this variable to control volume in AK4493 using SPI interface, everything works fine, but I want to make simpler design using PCM5102A, where there is no internal volume control, so the only way is to implement it in software.
No HID, no volume control from PC required.
Also I do not have any free core in the current firmware.

Thank you.
User avatar
fabriceo
XCore Addict
Posts: 244
Joined: Mon Jan 08, 2018 4:14 pm

Post by fabriceo »

Hi,
I suggest you do a workspace search for the keyword "OUTPUT_VOLUME_CONTROL" and you will find all the area where the volume is updated by software, based on the USB volume change. then you can certainly adapt the code by copy pasting some area and enabling them with another keyword "MY_VOLUME_CONTROL", using a global variable that you can read with an assembly statement or with the GET_SHARED_GLOBAL(x, g) macro defined in xc_ptr.h

hope this helps , but unfortunately no free lunch!
fabriceo
AlexAdvice
XCore Addict
Posts: 149
Joined: Sun Feb 23, 2014 11:30 am

Post by AlexAdvice »

Thanks.