tSIP softphone: audio device switching
Input and output audio device switching during call was added (following baresip) in tSIP 0.1.51.
Two new button types were added - one switching output device and one for input device. Each button instance (for switching back and forth between different devices) specifies audio module used (Portaudio, winwave or in case of input selection: wave file) and particular device (or wave file) to switch to.
Switching audio outputs
Three buttons defined, each one with separate output device (SPDIF / speakers / extra USB sound card).
Switching audio sources
As of 2024, for each tSIP release there are two separate binaries: with and without ("basic") video support.
Basic version allows switching audio source to selected physical device (microphone or line input), silence/nullaudio (slightly redundant considering there is also Mute button) or wave file. For wave files PCM S16LE or G.711 mono format is required. Wave files are resampled when reading, but to keep their size minimal they should match best codec to be used, e.g. 16000 sps for G.722. Handling end-of-file might attention - it is treated as audio error and in default configuration it would disconnect the call. If this is not the desired behavior, there is a setting to ignore end-of-file allowing to handle it with script like in playing audio files example.
Version with video contains additional FFmpeg-based avformat input module with very wide audio format compatibility. It can play mp3, audio track from mp4, ogg, aac and even http-based internet radio stations. Note that with current tSIP version (0.3.05) there is one major difference from module playing wav files (aufile) - with avformat file is looped when end-of-file is reached.
Usually one of the buttons would be configured to switch back to default audio device. To avoid duplicating device configuration (one in Settings window, one in button configuration) Lua SwitchAudioSourceToConfigured() function can be used.
Use cases
- "speakerphone" - plain audio output switching
- in main application configuration ("Audio I/O") set audio device with headphones as audio output
- define button with "speakerphone" caption switching to second audio divice (e.g. cheap USB sound card connected to speakers)
- optionally define "headphone" button for switching back to first audio device
- "answering machine" - voice mail with option to switch call to microphone / live call like with old tape-based auto-attendant devices
- follow instructions to configure softphone as voice mail
- define button to switch from audio file to real audio input (e.g. microphone)
- pick up call answered by voice mail at any time
- using wave file to pass some information (pre-recorded message) to called persons
- use regular configuration (microphone as input)
- define button to switch input to wave file (or many buttons of that type for different wave files)
- note: call would be disconnected if playback would reach end of wave file; softphone requires S16LE, 8ksps uncompressed wave files
- custom music on hold
- define buttons switching to wave file and switching back to regular audio input
- make sure wave file is long enough to avoid call disconnection
- note: multiple buttons with different wave files assigned can be defined
- call on hold can still be heard and recorded continuously
Back to tSIP softphone