Hi All,
What can I use if the sound procedure unable to work? It works under Windows, when I use the WinCRT unit, but it unable to work under Linux.
What are the methods of (cross-platform) produce sound?
Best regards, G

Mailing lists / fpc-pascal / 2015-09
22 messages · 8 people · –
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
Hi All,
What can I use if the sound procedure unable to work? It works under Windows, when I use the WinCRT unit, but it unable to work under Linux.
What are the methods of (cross-platform) produce sound?
Best regards, G
Géza Kovacs Géza wroteWhat are the methods of (cross-platform) produce sound?
The best would be to create a cross-platform wrapper class around all sound API's on the platforms you are interested in. eg: OSS under FreeBSD, PulseAudio under Linux, MCI under Windows.
SDL does this already, but SDL doesn't come standard with Windows. UOS is another one that comes to mind - implemented for FPC. I've personally tested UOS on Linux, Windows, Mac osX, freeBSD and it works very well.
UOS can be found here:
https://github.com/fredvs/uos.git
I'm sure there will be other wrapper classes already implemented too (not sure if any are included as standard with FPC), otherwise roll your own. But I would give UOS a try first.
Regards,
- Graeme -
Hi Graeme,
Thx your answer.
I unable to compile UOS on Windows, I tested it with Free Pascal 2.6.4.
It produces the following errors:
Free Pascal Compiler version 2.6.4 [2014/03/06] for i386 Copyright (c) 1993-2014 by Florian Klaempfl and others Target OS: Win32 for i386
Compiling consoleplay.pas
Compiling uos_flat.pas
Compiling uos.pas
Compiling uos_portaudio.pas
uos_portaudio.pas(359,9) Error: Identifier not found "Result" uos_portaudio.pas(364,10) Error: Identifier not found "Result" uos_portaudio.pas(368,7) Error: Identifier not found "result" uos_portaudio.pas(412,13) Error: Identifier not found "Result" uos_portaudio.pas(439) Fatal: There were 4 errors compiling module, stopping Fatal: Compilation aborted
Error: C:\FPC\2.6.4\bin\i386-Win32\ppc386.exe returned an error exitcode (normal if you did not specify a source file to be compiled)
What can I do?
Best regards, G
Try adding -MDelphi or -MObjFpc to the compiler options.
Bart
Thx your answer. I unable to compile UOS on Windows, I tested it with Free Pascal 2.6.4.…
Géza Kovacs Géza wroteuos_portaudio.pas(359,9) Error: Identifier not found "Result" uos_portaudio.pas(364,10) Error: Identifier not found "Result"
I just got an update and the uos and examples compile just fine.
I think Bart is correct, add the -MObjFpc to your compiler options. If you are using Lazarus IDE, it is in "Project Options - Compiler Options
- Parsing" and select the -MObjFpc Syntax Mode.
For any other IDE to process is similar, simply add -MObjFpc to your list of compiler options.
I'll notify the author that it might be a good idea to add the syntax mode at the beginning of each unit.
Regards,
- Graeme -
Try adding -MDelphi or -MObjFpc to the compiler options.
Thanks Bart. This is the trick.
'll notify the author that it might be a good idea to add the syntax mode at the beginning of each unit.
Thanks Graeme, I will add it ASAP.
Fre;D
-----
Many thanks ;-)
Try adding -MDelphi or -MObjFpc to the compiler options.
Ooops, just checked all demos and /{$mode objfpc}{$H+} /is already added.
So there must be a other problem with Géza Kovacs Géza compilation.
I just have re-try the consoleplay example on Windows and do not have problem.
It must be something else but I do not see what.
Fre;D
-----
Many thanks ;-)
fredvs wroteSo there must be a other problem with Géza Kovacs Géza compilation.
I checked... The demos have it, but the actual UOS units don't - and that is where the error occurs. I could easily reproduce the issue here with MSEide (and make sure my fpc.cfg has the default -Mfpc line).
TIP:
I recommend developers update there $HOME/.fpc.cfg files so it uses -Mobjfpc, instead of the default -Mfpc (what I consider outdated language mode).
Regards,
- Graeme -
Ooops, just checked all demos and /{$mode objfpc}{$H+} /is already added. So there must…
fredvs wroteIt must be something else but I do not see what.
Maybe your fpc.cfg was already changed to use -Mobjfpc? That is why I never noticed it before. Also if you change compiler options, remove all existing *.ppu files, or force a Build All.
Regards,
- Graeme -
I checked... The demos have it, but the actual UOS units don't - and that is where the…
I checked... The demos have it, but the actual UOS units don't...
OK, Graeme, you win ;-)
I will update it asap.
Many thanks.
Fre;D
What can I use if the sound procedure unable to work? It works under Windows, when I use…
Géza Kovacs Géza wroteuos_portaudio.pas(359,9) Error: Identifier not found "Result" uos_portaudio.pas(364,10) Error: Identifier not found "Result"
Hello Géza Kovacs Géza.
Could you try with new release b307af6..65e9749 => https://github.com/fredvs/uos
Fre;D.
-----
Many thanks ;-)
I checked... The demos have it, but the actual UOS units don't - and that is where the…
Am 15.09.2015 12:25 schrieb "Graeme Geldenhuys" <
The best solution is to have {$mode objfpc} in the unit as then it doesn't matter what is supplied in the config or on the commandline and one can be sure that the right mode for the unit is used.
Regards,
Sven
I checked... The demos have it, but the actual UOS units don't - and that is where the…
Finding maxint at 32767 (64bit compiler) with that mode can be a bit of a shock too!
Regards,
PB
I checked... The demos have it, but the actual UOS units don't - and that is where the…
Graeme Geldenhuys wroteI recommend developers update there $HOME/.fpc.cfg files so it uses -Mobjfpc, instead of the default -Mfpc
I wouldn't, because then as soon as you give your source code to someone else, they may not be able to compile it unless they use specific switches (as in this thread).
Jonas
Jonas Maebe wroteI wouldn't, because then as soon as you give your source code to someone else, they may not be able to compile it unless they use specific switches (as in this thread).
Very true. All my own code have the desired language mode defined in each unit. As you said, that is by far the better choice.
Fred has fixed the UOS units, so the original poster's issue should now be resolved.
Regards,
- Graeme -
What can I use if the sound procedure unable to work? It works under Windows, when I use…
Hi!
I succesfully compiled the updated version.
What component can I use when i only want to play only the specified Hz frequency of sound?
I would like to use this component within a console-based application. I am not using Lazarus IDE (or Delphi), only Free Pascal.
Sorry if this question too trivial, I am only looking a working alternative to the sound procedure which is unable to work. :-(
Best regards, Géza
What component can I use when i only want to play only the specified Hz frequency of sound?
Hello and thanks to try uos.
You do not need a special component, there is the procedure => uos_AddFilterIn();Take a example (both for LCL and fpGUI).
But, of course, you may use uos_AddDSPIn() and do your own Fourier transform.
I would like to use this component within a console-based application. I am not using Lazarus IDE (or Delphi), only Free Pascal.
No problem, there is consoleplay.pas demo and all fpGUI's demos are in fact... console applications (with GUI output). But, afaik, all the synchronize() procedures will have no sense in console application.
I am only looking a working alternative to the sound procedure which is unable to work. :-(
What sound procedure is unable to work ?
Thanks.
Fre;D
I guess he means Procedure Sound in rtl/unix/crt.pp This does not work for me either, just get the "sound of silence".
Procedure Sound(Hz: Word);
begin
{$ifdef havekiocsound}
if (not OutputRedir) and (hz>0) then
fpIoctl(TextRec(Output).Handle, KIOCSOUND, Pointer(1193180 div Hz));
{$endif}
end;Regards,
PB
Peter wroteI guess he means Procedure Sound in rtl/unix/crt.pp This does not work for me either, just get the "sound of silence".
That is a know problem for many years. Here is a thread from 2007.
http://free-pascal-general.1045716.n5.nabble.com/simple-sound-implementation-td2816047.html#a2816060
Regards,
- Graeme -
I guess he means Procedure Sound in rtl/unix/crt.pp This does not work for me either,…
I guess he means Procedure Sound in rtl/unix/crt.pp This does not work for me either, just get the "sound of silence".
Huh, same for me trying /fpcsrc/packages/fcl-sound/ ...
Does it exist a demo how to use fcl-sound ?
Thanks
Fre;D
-----
Many thanks ;-)
That is a know problem for many years. Here is a thread from 2007.…
Still, seems easy enough to do basic sounds in linux by shelling the beep command....
program soundcheck;
uses Process;
var s : ansistring;
begin
RunCommand ('beep',['-f','100','-l','900'],s);
end.Fisrt number is frequency, 2nd is length in Ms.
Need to have 'beep' installed, and possibly need to do
sudo modprobe pcspkr
Regards,
PB
Still, seems easy enough to do basic sounds in linux by shelling the beep
command....
Ha, ok, you only want to make a sound...
Peter's beep way is maybe the the easiest.
You may also use portaudio library to produce sine-wave.
Here example done by Mister Blaazen with library included=> https://sites.google.com/site/fiensprototyping/DynSynthDemo.tar.gz <https://sites.google.com/site/fiensprototyping/DynSynthDemo.tar.gz>
Fre;D
-----
Many thanks ;-)