-
Notifications
You must be signed in to change notification settings - Fork 227
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for the portaudio library #116
Comments
Can you prove that? I run Jamulus on a Raspberry Pi Zero with Jack. I do not think direct ALSA interface can improve the performance. Maybe some Jack Audio developer can comment on that. |
JACK also uses ALSA in the backend, because ALSA is what the kernel provides (that, or OSS). So, as long as you have only one application using sound running, ALSA has much less overhead (less processes ⇒ less RAM and less context switches). I’d prefer ALSA on Linux but have JACK as an option (e.g. for proper musicians who use it anyway), but we need JACK on GNU/kFreeBSD and GNU/Hurd in Debian because these don’t have ALSA because they don’t use the Linux kernel, so ideally both would be available and the user could choose. |
JACK can use ALSA in the backend, but it can use a bunch of other backends too (think FFADO as an example). |
See this commit: cb951c9 and also this: https://github.com/corrados/jamulus/blob/master/ChangeLog#L368 |
My HiFiBerry DAC+ ADC has shipped (Switzerland -> Minneapolis US), and it is only accessed via ALSA interface. My guess is the coverage of the implementation of ALSA within Jack. |
Scott T Nieman dixit:
My HiFiBerry DAC+ ADC has shipped (Switzerland -> Minneapolis US), and
it is only accessed via ALSA interface.
JACK uses ALSA by talking to the ALSA interfaces the same way an
application directly using ALSA would.
My guess is the coverage of the implementation of ALSA within Jack.
This makes no sense. If it works without JACK it will work with JACK.
(If jackd starts. I had a case today on a laptop infested with
poetteringaudio where we couldn’t get it to. On another, it worked.
Both not mine, I ofc know better…)
corrados dixit:
We have an audio interface for ASIO, CoreAudio, Jack and Android (under
development). I actually do not want to have another one...
Fair enough.
|
Really. An application may choose to implement what it needs for the scope of its functionality; e.g., MIDI (rawmidi.h) may be out of scope. That is what is typically is called 'coverage', at least in my 30+ years of development. |
Scott T Nieman dixit:
>> This makes no sense. If it works without JACK it will work with JACK.
Really.
So are you saying that JACK implements **100%** of the ALSA interfaces?
I’m not.
I’m saying that JACK implements 0% of the ALSA interfaces, because
it *uses* ALSA (not substitutes it).
|
@corrados Could you just switch Jamulus to using portaudio (portaudio.com) as its audio API? It would relieve you of the need to maintain code for multiple audio APIs, and it would add support for additional audio interfaces (e.g. WDM-KS on Windows). It's also the library that Jack itself uses. |
Jack on Linux uses portaudio? |
Not on Linux. Definitely on Windows, maybe on Mac (git has libportaudio.a but I'm not sure it's still used). Does the portaudio API provide adequate functionality for Jamulus' needs? |
Does portaudio support the Google Oboe library for Android? We are currently working on a new audio interface implementation for Jamulus for Android which uses the Oboe library, see #83 |
Good question. Looks like the official Portaudio is mainly a Win/Mac/Linux deal. There is a port of portaudio to opensles at https://github.com/Gundersanne/portaudio_opensles/tree/master/src/hostapi/opensles but that's the old Android API. I can't find any port of portaudio to AAudio or Oboe. It might be just as much work to add Oboe support to portaudio as it would be to update the Jamulus audio code to support all the other platforms it would be nice to have. E.g. using portaudio would allow switching between ASIO and Jack at runtime on Windows, and allow also using WDM-KS devices. |
Yes, I see the advantages of portaudio. It is definitely much better to include portaudio than ALSA directly (as is the title of this Issue). But right now I do not see an urgent need of including portaudio. Maybe we should change the title of this Issue and work on a portaudio integration sometime later (maybe when the peak of Corona is over and we have more time for other stuff). |
Since portaudio supports ALSA directly, I will change the title of this Issue now to better reflect the ongoing discussion here. |
I still don't understand why you are not considering dmix plug-in for ALSA to eliminate the extra dependencies. One can provide basic instructions on the asound.conf file. |
Scott T Nieman dixit:
I still don't understand why you are not considering dmix plug-in for
ALSA to eliminate the extra dependencies. One can provide basic
instructions on the asound.conf file.
Changing the system-wide state is a big detriment for casual users.
|
@mirabilos I am using an add-on ADC GPIO board to avoid the USB interface and any potential latency that introduces. So in order to make that happen, I currently do have to create asound.conf with dmix slave. As @streaps states it would work fine for USB interface users without any asound.conf once you have Jack routed - not so casual. The dmix C interface seems pretty straight-forward to pass in the PCM stream. |
Am I reading this correctly, that portaudio depends on Jack?
|
Yes, because portaudio can act as an abstraction layer on top of Jack. If you don't want Jack installed then you'd need to build your own custom portaudio19 packages.
Elliot
…________________________________
From: Scott T Nieman ***@***.***>
Sent: Monday, March 21, 2022 7:47:33 PM
To: jamulussoftware/jamulus ***@***.***>
Cc: elliotclee ***@***.***>; Mention ***@***.***>
Subject: Re: [jamulussoftware/jamulus] Add support for the portaudio library (#116)
Am I reading this correctly, that portaudio depends on Jack?
***@***.***:~ $ sudo apt install portaudio19-dev
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
libasound2-dev **libjack-dev libjack0** libportaudio2 libportaudiocpp0 uuid-dev
Suggested packages:
libasound2-doc jackd1 portaudio19-doc
The following packages will be REMOVED:
libjack-jackd2-0
The following NEW packages will be installed:
libasound2-dev libjack-dev libjack0 libportaudio2 libportaudiocpp0
portaudio19-dev uuid-dev
0 upgraded, 7 newly installed, 1 to remove and 0 not upgraded.
Need to get 734 kB of archives.
After this operation, 3,142 kB of additional disk space will be used.
Do you want to continue? [Y/n] n
—
Reply to this email directly, view it on GitHub<#116 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AJNWQFHVGZT6OXY77V7LUADVBEDBLANCNFSM4ML7LMQA>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
I'll try to add an option to the Jamulus project file to compile portaudio without jack. |
Noam, it might be a bit more involved than that. I remember seeing somewhere that Jamulus only compiles portaudio on win32, and Scott is running Raspberry Pi (aka Debian/Ubuntu-ish Linux).
Elliot
…________________________________
From: Noam Postavsky ***@***.***>
Sent: Monday, March 21, 2022, 9:15 PM
To: jamulussoftware/jamulus ***@***.***>
Cc: elliotclee ***@***.***>; Mention ***@***.***>
Subject: Re: [jamulussoftware/jamulus] Add support for the portaudio library (#116)
I'll try to add an option to the Jamulus project file to compile portaudio without jack.
—
Reply to this email directly, view it on GitHub<#116 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AJNWQFHTUZPXQE7S4PDWU63VBENKVANCNFSM4ML7LMQA>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
I wrote Jamulus' portaudio code so I have an idea about how involved it is ;)
Initially I only did it for win32, but later extended it to unix & macOS platforms (although I don't recall if anyone ever tested on macOS so it may not actually work). |
@elliotclee @npostavs
|
On portaudio's website, they say :
If you compile portaudio yourself without JACK installed, then it doesn't use JACK? |
Is it fair to state the minimal viable product for a PortAudio build for RPi4 would only need these files? Ref: |
Okay, I actually had forgotten that the non-win32 support was only for the shared lib config, so it was slightly more involved than I realized. But I think the following patch (or git commit here) against the feature branch should work (I tested on my Linux box, though I don't have rPi so I can't guarantee it will work there). Compile with [PATCH] Allow compiling portaudio with ALSA onlyFrom 7c7ab672a01cae400b689c60201868b8d9ab921b Mon Sep 17 00:00:00 2001
From: Noam Postavsky <[email protected]>
Date: Sat, 26 Mar 2022 13:15:57 -0400
Subject: [PATCH] Allow compiling portaudio with ALSA only
---
Jamulus.pro | 29 ++++++++++++++++++++---------
1 file changed, 20 insertions(+), 9 deletions(-)
diff --git a/Jamulus.pro b/Jamulus.pro
index a8fda289..f9b28ab7 100644
--- a/Jamulus.pro
+++ b/Jamulus.pro
@@ -63,6 +63,8 @@ INCLUDEPATH_OPUS = libs/opus/include \
INCLUDEPATH_PORTAUDIO = libs/portaudio/include libs/portaudio/src/common
win32 {
INCLUDEPATH_PORTAUDIO += libs/portaudio/src/os/win
+} else {
+ INCLUDEPATH_PORTAUDIO += libs/portaudio/src/os/unix
}
DEFINES += APP_VERSION=\\\"$$VERSION\\\" \
@@ -763,12 +765,15 @@ win32 {
}
} else:unix {
SOURCES_PORTAUDIO += $$files(libs/portaudio/src/os/unix/*.c)
- SOURCES_PORTAUDIO += $$files(libs/portaudio/src/os/hostapi/alsa/*.c) \
- $$files(libs/portaudio/src/os/hostapi/jack/*.c) \
- $$files(libs/portaudio/src/os/hostapi/oss/*.c)
+ # Does it ever make sense to use OSS?
+ # $$files(libs/portaudio/src/hostapi/oss/*.c)
+ SOURCES_PORTAUDIO += $$files(libs/portaudio/src/hostapi/alsa/*.c)
+ CONFIG(portaudio_jack) {
+ SOURCES_PORTAUDIO += $$files(libs/portaudio/src/hostapi/jack/*.c)
+ }
} else:macx {
SOURCES_PORTAUDIO += $$files(libs/portaudio/src/os/unix/*.c)
- SOURCES_PORTAUDIO += $$files(libs/portaudio/src/os/hostapi/coreaudio/*.c)
+ SOURCES_PORTAUDIO += $$files(libs/portaudio/src/hostapi/coreaudio/*.c)
}
# I can't figure out how to make the custom compiler stuff work for
@@ -1231,8 +1236,12 @@ CONFIG(portaudio) {
SOURCES += src/portaudiosound.cpp
CONFIG(portaudio_shared_lib) {
LIBS += $$libnames(portaudio)
- } else:win32 {
- DEFINES += PA_USE_ASIO=1 PA_USE_WASAPI=1 PA_USE_WDMKS=1
+ } else {
+ win32 {
+ DEFINES += PA_USE_ASIO=1 PA_USE_WASAPI=1 PA_USE_WDMKS=1
+ } else {
+ DEFINES += PA_USE_ALSA=1
+ }
INCLUDEPATH += $$INCLUDEPATH_PORTAUDIO
HEADERS += $$HEADERS_PORTAUDIO
mingw {
@@ -1243,9 +1252,11 @@ CONFIG(portaudio) {
SOURCES += $$SOURCES_PORTAUDIO $$SOURCES_CXX_PORTAUDIO
}
DISTFILES += $$DISTFILES_PORTAUDIO
- LIBS += $$libnames(winmm ole32 uuid setupapi)
- } else {
- error ( "non-shared portaudio only implemented for win32" )
+ win32 {
+ LIBS += $$libnames(winmm ole32 uuid setupapi)
+ } else {
+ LIBS += -lasound
+ }
}
}
--
2.11.0
|
used qmake CONFIG+=portaudio it was going so well until this...
|
trying qmake 'CONFIG+=portaudio portaudio_shared_lib' |
Hmm, looks like it's failing to link portaudio sources, I don't understand why. |
This did not return any errors BUT on RPi4 Jamulus was not added to the menu.
I am trying again.. Compiling.md definitely requires this for the RPi4: Once PortAudio 19.8 is available, I will try to build a slim MVP package. |
Oh, I forgot to mention you have to run with |
I will have time to fully test this Wednesday evening Central (us). After editing jamulus.desktop, I have now have the Jamulus client running and connected to my local server in my studio basement. The previous performance with the Hi-Fi Berry ADC-DAC was ~80ms total roundtrip, and this is about 1/2. I am not sure about the Pulse device, but again, I will test this out.
When I select the Hi-Fi Berry from the Device drop-down directly, it is throwing an exception. But that may be a configuration issue. |
Nice ! I want to test Windows WASAPI to use it instead of asio4all. P.S.: No need to use OSS server in 2022 from my point of view. |
@npostavs: I woke up in the middle of the night thinking the Hi-Fi Berry device should work, as there isn't much to configure. I only edited the /boot/config.txt
I have not created ~/.asoundrc (my user only) or /etc/asound.conf (all users) files. There may have an interface mismatch with the number of channels(?). |
You can give it a shot, although I found the results disappointing on my hardware (run Jamulus with
Hmm, I'm not sure what's triggerring that error. |
@npostavs I thought you'd like to know that I am getting the same error with the channel interface. Just to be clear the configuration
But I get the error when selecting the device in the Jamulus client: Really unrelated, but I am unclear why PulseAudio daemon is referenced, even when I remove it:
oddly it still shows up when I start the Jamulus client:
And the PulseAudio sound server interface seems to be working (I will check my server recording). If this daemon can be bypassed and go direct via PortAudio like Audacity, I suspect the total delay can be further reduced. |
PortAudio seems to use PulseAudio sound server. I went into Audacity again, then killed pid 632, and the RPi4 screen went blank and restarted with the login screen. |
Pulseaudio is one of the daemons that get started with the login session, so it's not surprising that the session ended when you killed it.
Now that you've removed the pulseaudio package and killed the process, can you login again and get Jamulus to run?
Elliot
…________________________________
From: Scott T Nieman ***@***.***>
Sent: Thursday, March 31, 2022 9:02:15 AM
To: jamulussoftware/jamulus ***@***.***>
Cc: elliotclee ***@***.***>; Mention ***@***.***>
Subject: Re: [jamulussoftware/jamulus] Add support for the portaudio library (#116)
PortAudio seems to use PulseAudio sound server. I went into Audacity again, then killed pid 632, and the RPi4 screen went blank and restarted with the login screen.
—
Reply to this email directly, view it on GitHub<#116 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AJNWQFHJN5WKIWVVGONZTYLVCWO5PANCNFSM4ML7LMQA>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
@elliotclee yes, you are correct. It is not spawned by PortAudio. Jamulus client saw PulseAudio and that was able to communicate to the HiFi Berry card in my earlier screenshots, hence why it was able to start. Now after restart of the RPi4, I now see this on startup of Jamulus client. @npostavs do you think there a PortAudio callback that is not set properly? Audacity still works after uninstall of PulseAudio too. Is there a way to turn on fine logging in the client via a cli parameter? |
I haven't added a logging option; I'm not really what there is to log. You could try fiddling with the setting of Might also be worth investigating whether any the functions in http://files.portaudio.com/docs/v19-doxydocs/pa__linux__alsa_8h.html helps. At least |
@npostavs
One of the above errors showed 'invalid number of channels'. |
It seems more on the device initialization, versus streams. http://files.portaudio.com/docs/v19-doxydocs/api_overview.html If you want to enumerate Devices belonging to a particular Host API you can count between 0 and PaHostApiInfo::deviceCount - 1. You can convert this Host API-specific index value to a global PaDeviceIndex value by calling Pa_HostApiDeviceIndexToDeviceIndex(). ===== Do you really want to iterate on the api count or the device count? selectedApiIndex is passed as an argument to Pa_HostApiDeviceIndexToDeviceIndex
|
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
I understand you have a Jack wrapper implementation, but native alsa may provide even better performance on the raspberry pi for Jamulus clients leveraging HiFiBerry DAC+ ADC boards.
The text was updated successfully, but these errors were encountered: