Advanced volume control via RS232
#1
Question 
Dear XBMC Community,

I already searched the forums for the following question, but I did not find any answer.

For using my external amplifier I'd like to deactivate the internal (digital) Volume Control and instead use a microcontroller, which controls the volume via a PGA2311 between the PC and the amplifier. This should maximize the signal/noise ratio and improve the dynamical range of the sound card.

For this I'd like to archieve:

1. Control the Volume via XBMC and XBMC Commander from iPod/iPhone
2. LEAVE the volume at Max Level in XBMC
3. Send a signal VIA RS232 to the controller
4. Optional: Receive input from the controller and show the "real" volume in XBMC

I'm not sure how to achieve this behaviour. Is it possible to catch Volume events in some Python Script? Do I need to write a new Plugin?

Thanks in advance,

Rob
Reply
#2
I love to see how you do this ...

I was able to do something like this (not the best way) ... but I had to do it in windows and I was using a PS3 blue tooth remote.

I was using a app I found on the forum to interface with the ps3 remote, then I set one of the keys to a hot key for a little app to talk to my microcontroller instead of mapping it to the volume in the xbmc enviroment
Reply
#3
As i know the event server in XBMC sends no events. The server receives events only.
http://wiki.xbmc.org/?title=EventServer
I guess you have to poll the volume with JSON-RPC.
Which OS do you use?
Reply
#4
Hi,
thanks for your support so far. I am using Windows at the moment, because I am testing XBMC on my main computer, but if there were any advantages in using Linux I'd be open for that, too. I'll need some time to check out on JSON-RPC and the Event Server. After that, there will most certainly be further questions.
cu
newcmbx
Reply
#5
newcmbx Wrote:Dear XBMC Community,
This should maximize the signal/noise ratio and improve the dynamical range of the sound card.
hope you dont mind my chiming in at this point. I have recently been investigating myself into the possibilities of using XBMC (or a computer) as a source for high quality sound, and started wondering how to handle (remote) volume control. I also concluded that, when using an analog amp, it would probably be best to let it handle volume control instead of manipulating the signal on the digital side.

After a while, I decided that there was no good solution, apart from doing hacks like you propose (which doesnt mean it is no good or wont work for you). I was amazed that even digital amps that were designed for computer input (with integrated USB DAC) did not adress this issue, but came with a (sometimes not even remote controllable) volume knob.

I have finally settled for a fully digital amp that has NO volume control of its own, and takes input from the computer via USB. My expectation is, as the amp is all-digital, the volume control on the computer side wont hurt the overall process. Any thought?

regards,
Chris
Reply
#6
A fully digital volume control (even with an analog amp) is not generally bad. If you have a 16 Bit signal, which is common for CD-audio, and you are using a 24Bit Soundcard, you can use the odd 8Bit (in reality it is less, because the noise floor is usually bigger than the least significant Bit at consumer products) for your Volume control without loosing any Dynamic Range. The important point is where the volume control is done. In my case there will be some signal processing between XBMC and the audio output of the sound card. A volume control should be the last step in the signal processing, so it had to be outside of XBMC anyway. Based on this thoughts a analog volume control seems for me to be the most versatile solution. Furthermore it seems to be the cheapest and most feasible solution due to my personal skills.

best regards
newcmbx
Reply
#7
newcmbx Wrote:A volume control should be the last step in the signal processing
could you elaborate a little more about this? As I mentioned, in my setup, volume control is done before the signal leaves the computer, and thus is the first step of processing. does this necessarily hurt? Why?

regards,
Chris
Reply
#8
I will try to give a short explanation, but I am still learning about digital signal processing, so I can't guarantee it is 100% correct.

A digital volume control reduces the bit depth of an signal, so you are loosing information. This is not an issue because if you have a 16 Bit signal, and your signal processing works with 24 Bit, you have can theoretically attenuate your signal by 48dB without loosing any information ( realistic would be 28dB, due to the limits of AD/DA-conversion). As long as you remain in this range it is not an issue where the volume control is done. But if you have additional signal processing, you are using lets say 10dB of this headroom for your equalizations, which leaves you with 18dB you can use for the volume control, which might be too little. If the volume control exceeds the limits I mentioned above you are loosing information. this is not necessarily hearable, but with signal processing behind it, the errors may add up.

So, I hope everything is correct so far.
cu
newcbmx
Reply
#9
what would be interesting now is how volume control in the OS actually works. If it directly talks to the sound card, instead of manipulating the data stream, then it would be up to the amp (which in my case acts as a USB-attached sound card to the OS) to handle this in an optimal fashion (which I assume it does).

This again begs the question, how this applies to S/PDIF output, in which case the OS talks to the on-board sound card, which passes on the stream to the amp.
Reply
#10
heres a statement from the J.River website, which I find interesting:
Quote:if you need to manipulate the sound, you can use JRiver to modify playback. Upmixing, downmixing, bitdepth, speaker control. Because the audio path is fully 64 bit, any adjustments to volume, bitdepth and sample-rate are mathematically lossless.
Reply
#11
Offering some thought for your project.


I currently run a setup similar to what you are asking, maybe two setups similar to what you want one I am running a digital link between the other is analog.

First from what I understand from your post is for the audio coming from your cd player or whatever source to be passed into a pc, and or you would like you audio from pc to be processed through your amp. Either way you would like a solution which is controllable through the pc.

This is how I do it maybe it could help out on your thoughts. Also I would like to add that I use a 10" windows ce touchscreen tablet ( $100 or less on ebay) to access a complete home automation website that I built which interacts with XBMC and some other cool features ( another thread ).

ANALOG:

Running on dual core pc is a 24bit sound blaster sound card. The amplifier is being controlled via rs232 and a simple html based webpage using eventghost. I run two pairs of monster cable ipod adapters 1/8" inch stereo one going into the pc sound in another coming from the pc sound out.

Via Eventghost plugins serial & webserver and a custom made integrated html page, I setup volume plus all inputs and outputs for control of the amp.


DIGITAL: Almost the same just slightly different

Running on dual core pc is a asus sound card. The amplifier is being controlled via TCPIP ethernet connection and a html based webpage using eventghost. I run two digital optical cables one going into the pc sound in another coming from the pc sound out.

Via Eventghost plugins event sender & webserver and a custom made integrated html page, I setup volume plus all inputs and outputs for control of the amp.

Both work flawlessly for me hopefully this may help with your project
Reply
#12
All:

Adding my two cents to this post.

You'll get the best SNR by keeping the source at full level and letting the receiver adjust its volumn levels either in its digital or analog domain.

I am also interested in some sort of scheme that would allow me to passthrough control my amplifier via RS232. So if the Kodi "receives Events" where can I find the code that intercepts and perhaps then dispatches commands based on those received events......

Peter
Reply

Logout Mark Read Team Forum Stats Members Help
Advanced volume control via RS2321