uos routines don't work as expected inside a loop after Revision 185

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
22 messages Options
12
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

uos routines don't work as expected inside a loop after Revision 185

fauri
This post was updated on .
Hi, Fred, how are you?

I don't know why, but after the last updates (specifically, 185 e 186 revisions), my routines don't work anymore as expected.

Basically, I've the follow code in a Thread Loop:

  uos_CreatePlayer(id);
  with(sounds[id]) do
  begin
    input_id := uos_AddFromFile(id, pchar(file), -1, 0, 1024);
    output_id := uos_AddIntoDevOut(id, -1, LATENCY,uos_InputGetSampleRate(id, input_id),
                                  uos_InputGetChannels(id, input_id), 0, 1024);
  end;
  uos_Play(id);

Until revision 184, the code above works very well, but, with 185 or 186, it plays only once, and then stops. The Thread Timer loop stops too, but the executable still keeps running (no freezing).

Thanks for your attention!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: uos routines don't work as expected inside a loop after Revision 185

fredvs
Administrator
Hello Fauri.

Huh, please, could you give a demo of your problem, I cannot reproduce it.

Thanks.

Fre;D
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: uos routines don't work as expected inside a loop after Revision 185

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

Did you read my last post of this topic :
http://uos.2369694.n4.nabble.com/Strange-issues-with-different-formats-td58i20.html

Fre;D
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: uos routines don't work as expected inside a loop after Revision 185

fauri
This post was updated on .
fredvs wrote
Huh, please, could you give a demo of your problem, I cannot reproduce it.
The example in attachment shows what's happening. Until revision 184, it's playing as expected. But, with 185 or 186 revisions, the performance falls down.

fredvs wrote
Yeap, but I ended up with another solution: A thread timer loop with the code bellow inside it:
     if(uos_GetStatus(0) <> 1) then
      uos_PlayNoFree(0);
For me, that solution was more accurate.

Cheers!

test.zip
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: uos routines don't work as expected inside a loop after Revision 185

fredvs
Administrator
Hello Fauri.

OK, we will find your solution.

In last commit 3ed91ff..4dce331 I re-writed SimpleDrums demo with same ideas as in beginning --> 1 player for each instrument.
Could you try it ?

> The example in attachment shows what's happening.

Ok, I will take a look (but maybe last commit does it).


Fre;D
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: uos routines don't work as expected inside a loop after Revision 185

fredvs
Administrator
In reply to this post by fauri
> The example in attachment shows what's happening.

Oooops, indeed, there was a horrible bug.

Well seen and thanks !

Fixed in last commit 4dce331..6832b23.

Huh, by the way, I am not sure your demo is the best way to do loop for drums.
Did you try with a TMemoryStream, like in consoleplaymemorystream demo ?
Or with a memory-buffer like from consoleplaymemorybuffer demo ?

And this with PlayNoFree() ?

Fre;D
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: uos routines don't work as expected inside a loop after Revision 185

fredvs
Administrator
Re-hello.

No, it is not good yet. ;-(

I did try simpledrums_fpGUI ---> +- ok.
But with simpledrums LCL (Lazarus) ---> a disaster, no synchro at all.


Fre;D
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: uos routines don't work as expected inside a loop after Revision 185

fauri
fredvs wrote
But with simpledrums LCL (Lazarus) ---> a disaster, no synchro at all.
I noticed that!

fredvs wrote
Huh, by the way, I am not sure your demo is the best way to do loop for drums.
Did you try with a TMemoryStream, like in consoleplaymemorystream demo ?
Or with a memory-buffer like from consoleplaymemorybuffer demo ?
So far, unfortunely, this was the best way I found to create the drum machine. I didn't saw any performance differences using the Memory Buffer method. In fact, it was even worse when the sounds was changed from one to another (a delay until the file was loaded into memory).
With Memory Stream, initially I came across with some errors. Now, it plays only once, then nothing more happens.

fredvs wrote
And this with PlayNoFree() ?
Same sync problems... :(
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: uos routines don't work as expected inside a loop after Revision 185

fredvs
Administrator
fauri wrote
So far, unfortunely, this was the best way I found to create the drum machine.
Yep, I updated SimpleDrums demos in last commit : 6832b23..092f4a2

fauri wrote
With Memory Stream, initially I came across with some errors. Now, it plays only once, then nothing more happens.
Aaargh, ok, I will take a look.

fredvs wrote
But with simpledrums LCL (Lazarus) ---> a disaster, no synchro at all.
Maybe with Qt it is better ?
Look at this :
http://forum.lazarus.freepascal.org/index.php/topic,15223.msg81442.html#msg81442

Fre;D


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: uos routines don't work as expected inside a loop after Revision 185

fredvs
Administrator
In reply to this post by fauri
fauri wrote
With Memory Stream, initially I came across with some errors. Now, it plays only once, then nothing more happens.
Hello.

Updated SimpleDrums demos using TMemoryStream in last commit 092f4a2..4c97dcd .
I have good result for LCL too.

Fre;D
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: uos routines don't work as expected inside a loop after Revision 185

fauri
Good! With this last commit, my project worked fine again. I was using revision 184 until now, which gave me the results I wish.

With the last SimpleDrums example, I realized the fact that uos_PlayNoFree's problem is the latency parameter. But, for me at least, values less than 0.04 result in a problematic sound at all. The problem is, even with 0.04, is perceptible a little bit of desync.

Another thing: I don't see any performance differences using uos_AddFromFile instead of uos_AddFromMemoryStream.

Best Regards!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: uos routines don't work as expected inside a loop after Revision 185

fredvs
Administrator
fauri wrote
Another thing: I don't see any performance differences using uos_AddFromFile instead of uos_AddFromMemoryStream.
uos_AddFromFile does access to disk vs uos_AddFromMemoryStream does access only on ram-memory.

Now about performance, indeed access to disk, those days, is very fast.

fauri wrote
With the last SimpleDrums example, I realized the fact that uos_PlayNoFree's problem is the latency parameter. But, for me at least, values less than 0.04 result in a problematic sound at all. The problem is, even with 0.04, is perceptible a little bit of desync.
What os are you using, with what lcl (gtk, qt, win32,...), with what fpc version ?

Fre;D
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: uos routines don't work as expected inside a loop after Revision 185

fauri
fredvs wrote
What os are you using, with what lcl (gtk, qt, win32,...), with what fpc version ?
Now, I'm using FPC 3.0.0, with win32, Lazarus 1.6. With Lazarus 1.6.4 and FPC 3.0.2, I had the same problems in the last week, when I was testing.

Fred, a few hours ago, I'm noticed another strange issue. After many builds that I did in my application, the last UOS commit was slow again. So, I did a downgrade one more time to 184 revision, and everything worked fine again. Strange, don't you?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: uos routines don't work as expected inside a loop after Revision 185

fredvs
Administrator
fauri wrote
I'm noticed another strange issue. After many builds that I did in my application, the last UOS commit was slow again. So, I did a downgrade one more time to 184 revision, and everything worked fine again. Strange, don't you?
 

Huh, what is 184 revision, can you give the date of that commit so I can compare.

Fre;D
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: uos routines don't work as expected inside a loop after Revision 185

fauri
Of course! :)

The Date of revision 184 is 03/20/2017 (bellow it's in Brazilian Portuguese).
Revision: 184
Author: fredvs
Date: segunda-feira, 20 de março de 2017 16:41:43
Message:
Added some improvements from Phoenix.

----
Modified : /branches/master/examples/consoleplaymemorybuffer.prj
Modified : /branches/master/examples/uos_flat.pas
Modified : /branches/master/src/uos_flat.pas
Modified : /branches/master/examples/uos.pas
Modified : /branches/master/examples/waveform_fpGUI.prj
Modified : /branches/master/src/uos.pas
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: uos routines don't work as expected inside a loop after Revision 185

fredvs
Administrator
Obrigado.

Huh, was do you feel slower, the synchro, the loading of sound,... ?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: uos routines don't work as expected inside a loop after Revision 185

fauri
fredvs wrote
Obrigado.
:D
Mijn genoegen! (You're dutch, right? I guess...)

fredvs wrote
Huh, was do you feel slower, the synchro, the loading of sound,... ?
Yeap, synchro problem again...


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: uos routines don't work as expected inside a loop after Revision 185

fredvs
Administrator
fauri wrote
Mijn genoegen! (You're dutch, right? I guess...)
No, only my name, I am latino, like you (I guess).

fauri wrote
Yeap, synchro problem again...
Could you try last commit 2125bb9..1fa1930, it takes all what can influe to synchro from earlier-working commit.

Fre;D

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: uos routines don't work as expected inside a loop after Revision 185

fauri
Ahmm... I can't find "simpledrums.lpi" and "simpledrums.pas" anymore... It's a bug with my svn method, or the files aren't present in the last commit?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: uos routines don't work as expected inside a loop after Revision 185

fredvs
Administrator
12
Loading...