Win How to switch audio output easily?
#31
can anyone please provide a step by step instruction for beginners (windows 8) how to switch between two audio outputs?
Reply
#32
Follow the instructions I gave to roby77, I included windows info alongside the linux info. Steps are pretty much the same - get the json-rpc commands you want working from the command line, then put those commands into a batch script to toggle between the two (or even automate it), then launch the script how you want - eventghost is good for launching commands from a remote and advanced launcher addon is good for launching commands via xbmc's gui.
Reply
#33
great tip...
can this could be done for a much easier toggle ?
-> just switch between HDMI audio output (an amp that handle all HD audio formats)
and OPTICAL out soundcard (that "only" handle DD5.1)
Many thanks !
Reply
#34
Sure, there are examples in post #28
Reply
#35
great, but seems that i'm a little too noob for that Wink
all my thing would be to launch a script with my remote (already got evenghost) to switch between HDMI / optical outputs...
Reply
#36
hi,
i found a very simple and very comfortable way to switch between two (or more) audio devices. you need a little program called audioswitch. just copy the files (only 100kb) in a folder you want, there is no need to install. below you find a link with detailing instructions. beside this instruction i have done the following (win 8.1, x64):

disable all audio devices in WINDOWS audio device manager you dont need
in xbmc audio settings (device) turn on "direct sound:default"
within audioswitch diable the gui, otherwise xbmc will loose focus

instruction (post 226): http://forum.team-mediaportal.com/thread...st-1038068

for me this is working very good. i also can switch the audio device while music or a movie is playing. i dont need to stop movie/music.
Reply
#37
Thank you very much Ed76, works - to a degree - here too (Win8.1pro, Gotham 13.1, Intel DN2820FYKH, C-Media CM106 USB audio controller). Great find!

What XBMC release are you on?

3 notes to add:

1. Left-clicking the system tray icon might not bring the Audio Switch config panel right up. After left-clicking the icon, press F1 to bring up the config panel. If F1 is a hotkey is use by XBMC, you might want to close down XBMC during the config.

2. If you use "Full-screen window" mode in XBMC, you can keep the Audio Switch OSD - it gives you a small overlay in the upper left region for about 1 second, dosplaying which output is active. The "focus issue" only applies to XBMC "true fullscreen".

3. Your usage may vary - but in my case with 3 outputs: 5.1 analog to AVR, S/PDIF to AVR and stereo analog to headset/speaker output - I experience the follwing: With Passthrough enabled in system settings, you'll not be able to get sound out from a non- [insert bitstream codec or number of channels here] capable unit. Eg: You won't get any audio out on a 2.0 output, if playing a source with a 5.1 audio track. And - even with Passthrough deactivated, I still have to stop playback to for output "toggle" to take effect. I guess various audio settings might affect this.

Sad to say, teeedubb - the "script route" was a bit over my head, too.
If I have helped you or increased your knowledge - please click the plus to the left below to give thanks
Reply
#38
to switch the audio output while media is playing you have to start audioswitch with admininstrator rights (win 8.1).

i use xbmc 13.1. yes, with windowed mode you dont loose focus but what i have read here in various forum posts the true fullscreen mode will give a better picture....
Reply
#39
Ah okay, didn't know / pick up on that. Will try.

In your set-up, are all your (AudioSwitch selectable) components multichannel-capable? Or maybe you do software decoding..?
If I have helped you or increased your knowledge - please click the plus to the left below to give thanks
Reply
#40
@pr0xZen yeah using json can be a bit confusing as the commands arent very human readable (plus in windows the command needs to be escaped) and the error replies can be cryptic, but getting the json command right is the hardest part, and once you have them putting them in to a toggle script shouldn't be too hard as there are plenty of examples on the net. Plus it seems as it will give you a finer degree of control than the audio switcher application, eg number of channels, codecs, up mixing etc...

On a side note I recommend that you familiarise yourself with json because its a very powerful tool, allowing you to stop/start addons (turning boblight on/off via remote), running addons like artwork downloader automatically in the background, making xbmc display a particular folder after launching a application that quits xbmc via advanced launcher or displaying on screen notifications, plus much more.
Reply
#41
Here is a autohotkey script to automatically change audio settings in xbmc based on whether the AVR is pingable or not. Its a bit different to the linux one, as it has to run a few more commands - I mainly use windows for games and need this script to automatically reset my gpu when I power cycle my avr, changing xbmcs audio settings is a nice bonus.

Code:
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#SingleInstance Force

;check or existing avr* files
IfNotExist, C:\Users\xbmc\AppData\Local\Temp\avr.on
    IfNotExist, C:\Users\xbmc\AppData\Local\Temp\avr.off
        ;no avr.* files found, assuming avr off
        FileAppend, This is a blank line`n, C:\Users\xbmc\AppData\Local\Temp\avr.off


;loop to ping for avr connectivity and adjust windows/xbmc settings to suit.
Loop
{
        Ping("192.168.1.201")
        If ErrorLevel
        {
                ;avr no ping
                ;Msgbox, avr not pinging.
                IfExist, C:\Users\xbmc\AppData\Local\Temp\avr.off
                {
                        ;Msgbox, avr.off exists
                        Sleep, 1000
                }
                else
                {
                        ;Msgbox, no avr.off exists
                        Msgbox, About to reset GPU due to AVR`, Save everything and press OK
                        Run, schtasks /run /TN "win-audio-reset",,Hide
                        IfExist, C:\Users\xbmc\AppData\Local\Temp\avr.on
                                FileDelete, C:\Users\xbmc\AppData\Local\Temp\avr.on
                        FileAppend, This is a blank line`n, C:\Users\xbmc\AppData\Local\Temp\avr.off
                        Sleep, 1000
                        Run, C:\emulation\emulators\killapp.bat,,Hide
                        WinWait, XBMC ahk_class XBMC
                        Sleep, 10000
                        Run, %comspec% /c c:\emulation\scripts\curl.exe -i -X POST -d "{\"jsonrpc\":\"2.0\"`,\"method\":\"Settings.SetSettingValue\"`, \"params\":{\"setting\":\"audiooutput.audiodevice\"`,\"value\":\"WASAPI:default\"}`,\"id\":1}" -H "content-type: application/json;" http://localhost:9191/jsonrpc,,Hide
                        Run, %comspec% /c c:\emulation\scripts\curl.exe -i -X POST -d "{\"jsonrpc\":\"2.0\"`,\"method\":\"Settings.SetSettingValue\"`, \"params\":{\"setting\":\"audiooutput.channels\"`,\"value\":1}`,\"id\":1}" -H "content-type: application/json;" http://localhost:9191/jsonrpc,,Hide
                        Run, %comspec% /c c:\emulation\scripts\curl.exe -i -X POST -d "{\"jsonrpc\":\"2.0\"`,\"method\":\"Settings.SetSettingValue\"`, \"params\":{\"setting\":\"audiooutput.passthrough\"`,\"value\":false}`,\"id\":1}" -H "content-type: application/json;" http://localhost:9191/jsonrpc,,Hide
                        Run, %comspec% /c c:\emulation\scripts\curl.exe -i -X POST -d "{\"jsonrpc\":\"2.0\"`,\"method\":\"GUI.ShowNotification\"`,\"params\":{\"title\":\"AUDIO OUTPUT\"`,\"message\":\"TV\"`,\"image\":\"c:/emulation/artwork/Speaker3.png\"}`,\"id\":1}" -H "content-type: application/json;" http://localhost:9191/jsonrpc,,Hide

                }
        }
        else
        {
                ;avr ping
                ;Msgbox, avr is pinging.
                IfExist, C:\Users\xbmc\AppData\Local\Temp\avr.on
                {
                        ;Msgbox, avr.on exists
                        Sleep, 1000
                }
                else
                {
                        ;Msgbox, no avr.on exists
                        Msgbox, About to reset GPU due to AVR`, Save everything and press OK
                        Run, schtasks /run /TN "win-audio-reset",,Hide
                        IfExist, C:\Users\xbmc\AppData\Local\Temp\avr.off
                                FileDelete, C:\Users\xbmc\AppData\Local\Temp\avr.off
                        FileAppend, This is a blank line`n, C:\Users\xbmc\AppData\Local\Temp\avr.on
                        Sleep, 1000
                        Run, C:\emulation\emulators\killapp.bat,,Hide
                        WinWait, XBMC ahk_class XBMC
                        Sleep, 10000
                        Run, %comspec% /c c:\emulation\scripts\curl.exe -i -X POST -d "{\"jsonrpc\":\"2.0\"`,\"method\":\"Settings.SetSettingValue\"`, \"params\":{\"setting\":\"audiooutput.audiodevice\"`,\"value\":\"WASAPI:default\"}`,\"id\":1}" -H "content-type: application/json;" http://localhost:9191/jsonrpc,,Hide
                        Run, %comspec% /c c:\emulation\scripts\curl.exe -i -X POST -d "{\"jsonrpc\":\"2.0\"`,\"method\":\"Settings.SetSettingValue\"`, \"params\":{\"setting\":\"audiooutput.channels\"`,\"value\":8}`,\"id\":1}" -H "content-type: application/json;" http://localhost:9191/jsonrpc,,Hide
                        Run, %comspec% /c c:\emulation\scripts\curl.exe -i -X POST -d "{\"jsonrpc\":\"2.0\"`,\"method\":\"Settings.SetSettingValue\"`, \"params\":{\"setting\":\"audiooutput.passthrough\"`,\"value\":true}`,\"id\":1}" -H "content-type: application/json;" http://localhost:9191/jsonrpc,,Hide
                        Run, %comspec% /c c:\emulation\scripts\curl.exe -i -X POST -d "{\"jsonrpc\":\"2.0\"`,\"method\":\"Settings.SetSettingValue\"`, \"params\":{\"setting\":\"audiooutput.passthroughdevice\"`,\"value\":\"WASAPI:default\"}`,\"id\":1}" -H "content-type: application/json;" http://localhost:9191/jsonrpc,,Hide
                        Run, %comspec% /c c:\emulation\scripts\curl.exe -i -X POST -d "{\"jsonrpc\":\"2.0\"`,\"method\":\"GUI.ShowNotification\"`,\"params\":{\"title\":\"AUDIO OUTPUT\"`,\"message\":\"AVR\"`,\"image\":\"c:/emulation/artwork/Speaker3.png\"}`,\"id\":1}" -H "content-type: application/json;" http://localhost:9191/jsonrpc,,Hide

                }
        }
}

;Ping Function
Ping(IPADDRESS)
{
Runwait,%comspec% /c ping -n 1 %IPADDRESS%>C:\Users\xbmc\AppData\Local\Temp\ping.log,,hide
fileread , PingLog, C:\Users\xbmc\AppData\Local\Temp\ping.log
ifinstring , PingLog, Destination host unreachable
{
  ErrorLevel = 1
}
else
{
  ErrorLevel = 0
}
;Msgbox, echo %ErrorLevel%

}

Some notes: the lines with 'win-audio-reset' calls a windows scheduled task to reset my GPU. It needs to be run as admin and using task scheduler will hide the uac popup. See http://www.avsforum.com/forum/26-home-th...-then.html
The lines with 'kill-app.bat' is to kill xbmc (plus emulators) and restart xbnc as resetting the GPU crashes any running 3d applications.
In the windows command prompt, inside the json string " needs to be escaped with a /. When using autohotkey , needs to be escaped everywhere with `.
Also the script will show a message box before resetting the GPU to prompt the user to save everything.

This hasn't been as thoroughly tested as the Linux script but works well from my limited testing. Plus it contains enough info to give yo a idea of how to make a toggle script.
Reply
#42
So I'm clear on this: Does this script only function on an AVR with NW connectivity? - also I'm not quite sure what you mean by , needs to be escaped everywhere with ` (autohotkey). Maybe I'm just slow today, but I want to make this work right.
If I have helped you or increased your knowledge - please click the plus to the left below to give thanks
Reply
#43
(2014-06-26, 23:37)pr0xZen Wrote: Ah okay, didn't know / pick up on that. Will try.

In your set-up, are all your (AudioSwitch selectable) components multichannel-capable? Or maybe you do software decoding..?

i switch between hdmi audio (tv) and my stereo speakers. for me all is working fine
Reply
#44
(2014-06-28, 17:39)Ed76 Wrote: i switch between hdmi audio (tv) and my stereo speakers. for me all is working fine

You use passthrough?
If I have helped you or increased your knowledge - please click the plus to the left below to give thanks
Reply
#45
(2014-06-29, 05:24)pr0xZen Wrote:
(2014-06-28, 17:39)Ed76 Wrote: i switch between hdmi audio (tv) and my stereo speakers. for me all is working fine

You use passthrough?

no
Reply

Logout Mark Read Team Forum Stats Members Help
How to switch audio output easily?0