Recent

Author Topic: Redirect playback to unplugged output on Windows  (Read 12420 times)

MementoMojito

  • Jr. Member
  • **
  • Posts: 63
Redirect playback to unplugged output on Windows
« on: February 02, 2017, 09:49:24 pm »
Hi,

I know it's quite a general question and it's not stricto sensus a Lazarus/fpc question.
Basically my project uses Butt to stream any sound played on the soundcard, it works great except it's also playing on the laptop speakers for example.
I was wondering if there is any way to redirect the output to the headphone or any other unplugged output on Windows with Lazarus? Is there any open-source lib I could use? On Linux it's really trivial to do that with PulseAudio but Windows seems to be really limited in term of interfaces it offers for audio...
Any help would be really appreciated.
Thanks!


Cyrax

  • Hero Member
  • *****
  • Posts: 836
Re: Redirect playback to unplugged output on Windows
« Reply #1 on: February 02, 2017, 10:52:20 pm »
You need to install audio chipset manufacturers audio device drivers to get that kind of functionality.

MementoMojito

  • Jr. Member
  • **
  • Posts: 63
Re: Redirect playback to unplugged output on Windows
« Reply #2 on: February 02, 2017, 11:40:25 pm »
I am not sure to understand, if the soundcard is already in use the drivers are already installed right? Or am I talking about something else?
And I was secretly hoping for something a bit more high level...

Cyrax

  • Hero Member
  • *****
  • Posts: 836
Re: Redirect playback to unplugged output on Windows
« Reply #3 on: February 03, 2017, 07:18:34 pm »
Default audio device drivers installed by Windows itself may or may not contain advanced features like using headphones as separate audio device. You need to install audio chipset manufacturers device drivers for that.

Check your audio device manufacturer by using this handy utility : https://www.hwinfo.com/

MementoMojito

  • Jr. Member
  • **
  • Posts: 63
Re: Redirect playback to unplugged output on Windows
« Reply #4 on: February 03, 2017, 08:32:40 pm »
Ok thanks for the precision Cyrax, but unfortunately that's clearly not a solution as not portable at all :/
Windows is such an annoying and limited OS...

Fred vS

  • Hero Member
  • *****
  • Posts: 3158
    • StrumPract is the musicians best friend
Re: Redirect playback to unplugged output on Windows
« Reply #5 on: February 03, 2017, 10:16:07 pm »
Quote
Is there any open-source lib I could use? On Linux it's really trivial to do that with PulseAudio but Windows seems to be really limited in term of interfaces it offers for audio...

Hello.

Yoiu may use PortAudio. It is open source and multi-os (Windows included).
Pascal wrapper + examples + library are included in uos : https://github.com/fredvs/uos

Fre;D
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

MementoMojito

  • Jr. Member
  • **
  • Posts: 63
Re: Redirect playback to unplugged output on Windows
« Reply #6 on: February 04, 2017, 12:04:13 am »
Thanks alot Fred, I will have a look.
Is it possible to redirect the output without streaming from uos directly? Not that I mind too much to don't use Butt, just to know what are my options here :)

Fred vS

  • Hero Member
  • *****
  • Posts: 3158
    • StrumPract is the musicians best friend
Re: Redirect playback to unplugged output on Windows
« Reply #7 on: February 04, 2017, 01:01:48 pm »
Thanks alot Fred, I will have a look.
Is it possible to redirect the output without streaming from uos directly?

Yes.
You may use PortAudio alone, but maybe with uos it will be easier.  ;)

Fre;D
« Last Edit: February 04, 2017, 01:38:42 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

MementoMojito

  • Jr. Member
  • **
  • Posts: 63
Re: Redirect playback to unplugged output on Windows
« Reply #8 on: February 04, 2017, 07:18:02 pm »
Thanks Fred, to change the Output seems indeed pretty trivial with uos (great work btw!).
However, I am not sure how to achieve that without assigning a player to uos_AddIntoDevOut().

Fred vS

  • Hero Member
  • *****
  • Posts: 3158
    • StrumPract is the musicians best friend
Re: Redirect playback to unplugged output on Windows
« Reply #9 on: February 04, 2017, 09:01:15 pm »
Hello MementoMojito.

I did not see your code but if you are using PulseAudio, it would not be too much work to replace it with Portaudio.

You may note that uos do not use any callback method of portaudio, all is done before to give the buffer to the output
.
It is wanted to easy jump for other audio-port-libraries (like PulseAudio).

But each time that I try a other audio-port-library,... I come back to portaudio.

Indeed you may be helped by uos_AddIntoDevOut() and uos_loadlib() to decrypt portaudio.

Fre;D
« Last Edit: February 04, 2017, 09:12:24 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

MementoMojito

  • Jr. Member
  • **
  • Posts: 63
Re: Redirect playback to unplugged output on Windows
« Reply #10 on: February 04, 2017, 09:36:37 pm »
My code for Linux is really simplistic, I basically just run the command:
Code: Pascal  [Select][+][-]
  1. pactl set-sink-port @DEFAULT_SINK@ analog-output-headphones
  2.  

with TProcess.

Just to explain briefly what my project is, I basically have a RaspberryPi + DAC that acts as a server (with VLC socket interface + Icecast + a server in Python I have coded).
My client (basically a player/remote controler connected to VLC on the Pi) is coded with Lazarus, and as a source client for Icecast it uses ices2 on Linux and Butt on Windows (both with TProcess again) for streaming the input from your soundcard. Proper music files are handled by my Python server and played locally by VLC on the Pi.
So now what I want to achieve on Windows is just what I do on Linux, switch the output when you start to stream your soundcard to the Pi so you don't hear and the DAC and your laptop playign the same sound...

Fred vS

  • Hero Member
  • *****
  • Posts: 3158
    • StrumPract is the musicians best friend
Re: Redirect playback to unplugged output on Windows
« Reply #11 on: February 04, 2017, 11:40:59 pm »
Hello.

Huh, I did not understand everything...

Quote
... for streaming the input from your soundcard

Do you want to stream the input from the sound card of the server mixed with some audio ?
Or stream some audio form the server and mix it with the input of the client ?

Fre;D
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

MementoMojito

  • Jr. Member
  • **
  • Posts: 63
Re: Redirect playback to unplugged output on Windows
« Reply #12 on: February 05, 2017, 12:20:38 am »
No, I stream the soundcard from the client, so any playback on my laptop is played on the Raspberry+DAC, the server just host Icecast.
Basically the chain is as follow:

[client machine] Source Client (ices2 or Butt)  > [server]Icecast > [server]VLC

I hope it makes sense.
 

Fred vS

  • Hero Member
  • *****
  • Posts: 3158
    • StrumPract is the musicians best friend
Re: Redirect playback to unplugged output on Windows
« Reply #13 on: February 05, 2017, 07:47:37 pm »
Ha, ok.

Quote
On Linux it's really trivial to do that with PulseAudio but Windows seems to be really limited in term of interfaces it offers for audio...

I was thinking that your own audio-engine was using PulseAudio but you use vlc.
I am sorry but I dont know how to deal with audio-port via command line in Windows.

Fre;D
« Last Edit: February 05, 2017, 07:51:12 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

lainz

  • Hero Member
  • *****
  • Posts: 4449
    • https://lainz.github.io/
Re: Redirect playback to unplugged output on Windows
« Reply #14 on: February 05, 2017, 07:50:42 pm »
Ha, ok.

Quote
On Linux it's really trivial to do that with PulseAudio but Windows seems to be really limited in term of interfaces it offers for audio...

I was thinking that your own audio-engine was using PulseAudio but you use vlc.
Are you using vlc via the library or the exe ?

Fre;D

Hi Fre;D sorry for commenting here, you can take a look at Online Package Manager thread? Maybe your UOS library can be added to this excellent tool, only is needed that you add a package file .lpk to your sources. It doesn't mean that every user will need to use it, it's just another way to distribute your sources.
http://forum.lazarus.freepascal.org/index.php/topic,34297.msg236558.html#msg236558

 

TinyPortal © 2005-2018