Windows 11: simplerecorder error

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
79 messages Options
1234
Reply | Threaded
Open this post in threaded view
|

Windows 11: simplerecorder error

NeedUOS
Hello Fred,

I am using the latest commit and trying out the simplerecorder. This is working, but on closing the program I got the following error:

This stops the execution in uos.pas in procedure Tuos_Init.unloadlib at Pa_Unload(); in line 11640.
The same error I have for simpleplayer and deviceinfo.

Before trying the examples, I already let an AI write a program to play a file with your library,  which was not working, since there was the need for PortAudioFileName. So I searched and found the dll on the PortAudio website. I didn't get an error!

So I was trying simpleplayer with the new libportaudio64bit.dll - no error anymore. Then simplerecorder: no error on close! But:

When recording with Listen MIC I hear myself as Micky Mouse (double speed) and this is also audible in the resulting file.

Then I started experimenting with your functions with the custom parameters. Setting channels in uos_AddIntoFile and uos_AddIntoDevOut to 1 helped in getting normal speed while recording (leaving the other parameters -1). But the resulting file contains only zeros, but has the right length (shown in wave editor)!

With other parameter combinations the resulting file contains some or combinations of this: crackling, noise, beeping, choppy Micky, distortion.

What can I do? Or just live with the error by now?

Greetings

Reply | Threaded
Open this post in threaded view
|

Re: Windows 11: simplerecorder error

fredvs
Administrator
Hello NeedUOS and welcome to uos forum.

Hum, I will try to understand your problem.

When you try the simplerecorder demo using the libraries by default from uos, apart for the crash at closing, do you get correct result with the saved file?
Is it ok also with "listen to mic"?

>So I was trying simpleplayer with the new libportaudio64bit.dll - no error anymore. Then simplerecorder: no error on close! But:

What is the new libportaudio64bit.dll ? Is it a version from /uos/lib?

I need to know that to understand what is wrong.

Reply | Threaded
Open this post in threaded view
|

Re: Windows 11: simplerecorder error

NeedUOS
> do you get correct result with the saved file?
Yes
> Is it ok also with "listen to mic"?
Yes
> libportaudio64bit.dll
It's from https://github.com/spatialaudio/portaudio-binaries/blob/master/libportaudio64bit.dll .
Reply | Threaded
Open this post in threaded view
|

Re: Windows 11: simplerecorder error

fredvs
Administrator
In reply to this post by fredvs
Re-hello.

For the crash you get when closing, could you please try this (keeping the original libportaudio64.dll):

Edit \uos\examples\uos_portaudio.pas and at line 318

change this:

  if Pa_Handle<>0 then

with this:

  if Pa_Handle<>dynlibs.NilHandle then

and recompile and try the demo?

Thanks.

Reply | Threaded
Open this post in threaded view
|

Re: Windows 11: simplerecorder error

NeedUOS
Changed it, recompiled, same error. Checked multiple times.

Thanks for the help
Reply | Threaded
Open this post in threaded view
|

Re: Windows 11: simplerecorder error

fredvs
Administrator
In reply to this post by fredvs
Ooops, the previous fixe will not repair the crash at close.
Sorry for the noise, I still investigate.
Reply | Threaded
Open this post in threaded view
|

Re: Windows 11: simplerecorder error

fredvs
Administrator
In reply to this post by NeedUOS
Other question, do you get this error while debugging or even with running without debugging.
I try here on a Windows 11 machine and cannot get the crash.
Reply | Threaded
Open this post in threaded view
|

Re: Windows 11: simplerecorder error

NeedUOS
No!
Reply | Threaded
Open this post in threaded view
|

Re: Windows 11: simplerecorder error

NeedUOS
No error when not debugging.
Reply | Threaded
Open this post in threaded view
|

Re: Windows 11: simplerecorder error

NeedUOS
Also no error when compiled with debug on, but started from Explorer!
Reply | Threaded
Open this post in threaded view
|

Re: Windows 11: simplerecorder error

fredvs
Administrator
In reply to this post by NeedUOS
OK, could you try this,
once again in  \uos\examples\uos_portaudio.pas but at line 384

remove or comment this:
// Pa_Handle:=DynLibs.NilHandle;

and see, with debugging, if there is still crash.
 
Note that debugging audio application is difficult because it will have a big impact on latency and the result of sound will be bad.
Reply | Threaded
Open this post in threaded view
|

Re: Windows 11: simplerecorder error

fredvs
Administrator
In reply to this post by NeedUOS
When you run the application from Lazarus you may choose to run it with or without debugger.
With debugger it will analyse each buffer of samples and so make the process read/write not fluent.

If you run it from explorer, it will run without to load the debugger.
Reply | Threaded
Open this post in threaded view
|

Re: Windows 11: simplerecorder error

NeedUOS
In reply to this post by fredvs
Commented it - same error.

> big impact on latency
This explains the stutter on recording. Playback works fine.
Reply | Threaded
Open this post in threaded view
|

Re: Windows 11: simplerecorder error

fredvs
Administrator
In reply to this post by fredvs
To resume: use the debugger with audio application only when you are lost, there is a crash or exception you do not find.
Because with the debugger, what you will ear or get is absolutely not the result without debugger.
Reply | Threaded
Open this post in threaded view
|

Re: Windows 11: simplerecorder error

NeedUOS
Ok, I will start to use the Lazarus Build modes
Reply | Threaded
Open this post in threaded view
|

Re: Windows 11: simplerecorder error

fredvs
Administrator
This post was updated on .
In reply to this post by NeedUOS
Yes, I see now why, the debugger is still analysing when portaudio is already closed.
I fair I cannot do anything for that, maybe add a sleep(1000); before  DynLibs.UnloadLibrary(Pa_Handle);

Imho, the most important is what's happening when you run/close the application "pure" without the debugger controlling it.

When you run/close the app from a terminal, what message do you get?
You should get some message from portaudio, but do you get a crash message?
Reply | Threaded
Open this post in threaded view
|

Re: Windows 11: simplerecorder error

fredvs
Administrator
In reply to this post by NeedUOS
It is better to run the audio application, when using Lazarus, with menu Run/Run Without Debugging.
This to test your audio app and when you are lost with a crash, maybe the debugger could help you.
Reply | Threaded
Open this post in threaded view
|

Re: Windows 11: simplerecorder error

NeedUOS
The error occurs when executing Pa_Terminate();.
I struggled once to get rid of the console window. Now I can't find the place to turn it on again (google doesn't help)!
Reply | Threaded
Open this post in threaded view
|

Re: Windows 11: simplerecorder error

NeedUOS
I got rid of the error!

After loading the libraries I issued a Pa_Initialize. Then the error was gone.

Is this ok?
Reply | Threaded
Open this post in threaded view
|

Re: Windows 11: simplerecorder error

fredvs
Administrator
This post was updated on .
Please if you use uos, use the uos_xxx methods.

I dont follow you any more.
Do you get error without debugging?

Dont add Pa_Initialize after uos_loadlib(), it is done by uos, it will create a memory leak and conflict.

As explained already, the debugger will create a error at closing because pa_terminate will be still analyzed after unloadlib.
If you absolutely want to use the debugger without crash at end, maybe it will help adding in uos/examples/uos_portaudio.pas,

line 17,
add: sysutils,

and line 382,
after Pa_Terminate();

add this: sleep(1000); 

And remove it when compiling for release of your program.

Also, take a look at the many demos of uos, all is explained how to use uos.
 
1234