B4J Question [ jAudioRecord2 ] lag in the window when starting audio recording?

Waldemar Lima

Well-Known Member
Licensed User
Hello guys, I'm currently trying to implement jAudioRecord2 in my project, however, when starting the audio recording, the window and some components start to freeze, and only return to normal when the audio recording ends...

Is it possible to fix this lag with thread? How would I do it?
 

stevel05

Expert
Licensed User
Longtime User
Are you running the demo? If not, what are you doing in the gui? Can you post your project?
Are you running in release mode?
 
Upvote 0

Waldemar Lima

Well-Known Member
Licensed User
Are you running the demo?
Yes.
Are you running in release mode?
Yes.


screenshot : https://www.canva.com/design/DAFwzVyBFuY/G6qFdUDV898cnP2UTYQulQ/watch

1696886175074.png
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Recording audio is a resource intensive process, it is not often that you are going to be moving a window while recording. That said, jAudioRecord implements threading, so you could try that.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Yes, it would be possible. It would require working out the best way to implement it, which would probably be as a compiled Java library so that it can be used while debugging the rest of the app. and would require two additional classes, one for Capture to file and one for Capture Raw.
 
Upvote 0

Waldemar Lima

Well-Known Member
Licensed User
But why the additional classes?
Wouldn't it be possible to just play the record function within a thread and the problem would be solved?

Note:Sorry for the questions, I'm not an expert in threads xD
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Then it would complicate the existing classes as the structure required for the threaded class is different, and won't work the same with the resumeable subs that the current classes were designed for. They would be mostly the same.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
difference significant between using sleep()
Possibly, it really depends on what else is going on in the gui , the spec of the pc and any other background tasks that may be running.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
If you want to try a threaded approach, try the attached, it supports threaded and non threaded recording. Bear in mind that the demo is just that, and you can take the modules you want for your project and implement one or more methods.

The threaded classes cannot be used in debug mode, that would require a bigger rewrite of the demo.

Moved the file to the jAudioRecord2 thread (first post)
 
Last edited:
Upvote 0
Top