tomek-o / tSIP

SIP softphone
149 stars 32 forks source link

Lua command SwitchAudioSource() and SwitchAudioPlayer() problem #50

Closed hillxrem closed 1 month ago

hillxrem commented 1 month ago

I believe SwitchAudioSource() and SwitchAudioPlayer() are commands that change the audio input/output device during a call.

However, when I run this command, the default Windows device becomes the audio input/output device of the call.

The specific command I tried is as follows SwitchAudioSource(“winwave2”, “microphone (USB Audio)”) and SwitchAudioSource(“winwave2”, "USB Audio”) SwitchAudioPlayer(“winwave2”, “speaker (USB Audio)”) and SwitchAudioPlayer(“winwave2”, “USB Audio”)

I'm trying to switch input/output devices from "USB microphone" to "USB Audio" during a long call. The device name is obtained with GetAudioDevice().

tomek-o commented 1 month ago

SwitchAudioSource(“winwave2”, “microphone (USB Audio)”)

Are you sure device name is starting with lowercase? This seems unusual. "Microphone" here is not used as a common noun but it is part of the name created by Windows. Same device names are also visible on the list in Audio I/O settings after selecting same audio module type. Side note: there are also dedicated button types for switching audio devices, for manual switching they might be easier to manage (few buttons next to each other with names and maybe some bitmaps).

If there would be "real" speaker involved: see https://tomeko.net/software/SIPclient/howto/troubleshooting.php, acoustic echo cancellation.

hillxrem commented 1 month ago

Thank you for support. Sorry, as it turns out, it was not a tSIP issue. The reason for the device switching not working was the character encoding. (The real device name in my country was “マイク (USB Audio)”, but I was dealing with this in UTF-8.)

And also thanks for the side note. Now I am trying to use tSIP with several people, and because of the different device names they are using, I need to get the device name dynamically, which I find difficult to handle with the dedicated button type.

tomek-o commented 1 month ago

I had a problem with "unstable" device name myself (maybe because of USB port changing) and I've used this kind of script: https://tomeko.net/software/SIPclient/howto/update_settings.php to select proper device at startup (modifying own configuration at startup in this case). Few lines of code could be stripped from it if using later added local devices = GetAudioDevicesList(moduleName, direction) function returning array of names.