Recent

Author Topic: Output Sound  (Read 12418 times)

Noval

  • Newbie
  • Posts: 3
Output Sound
« on: April 22, 2017, 04:01:46 pm »
I'm trying to create a metronome in Lazarus version 1.6.4 on Windows 10. I have encountered the problem that Lazarus does not provide an audio solution. I was wondering if anyone could help me in getting sound out of Lazarus.
Kind regards.

wp

  • Hero Member
  • *****
  • Posts: 11854
Re: Output Sound
« Reply #1 on: April 22, 2017, 04:18:25 pm »
There's a nice component playsoundpackage in Lazarus CCR which plays a sound file in Windows and Linux.

Handoko

  • Hero Member
  • *****
  • Posts: 5130
  • My goal: build my own game engine using Lazarus
Re: Output Sound
« Reply #2 on: April 22, 2017, 04:53:10 pm »
Hello Noval.

There are many ways to play sound in Lazarus:
http://wiki.freepascal.org/Multimedia_Programming

Pick one you feel convenient. If you get trouble, people here are nice to help.

Noval

  • Newbie
  • Posts: 3
Re: Output Sound
« Reply #3 on: April 22, 2017, 05:40:44 pm »
I have so far tried the playsoundpackage, Audorra, ACS and Bass, but have failed installing them/ getting them to work. The playsoundpackage and ACS brought up errors whilst compiling.

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: Output Sound
« Reply #4 on: April 22, 2017, 05:53:52 pm »
hello,
another way to make a metronom with lazarus is the tonegrid project.

Friendly, J.P
« Last Edit: April 22, 2017, 05:59:46 pm by Jurassic Pork »
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

Fred vS

  • Hero Member
  • *****
  • Posts: 3158
    • StrumPract is the musicians best friend
Re: Output Sound
« Reply #5 on: April 22, 2017, 05:56:55 pm »
I have so far tried the playsoundpackage, Audorra, ACS and Bass, but have failed installing them/ getting them to work. The playsoundpackage and ACS brought up errors whilst compiling.

You may try uos.
https://github.com/fredvs/uos
There is SimpleDrums demo in /uos/examples/
You do not need to install anything, just compile and run.

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

Handoko

  • Hero Member
  • *****
  • Posts: 5130
  • My goal: build my own game engine using Lazarus
Re: Output Sound
« Reply #6 on: April 22, 2017, 06:00:44 pm »
Also, try this video tutorial:
https://www.youtube.com/watch?v=SkhV7FuUpI4

Noval

  • Newbie
  • Posts: 3
Re: Output Sound
« Reply #7 on: April 30, 2017, 10:21:14 pm »
Alright, thanks for all the suggestions, the video suited my needs perfectly, so that's great.
Cheers!

jipété

  • Full Member
  • ***
  • Posts: 113
Re: Output Sound
« Reply #8 on: February 17, 2024, 03:49:23 pm »
Hello,

You do not need to install anything, just compile and run.
Wrong !
You must install fpGUI toolkit (https://fpgui.sourceforge.net/), nine years old, for stuff to compile...
So, not tried.
HTH,
« Last Edit: February 17, 2024, 03:52:12 pm by jipété »

TRon

  • Hero Member
  • *****
  • Posts: 2435
Re: Output Sound
« Reply #9 on: February 17, 2024, 04:00:33 pm »
Wrong !
Right  :)

Quote
You must install fpGUI toolkit (https://fpgui.sourceforge.net/), nine years old, for stuff to compile...
No you must not. Which project file did you load ?

PS:
...nine years old, for stuff to compile...
That is a useless remark about the age especially from someone necroing a 7 years old thread..
« Last Edit: February 17, 2024, 04:09:19 pm by TRon »

jipété

  • Full Member
  • ***
  • Posts: 113
Re: Output Sound
« Reply #10 on: February 17, 2024, 06:08:59 pm »
No you must not. Which project file did you load ?
One in the Examples folder, deviceinfos_fpGUI.lpi.

But maybe the problem I've found is related to the fact that I run Linux, and I noticed, when exploring the folders of uos, that there were many .dll files somewhere but 0 .so files (the "dll" of the Linux world)...
« Last Edit: February 17, 2024, 06:36:13 pm by jipété »

TRon

  • Hero Member
  • *****
  • Posts: 2435
Re: Output Sound
« Reply #11 on: February 17, 2024, 10:38:42 pm »
One in the Examples folder, deviceinfos_fpGUI.lpi.
I was kind of hoping that when you wrote that down (or had the intention to write that down) that the fpgui part in that name was able to provide you the hint for what widgetset that demo was intended (namely fpGUI)  :)

If there is fpGUI in the name of the project file then the demo is intended to run using the fpGUI widgets. You can either use the fpGUI examples to look at the source-code which then would be able to show you how to work with uos or use one of the other examples that is not bound to fpGUI (and that are able to compile without installing fpGUI). Alternatively it is optional to install fpGUI so that you can compile the fpGUI related demo's.

Quote
But maybe the problem I've found is related to the fact that I run Linux, and I noticed, when exploring the folders of uos, that there were many .dll files somewhere but 0 .so files (the "dll" of the Linux world)...
The example I posted was as mentioned by FredVs (the author of UOS) in this thread: SimpleDrums (SimpleDrums.lpi) and was compiled on Debian Linux 64-bit. It compiles out of the box and without the need to have fpGUI installed (note that there is also a fpGUI version of the simpledrums project (and which has fpGU in its name)). UOS does not depend on any specific widgetset.

Whether or not the UOS examples projects build/compile and run on your Linux machine might depend on the presences of the dependencies and if they are installed on your Linux machine (or not).
« Last Edit: February 17, 2024, 10:43:12 pm by TRon »

Thaddy

  • Hero Member
  • *****
  • Posts: 14201
  • Probably until I exterminate Putin.
Re: Output Sound
« Reply #12 on: February 17, 2024, 10:47:28 pm »
Fred did a great job, although I am struggling with latency on Linux, but that is not his fault. On windows I can get 2 ms with raw sound data through an ASIO -driver: Asio4All- , which make it real time. I still can not even come close to that on Linux.
Maybe  Fred has an answer. It is not his code, but the drivers.
« Last Edit: February 17, 2024, 10:50:13 pm by Thaddy »
Specialize a type, not a var.

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: Output Sound
« Reply #13 on: February 17, 2024, 10:50:05 pm »
You may try uos.
https://github.com/fredvs/uos
There is SimpleDrums demo in /uos/examples/
You do not need to install anything, just compile and run.

Going back to our previous discussions, there's a "beep" derivative at https://github.com/MarkMLl/asound

However, I suspect that defining the samples for a satisfying metronome tick will be non-trivial :-)

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

jipété

  • Full Member
  • ***
  • Posts: 113
Re: Output Sound
« Reply #14 on: February 18, 2024, 12:56:23 pm »
Hello,

before downloading uos package, I've read forums here and there, and found that :
Code: Pascal  [Select][+][-]
  1. Do you have problems to load-run the demos in /uos/examples/?
  2.  
  3. It should be out-of-the-box, just load a lpi project via Lazarus/Open Project an compile it.
  4.  
http://uos-forum.108.s1.nabble.com/simplest-to-play-a-wav-file-a-la-sndplaysound-tp980p982.html

But nothing told me : "but be careful not to use files with fpgui word in the name."

And there : https://forum.lazarus.freepascal.org/index.php/topic,37907.msg256152.html?PHPSESSID=q7pg59oevmqlu3qephic78l7m6#msg256152
2) In Lazarus, Open Project --> /the_directory_of/uos/examples/
    Choose a *.lpi example.

That's what I've done...

Then, this morning, 
1- I tried deviceinfos.lpi, which worked ootb but there are some strange behaviours : starting with a centered form, a click on "Load that library" button moves form at 0,0, I need to remove form1.Hide and form1.Show, and change form1.Height   := 388; to form1.Height   := 388 + shape.Height; to get it working fine.

2- In formspectrum.lpi code I read   
Code: Pascal  [Select][+][-]
  1. if (1 =2) and
...
if 1 = 2, really ? Always false, as said by the compiler...
Anyway, formspectrum doesn't work : I need to enlarge the form to see the error
img_filter_spectrum.jpg
Code: Pascal  [Select][+][-]
  1.   res := uos_LoadLib(PChar(PA_FileName), PChar(SF_FileName), PChar(MP_FileName), nil, nil, nil);  // Error
  2.   if Res <> 0 then
  3.   begin
  4.     label1.Caption  := 'UOS library in Error';
So I tested like that, see results at end of lines :
Code: Pascal  [Select][+][-]
  1. //res := uos_LoadLib(PChar(PA_FileName), PChar(SF_FileName), PChar(MP_FileName), nil, nil, nil); // Error
  2.   res := uos_LoadLib(PChar(PA_FileName), '', '', nil, nil, nil); // no error, but nothing on screen after "start"
  3. //res := uos_LoadLib('', PChar(SF_FileName), '', nil, nil, nil); // Error
  4. //res := uos_LoadLib('', '', PChar(MP_FileName), nil, nil, nil); // no error, but nothing on screen after "start"

3- Another basic try : I open simpledrums.lpi, I press F9 then ENTER (coz' Play is activated) and bim !
simpledrums.jpg

4- Waveform.lpi :
waveform.jpg

5- and simpleplayer.lpi :
simpleplayer.jpg

Sorry...
(and I don't know how to insert images in text, here...)

Oops, I forget that : Debian 11.9 Gtk2 Laz 3.0 FPC 3.2.2

 

TinyPortal © 2005-2018