Recent

Author Topic: [UOS/PortAudio] Minimizing Audio Latency?  (Read 1525 times)

Fred vS

  • Hero Member
  • *****
  • Posts: 2992
    • StrumPract is the musicians best friend
Re: [UOS/PortAudio] Minimizing Audio Latency?
« Reply #15 on: February 06, 2023, 04:43:24 pm »
Here you go:
Code: Pascal  [Select][+][-]
  1. uos.pas(10381,43) Error: Can't determine which overloaded function to call

Hum, here no problems.
What version of uos are you using?

The last is this:  https://github.com/fredvs/uos/archive/refs/heads/main.zip

What example are you compiling to get that error?

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

Hobbit1972

  • New Member
  • *
  • Posts: 23
Re: [UOS/PortAudio] Minimizing Audio Latency?
« Reply #16 on: February 06, 2023, 04:51:57 pm »
Here you go:
Code: Pascal  [Select][+][-]
  1. uos.pas(10381,43) Error: Can't determine which overloaded function to call

Hum, here no problems.
What version of uos are you using?

The last is this:  https://github.com/fredvs/uos/archive/refs/heads/main.zip

What example are you compiling to get that error?

I'm using the latest  ;)
Doesn't matter what example, as long as I use the unmodified uos.pas the compilers throws this error.


Fred vS

  • Hero Member
  • *****
  • Posts: 2992
    • StrumPract is the musicians best friend
Re: [UOS/PortAudio] Minimizing Audio Latency?
« Reply #17 on: February 06, 2023, 04:54:04 pm »
SimpleRecorder: I'd say latency is ~1/4s, just like in my program.

Sorry but I did not understand.  :-[
Is the sound ok or not?

Sound is (and was alaways) okay, but processing time (=latency) is too long for my purposes. Between me speaking in the mic and hearing my voice in the speaker is ~250ms  :o

ofc Win was and is a pain in the a** concerning these kind of things.  :(

If you want a shorter delay, you have to play with the FramesCount parameter of input and output.

     
Code: Pascal  [Select][+][-]
  1. uos_AddFromDevIn(0, -1, -1, -1, -1, -1, -1, -1);  
  2.       /// add Input from mic/aux into IN device with custom parameters
  3.       //////////// PlayerIndex : Index of a existing Player
  4.       //////////// Device ( -1 is default Input device )
  5.       //////////// Latency  ( -1 is latency suggested ) )
  6.       //////////// SampleRate : delault : -1 (44100)
  7.       //////////// OutputIndex : OutputIndex of existing Output // -1 : all output, -2: no output, other integer : existing output)
  8.       //////////// SampleFormat : -1 default : Int16 : (0: Float32, 1:Int32, 2:Int16)
  9.       //////////// FramesCount : -1 default : 4096   ( > = safer, < =  better latency )
  10.  
  11.   uos_AddIntoDevOut(0, -1, -1, -1, -1, 1,-1, -1);
  12.       //// add a Output into device with custom parameters
  13.       //////////// PlayerIndex : Index of a existing Player
  14.       //////////// Device ( -1 is default Output device )
  15.       //////////// Latency  ( -1 is latency suggested ) )
  16.       //////////// SampleRate : delault : -1 (44100)
  17.       //////////// Channels : delault : -1 (2:stereo) (0: no channels, 1:mono, 2:stereo, ...)
  18.       //////////// SampleFormat : -1 default : Int16 : (0: Float32, 1:Int32, 2:Int16)
  19.       //////////// FramesCount : -1 default : 65536
  20.       // ChunkCount : default : -1 (= 512)
  21.       // ChunkCount : default : -1 (= 512)
  22.  

How little is the FramesCount how short is the delay.
And play also with the Latency parameter.

I agree it is not easy to find the right combination for each sound card (plus Windows is not the King of Latency).
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

Fred vS

  • Hero Member
  • *****
  • Posts: 2992
    • StrumPract is the musicians best friend
Re: [UOS/PortAudio] Minimizing Audio Latency?
« Reply #18 on: February 06, 2023, 05:01:50 pm »
I'm using the latest  ;)
Doesn't matter what example, as long as I use the unmodified uos.pas the compilers throws this error.

Bizarre...
I will be very happy to find out how you did to get that error.

Are you using Lazarus IDE and the *.lpi uos-examples or do you compile the examples a other way?
« Last Edit: February 06, 2023, 05:06:40 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

Hobbit1972

  • New Member
  • *
  • Posts: 23
Re: [UOS/PortAudio] Minimizing Audio Latency?
« Reply #19 on: February 06, 2023, 05:16:18 pm »

If you want a shorter delay, you have to play with the FramesCount parameter of input and output.

     
Code: Pascal  [Select][+][-]
  1. ....

How little is the FramesCount how short is the delay.
And play also with the Latency parameter.

I agree it is not easy to find the right combination for each sound card (plus Windows is not the King of Latency).

Values I tried so far only increase latency  :(

Hobbit1972

  • New Member
  • *
  • Posts: 23
Re: [UOS/PortAudio] Minimizing Audio Latency?
« Reply #20 on: February 06, 2023, 05:18:47 pm »

If you want a shorter delay, you have to play with the FramesCount parameter of input and output.

     
Code: Pascal  [Select][+][-]
  1. ....

How little is the FramesCount how short is the delay.
And play also with the Latency parameter.

I agree it is not easy to find the right combination for each sound card (plus Windows is not the King of Latency).

Values I tried so far only increase latency  :(

Ah, cutting down chunk size was needed, too.

Fred vS

  • Hero Member
  • *****
  • Posts: 2992
    • StrumPract is the musicians best friend
Re: [UOS/PortAudio] Minimizing Audio Latency?
« Reply #21 on: February 06, 2023, 05:21:17 pm »

If you want a shorter delay, you have to play with the FramesCount parameter of input and output.

     
Code: Pascal  [Select][+][-]
  1. ....

How little is the FramesCount how short is the delay.
And play also with the Latency parameter.

I agree it is not easy to find the right combination for each sound card (plus Windows is not the King of Latency).

Values I tried so far only increase latency  :(

Even with a little FramesCount for input and output?
Did you try with a other Windows audio app that can do "direct-wire" (input directly to output) ?
Do you get better result?
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

Hobbit1972

  • New Member
  • *
  • Posts: 23
Re: [UOS/PortAudio] Minimizing Audio Latency?
« Reply #22 on: February 07, 2023, 06:39:58 am »
Frame size together with chunk size improves latency.  :)
I'll have to add a pair of sliders to allow fine tuning on different machines.

Fred vS

  • Hero Member
  • *****
  • Posts: 2992
    • StrumPract is the musicians best friend
Re: [UOS/PortAudio] Minimizing Audio Latency?
« Reply #23 on: February 07, 2023, 02:33:20 pm »
Hello.

I dont use Windows any more but, like metis noted: https://forum.lazarus.freepascal.org/index.php/topic,62191.msg470140.html#msg470140
there is ASIO4ALL that gives better latency.
PortAudio can deal with it, just install it and choose it as device.
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

metis

  • Sr. Member
  • ****
  • Posts: 257
Re: [UOS/PortAudio] Minimizing Audio Latency?
« Reply #24 on: February 07, 2023, 04:21:53 pm »
As mentioned in the OP, "to route MicIn to SpkOut" on Win11 64bit, see the
JACKROUTER setup guide for windows 10 64bit (YouTube).

With PortAudio, You have to select the 'JackRouter' as shown in the attached Pic.
(This is, how I use PortAudio+JACK on my WinXP, but it should work the same Way on Win11.)
« Last Edit: February 07, 2023, 04:53:35 pm by metis »
Life could be so easy, if there weren't those f*** Details.
My FFmpeg4Lazarus = FFPlay4Laz + FFGrab4Laz + FFInfo4Laz

Hobbit1972

  • New Member
  • *
  • Posts: 23
Re: [UOS/PortAudio] Minimizing Audio Latency?
« Reply #25 on: February 08, 2023, 07:57:23 am »
I'll have a look at the jackrouter/asio4all. Tx.

metis

  • Sr. Member
  • ****
  • Posts: 257
Re: [UOS/PortAudio] Minimizing Audio Latency?
« Reply #26 on: February 09, 2023, 05:27:33 pm »
Here's another YouTube-Video that should suit your Case: Ableton Tutorial: Using JACK for Windows with Ableton Live.
See @ 06:13 for how to set up the JACK-Router for 'PortAudio', and
see @ 09:02 for how to set up JACK-Connections.

It's shown on Win7, but Things shouldn't have changed too much since then.
« Last Edit: February 09, 2023, 05:30:41 pm by metis »
Life could be so easy, if there weren't those f*** Details.
My FFmpeg4Lazarus = FFPlay4Laz + FFGrab4Laz + FFInfo4Laz

 

TinyPortal © 2005-2018