Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2015-09

Sound procedure does not work

22 messages · 8 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Géza Kovacs Géza

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

Reply by email

Graeme Geldenhuys
to Géza Kovacs Géza
Géza Kovacs Géza wrote
What 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 -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

Géza Kovacs Géza
to Graeme Geldenhuys

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

Reply by email

Bart
to Géza Kovacs Géza
Géza Kovacs Géza wrote 7 lines
Thx your answer. I unable to compile UOS on Windows, I tested it with Free Pascal 2.6.4. It produces the following errors: uos_portaudio.pas(359,9) Error: Identifier not found "Result"

Try adding -MDelphi or -MObjFpc to the compiler options.

Bart

Reply by email

Graeme Geldenhuys
to Géza Kovacs Géza: Thx your answer. I unable to compile UOS on Windows, I tested it with Free Pascal 2.6.4.…
Géza Kovacs Géza wrote
uos_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 -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

fredvs
to fredvs
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 ;-)

View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Sound-procedure-does-not-work-tp5722591p5722599.html Sent from the Free Pascal - General mailing list .

Reply by email

Graeme Geldenhuys
to fredvs
fredvs wrote
So 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 -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

Graeme Geldenhuys
to fredvs: Ooops, just checked all demos and /{$mode objfpc}{$H+} /is already added. So there must…
fredvs wrote
It 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 -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

fredvs
to Géza Kovacs Géza: What can I use if the sound procedure unable to work? It works under Windows, when I use…
Géza Kovacs Géza wrote
uos_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 ;-)

View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Sound-procedure-does-not-work-tp5722591p5722604.html Sent from the Free Pascal - General mailing list .

Reply by email

Sven Barth
to Graeme Geldenhuys: 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" <

Show quoted text 7 lines
: 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).

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

Reply by email

Graeme Geldenhuys
to Jonas Maebe
Jonas Maebe wrote
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).

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 -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

Géza Kovacs Géza
to Géza Kovacs Géza: 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

Reply by email

Fred van Stappen
to Géza Kovacs 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

Reply by email

Peter
to Fred van Stappen
Fred van Stappen wrote 7 lines
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

Reply by email

fredvs
to Peter: 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 ;-)

View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Sound-procedure-does-not-work-tp5722591p5722617.html Sent from the Free Pascal - General mailing list .

Reply by email

Peter
to Graeme Geldenhuys: That is a know problem for many years. Here is a thread from 2007.…
Graeme Geldenhuys wrote 13 lines
On 2015-09-15 20:59, Peter wrote: > I 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 -

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

Reply by email

fredvs
to Peter
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 ;-)

View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Sound-procedure-does-not-work-tp5722591p5722619.html Sent from the Free Pascal - General mailing list .

Reply by email