Recent

Author Topic: Output buffer to audio.  (Read 1445 times)

Fred vS

  • Hero Member
  • *****
  • Posts: 3629
    • StrumPract is the musicians best friend
Re: Output buffer to audio.
« Reply #15 on: June 13, 2025, 05:34:55 pm »
Hello Dzandaa.

In attachment, update of your last UOSDemo.zip with sound.

I will see tonight what to do to play custom buffer like in your first demo.
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

Dzandaa

  • Sr. Member
  • ****
  • Posts: 462
  • From C# to Lazarus
Re: Output buffer to audio.
« Reply #16 on: June 13, 2025, 07:20:32 pm »
Hi,

@Fred:

It's alive!!!!

Thank you very much.

My understanding of UOS has greatly improved :)

B->
Regards,
Dzandaa

Fred vS

  • Hero Member
  • *****
  • Posts: 3629
    • StrumPract is the musicians best friend
Re: Output buffer to audio.
« Reply #17 on: June 13, 2025, 07:33:41 pm »
Yeeep!  ;D
« Last Edit: June 14, 2025, 06:00:12 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

Fred vS

  • Hero Member
  • *****
  • Posts: 3629
    • StrumPract is the musicians best friend
Re: Output buffer to audio.
« Reply #18 on: June 14, 2025, 02:27:13 am »
I did change a few your procedure TUOSDemoForm.CreateFrenquencies() because I had bad sound (did not find why yet, maybe because the freq was too short)

Code: Pascal  [Select][+][-]
  1.                 // FreqAmpArray[Cnt].Freq := 10 + (Random(4) * 10); this was changed
  2.               FreqAmpArray[Cnt].Freq := 440 + (Random(10) * 10);   // with this

And for the creation + play the buffer:

Code: Pascal  [Select][+][-]
  1. function DSPfillbuffer(var Data: TuosF_Data; var fft: TuosF_FFT): TDArFloat;
  2. begin
  3.   result := UOSDemoForm.SinData;
  4. end;
  5.  
  6. procedure TUOSDemoForm.CreatePlayer();
  7. var
  8.         Stat: Boolean;
  9. begin
  10.    PlayerIndex := SPPlayer.Value;
  11.    Stat := uos_CreatePlayer(PlayerIndex);
  12.    if(Stat) then
  13.         begin
  14.             InputIndex :=  uos_AddFromEndlessMuted(PlayerIndex, 1, length(SinData) ); // used as template
  15.             uos_InputAddDSP(PlayerIndex, InputIndex, nil, @DSPfillbuffer, nil, nil);   // DSP to fill the buffer at each loop
  16.             OutputIndex := uos_AddIntoDevOut(PlayerIndex, -1, -1, SamplingFrequency , 1, 0, length(SinData), -1); // this to get sound
  17.             uos_Play(PlayerIndex);
  18.         end
  19.         else
  20.            MLog.Append('Error with Player: ' + PlayerIndex.ToString);
  21. end;  
       

With this I get a correct sine-wave (but of course it is only to test and to give some ideas).

The zip of the project is included [EDIT: The zip was updated].
« Last Edit: June 14, 2025, 03:20:11 am 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

Dzandaa

  • Sr. Member
  • ****
  • Posts: 462
  • From C# to Lazarus
Re: Output buffer to audio.
« Reply #19 on: June 14, 2025, 12:37:00 pm »
Hi,
@Fred:

Great work: Both are working Synth and Buffer.

Also tested on Linux.

I'm thinking of a dual buffer or a circular buffer with 2 pointer In and Out.

For next week :)

Thank you again.

B->

P.S: I also tested you Wavview and StrumPract. Great programs.
« Last Edit: June 14, 2025, 12:57:28 pm by Dzandaa »
Regards,
Dzandaa

Fred vS

  • Hero Member
  • *****
  • Posts: 3629
    • StrumPract is the musicians best friend
Re: Output buffer to audio.
« Reply #20 on: June 14, 2025, 01:26:46 pm »
Great work: Both are working Synth and Buffer.

Also tested on Linux.
;D

P.S: I also tested you Wavview and StrumPract. Great programs.
Thank you, dear fellow neighbor!
There is also Simple Web Player.
All those apps use uos and MSEgui widgetset.

Have fun!

Fre;D
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

 

TinyPortal © 2005-2018