Volume control with Atrix volume keys
Edward Kearney (2033) 13 posts |
I could not find a way to use the volume keys on my lapdock’s keyboard to control the volume in RISC OS. Please let me know if there is something already out there… I have used this problem as an opportunity to learn some BASIC and more about RISC OS. I have created 3 small tools (!VolumeUp, !VolumeDown, and !Mute) that can be used with !HID and run whenever a chosen keyboard key is pressed. It keeps in sync with the slider in !Configure. This solution does not work in the background, so the volume keys do not work during full-screen games. Here is the basic script for increasing the volume: VolumeUp.bas You can see some commented-out lines, near the end, to change the script to decrease volume, or mute the sound instead. Any feedback, suggestions, etc appreciated as this was just thrown together. Can something like this run in the background so that it will work during full-screen games? (do I need to create a module?) Is there a way to interface these special keyboard keys without !HID? Is it bad form to edit !Boot.Choices.Boot.PreDesk.SndSetup? (this was the only way I could find to stay in sync with Configure) |
Steve Pampling (1551) 8172 posts |
I think your “full screen games” are probably single tasking and control the sound levels themselves – hence the Wimp based HID settings having no effect. With regard to volume and modules – had you looked at the output of *h. soundchannels ? |
Jon Abbott (1421) 2651 posts |
As Steve mentioned, you would need to implement your code as a Module for it to work within games – they won’t be multi-tasking. I did something similar for my pi-top, using the volume keys to adjust the volume via Sound_Volume |
Edward Kearney (2033) 13 posts |
Thank you both. Yes my “full screen games” comment was grasping for the correct term and failing. I’ll look in to Module authoring as the next step. Jon, I did try your pi-top tools: just in case they would magically work for my lapdock! (They didn’t) I opted to use MixVolume instead of Sound_Volume so that I could keep in sync with the volume slider in Configure. Also thank you very much for ADFFS Jon, it is due to starting up Pandora’s Box at 2 in the morning that I have a real need for the volume down key to work :D |
Jon Abbott (1421) 2651 posts |
Ah, in that case I could add volume control keys to ADFFS. It would have to use Sound_Volume though as SoundCtrl_SetMix only seems to be available on specific builds. EDIT: Ignore that last bit. ADFFS is emulating the IOC hardware, so I’ll apply a volume setting internally |
Edward Kearney (2033) 13 posts |
An internal volume setting for ADFFS would be great. I have done a bit more testing and it seems that using !HID with my scripts while a single-task app is running: the scripts do get run when the mapped key is pressed/held – and although real-time changes to *MixVolume (or *Volume) are not honoured, the change to the SndSetup file is honoured upon closing of the app. Relaunching the app will be at the adjusted MixVolume. Is it possible to also have some sort of “pass-through” volume control: for “MixVolume pass-through” it would listen for changes to SndSetup (or SWI/RAM?) and translate "volume at launch of app : “current volume” → internal ADFFS volume percentage… or potentially something less convoluted? Sorry if my ignorance to the workings of RISC OS made that awful to read, or have otherwise made leaps in logic! |
Jon Abbott (1421) 2651 posts |
I believe what I need to do is add a SharedSound driver to ADFFS and translate the emulated u-law audio DMA to 16 bit linear. SharedSound and SoundCtrl should then handle the volume when it’s mixed and it should appear in Sound with its own volume slider. Although 16bit conversion is currently done by SharedSound itself (SoundDMA feeds into SharedSound), it doesn’t appear to apply a volume setting during the mixing stage – I’m not sure if that’s a bug, by design, or something I’m doing wrong. As far as I can determine SoundCtrl doesn’t have a dedicated volume for 8-bit u-law audio from SoundDMA. Long story short, SoundDMA sourced audio currently relies on the game fill routine applying a volume though the volume lookup table the OS provides. Games generally don’t do that as they’re coded for speed, not functionality. A question to the OS devs, is there a reason SoundCtrl isn’t in the IOMD build? |