Sound procedure does not work

classic Classic list List threaded Threaded
22 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Sound procedure does not work

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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Sound procedure does not work

Graeme Geldenhuys-6
On 2015-09-14 16:27, 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/
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Sound procedure does not work

Géza Kovacs Géza
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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Sound procedure does not work

Bart-48
On 9/15/15, Géza Kovacs Géza <[hidden email]> wrote:

> 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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Sound procedure does not work

Graeme Geldenhuys-6
In reply to this post by Géza Kovacs Géza
On 2015-09-15 05:42, 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/
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Sound procedure does not work

fredvs
> 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 ;-)
Reply | Threaded
Open this post in threaded view
|

Re: Sound procedure does not work

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 ;-)
Reply | Threaded
Open this post in threaded view
|

Re: Sound procedure does not work

Graeme Geldenhuys-6
On 2015-09-15 11:19, 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/
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Sound procedure does not work

Graeme Geldenhuys-6
In reply to this post by fredvs
On 2015-09-15 11:19, 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/
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Sound procedure does not work

fredvs
In reply to this post by Graeme Geldenhuys-6
> 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

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Many thanks ;-)
Reply | Threaded
Open this post in threaded view
|

Re: Sound procedure does not work

fredvs
In reply to this post by Géza Kovacs Géza
On 2015-09-15 05:42, 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 ;-)
Reply | Threaded
Open this post in threaded view
|

Re: Sound procedure does not work

Sven Barth-2
In reply to this post by Graeme Geldenhuys-6

Am 15.09.2015 12:25 schrieb "Graeme Geldenhuys" <[hidden email]>:
>
> 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


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Sound procedure does not work

Peter
In reply to this post by Graeme Geldenhuys-6
On 15/09/15 11:25, Graeme Geldenhuys wrote:
> .....
> the default -Mfpc (what I consider outdated
> language mode).
>
>
> Regards,
>   - Graeme -
>

Finding maxint at 32767 (64bit compiler) with that mode can be a bit of
a shock too!


Regards,
PB
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Sound procedure does not work

Jonas Maebe-2
In reply to this post by Graeme Geldenhuys-6
On 15/09/15 12:25, Graeme Geldenhuys wrote:
>    I 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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Sound procedure does not work

Graeme Geldenhuys-6
On 2015-09-15 16:24, 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/
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Sound procedure does not work

Géza Kovacs Géza
In reply to this post by Géza Kovacs Géza
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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Sound procedure does not work

fredvs
> 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 look at filterplay.pas 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



_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Many thanks ;-)
Reply | Threaded
Open this post in threaded view
|

Re: Sound procedure does not work

Peter
On 15/09/15 18:34, Fred van Stappen wrote:
>
> 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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Sound procedure does not work

Graeme Geldenhuys-6
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 -

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Sound procedure does not work

fredvs
In reply to this post by Peter
> 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 ;-)
12