Recent

Author Topic: Join wav files  (Read 45424 times)

KMagic

  • Full Member
  • ***
  • Posts: 100
Re: Join wav files
« Reply #15 on: February 03, 2014, 06:04:14 pm »
I will try. Thank you very much.

Fred vS

  • Hero Member
  • *****
  • Posts: 3158
    • StrumPract is the musicians best friend
Re: Join wav files
« Reply #16 on: February 03, 2014, 06:18:35 pm »
Quote
I will try. Thank you very much.

Hum, i do not understand totally what you want but, look at

Quote
Player.EndProc := @ClosePlayer;

EndProc is the procedure loaded at end of audio file.

So you may add in that procedure the next wav you will load.
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

KMagic

  • Full Member
  • ***
  • Posts: 100
Re: Join wav files
« Reply #17 on: February 03, 2014, 06:33:13 pm »
What can I do to make an 2-second interval between the files?

Fred vS

  • Hero Member
  • *****
  • Posts: 3158
    • StrumPract is the musicians best friend
Re: Join wav files
« Reply #18 on: February 03, 2014, 08:18:04 pm »
Quote
What can I do to make an 2-second interval between the files?

Code: [Select]
...

procedure TForm1.Button1Click(Sender: TObject);
var
Player1 :  TUOS_Player ;
begin
  Player1 := TUOS_Player.Create(True, self);
  Player1.AddIntoDevOut;   //// add a Output with default parameters
  Player1.AddFromFile('MyWav.wav');
  Player1.EndProc := @ClosePlayer1;
  Player1.Play;
 end;     

procedure TForm1.ClosePlayer1;
begin
sleep(2000);
button2.click;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
Player2 :  TUOS_Player ;
begin
  Player2 := TUOS_Player.Create(True, self);
  Player2.AddIntoDevOut;   //// add a Output with default parameters
  Player2.AddFromFile('MyWav2.wav');
  Player2.Play;
 end;     

...       
       
« Last Edit: February 03, 2014, 08:25:59 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

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Join wav files
« Reply #19 on: February 03, 2014, 09:01:39 pm »
Quote
What can I do to make an 2-second interval between the files?

Code: [Select]
...
procedure TForm1.ClosePlayer1;
begin
sleep(2000);
button2.click;
end;
...       

Lol. I guess that's the best way to go here!
The correct way would be to insert two-seconds "muted" wave buffer

Fred vS

  • Hero Member
  • *****
  • Posts: 3158
    • StrumPract is the musicians best friend
Re: Join wav files
« Reply #20 on: February 04, 2014, 12:07:02 pm »
Quote
The correct way would be to insert two-seconds "muted" wave buffer

Hum, i do not understand your "correct way". I give a simple example and you propose something complicated.  But of course, it is possible to add 2 seconds of "muted wave buffer" (buffer with data = 0) in uos.

Also i do not understand why you propose OpenAl. It seems to me that OpenAl is a library to apply 3 D effect on sound, like OpenGl does for graphic...
« Last Edit: February 04, 2014, 12:19:00 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

KMagic

  • Full Member
  • ***
  • Posts: 100
Re: Join wav files
« Reply #21 on: February 04, 2014, 12:34:51 pm »
 Player1.AddIntoDevOut;   //// add a Output with default parameters

I don't understand what this line is used for. Can you explain in more detail?

KMagic

  • Full Member
  • ***
  • Posts: 100
Re: Join wav files
« Reply #22 on: February 04, 2014, 12:40:55 pm »
Quote
What can I do to make an 2-second interval between the files?

Code: [Select]
...

procedure TForm1.Button1Click(Sender: TObject);
var
Player1 :  TUOS_Player ;
begin
  Player1 := TUOS_Player.Create(True, self);
  Player1.AddIntoDevOut;   //// add a Output with default parameters
  Player1.AddFromFile('MyWav.wav');
  Player1.EndProc := @ClosePlayer1;
  Player1.Play;
 end;     

procedure TForm1.ClosePlayer1;
begin
sleep(2000);
button2.click;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
Player2 :  TUOS_Player ;
begin
  Player2 := TUOS_Player.Create(True, self);
  Player2.AddIntoDevOut;   //// add a Output with default parameters
  Player2.AddFromFile('MyWav2.wav');
  Player2.Play;
 end;     

...       
       

 Can you show me how to insert two-seconds "muted" wave buffer? because there may be many more files, if I do in this way, it will take lots of time. Moreover, in this case, I want to click only 1 button.
« Last Edit: February 04, 2014, 12:52:35 pm by KMagic »

Fred vS

  • Hero Member
  • *****
  • Posts: 3158
    • StrumPract is the musicians best friend
Re: Join wav files
« Reply #23 on: February 04, 2014, 12:51:58 pm »
Quote
Can you show me how to insert two-seconds "muted" wave buffer? because there may be many more files, if I do in this way, it will take lots of time.

Hello.
Please, could you explain better what you want.

If you want to play different wav files, with 2 seconds between each wav file, the example i give you is the best. Dont use "muted wave buffers".

If you want to create a new unique file, containing all your other wav files, separated with 2 seconds of silence, there, of course you need  "muted wave buffers" between each wav.
But that is more complicated to do (but possible with uos, of course).

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: 3158
    • StrumPract is the musicians best friend
Re: Join wav files
« Reply #24 on: February 04, 2014, 12:59:51 pm »
Quote
I don't understand what this line is used for. Can you explain in more detail?

Please, try the examples in uos, everything is explained and read the uos wiki :

http://wiki.lazarus.freepascal.org/uos
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

KMagic

  • Full Member
  • ***
  • Posts: 100
Re: Join wav files
« Reply #25 on: February 04, 2014, 01:01:55 pm »
I mean I want to play different wav files with 2 seconds between each other by clicking only 1 button once. I don't want to create a new wav file.

Fred vS

  • Hero Member
  • *****
  • Posts: 3158
    • StrumPract is the musicians best friend
Re: Join wav files
« Reply #26 on: February 04, 2014, 01:07:06 pm »
Quote
I mean I want to play different wav files with 2 seconds between each other by clicking only 1 button once. I don't want to create a new wav file.

Ok, so the example i give is ok.  ;)
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

KMagic

  • Full Member
  • ***
  • Posts: 100
Re: Join wav files
« Reply #27 on: February 04, 2014, 01:37:45 pm »
But why is there button2 in your example?

Fred vS

  • Hero Member
  • *****
  • Posts: 3158
    • StrumPract is the musicians best friend
Re: Join wav files
« Reply #28 on: February 04, 2014, 01:51:05 pm »
Quote
But why is there button2 in your example?

It was to give a clear simple example.

Of course, and better, you may use only procedure...

Like that
Code: [Select]
..

procedure TForm1.Button1Click(Sender: TObject);
var
Player1 :  TUOS_Player ;
begin
  Player1 := TUOS_Player.Create(True, self);
  Player1.AddIntoDevOut;   //// add a Output with default parameters
  Player1.AddFromFile('MyWav.wav');
  Player1.EndProc := @ClosePlayer1;
  Player1.Play;
 end;     

procedure TForm1.ClosePlayer1;
var
Player2 :  TUOS_Player ;
begin
sleep(2000);
  Player2 := TUOS_Player.Create(True, self);
  Player2.AddIntoDevOut;   //// add a Output with default parameters
  Player2.AddFromFile('MyWav2.wav');
  Player2.EndProc := @ClosePlayer2;
  Player2.Play;
 end;     

procedure TForm1.ClosePlayer2;
var
Player3 :  TUOS_Player ;
begin
sleep(2000);
  Player3 := TUOS_Player.Create(True, self);
  Player3.AddIntoDevOut;   //// add a Output with default parameters
  Player3.AddFromFile('MyWav2.wav');
  Player3.EndProc := @ClosePlayer3;
  Player3.Play;
 end;     

etc...

...       
       

[
« Last Edit: February 06, 2014, 11:51:23 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

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Join wav files
« Reply #29 on: February 04, 2014, 02:07:03 pm »
Hum, i do not understand your "correct way". I give a simple example and you propose something complicated.  But of course, it is possible to add 2 seconds of "muted wave buffer" (buffer with data = 0) in uos.
using sleep(2000) is the worst part of the code. I can understand sleep for command-line example, but not GUI. Just very bad practice.

Adding a "mute buffer" vs doing a time delay (using sleep or actual timer) - is a matter of required accuracy.
If it's fine to have +2 seconds  offsets - then using the timer offset the way to go, since it's easier.
But if a better accuracy is needed, "mute buffer" is necessary.

Also i do not understand why you propose OpenAl. It seems to me that OpenAl is a library to apply 3 D effect on sound, like OpenGl does for graphic...
Apart from 3d effects, that I guess used in very rare cases, OpenAL is an awesome cross-platform audio API over a system-native APIs.
« Last Edit: February 04, 2014, 02:15:38 pm by skalogryz »

 

TinyPortal © 2005-2018