[Lazarus] Beep?

Donald Ziesig donald at ziesig.org
Thu Mar 29 15:42:28 CEST 2018


On 03/29/2018 06:12 AM, Carlos E. R. via Lazarus wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
>
>
> On Monday, 2018-03-26 at 06:09 +0200, Carlos E. R. via Lazarus wrote:
>
>> On 2018-03-26 04:02, Donald Ziesig via Lazarus wrote:
>>> Hi Everyone!
>>>
>>> I am using Lazarus 1.8 on Linux Mint.  I would like to use the
>>> Windows.Beep( Freq, Duration) function, or (if not available)
>>> SysUtils.Beep subprograms.
>>
>> AFAIK, you can not call Windows functions in Linux.
>
> Further, my understanding is that the loudspeaker is associated to the 
> terminal in Linux. You can not thus beep from a daemon, something that 
> would be useful. We apparently do not get access to program the chip 
> as in MsDOS, nor freq,duration.
>
>
> Here I post an attempt I did back on 2005. It doesn't compile, and 
> this moment I can't check why. Nor, of course, do I remember what I 
> was trying.
>
> program beeper;
>
> uses linux;
>
> var
>         Saved43, Saved61: byte;
>         LoadClock: word;
>         frequency: word;
>         duration:  real;
>         RequestedDuration, RemainingDuration: timespec;
>
>         hh,mm,ss, msec, usec: word;
> begin
> (*
>         if paramcount <> 2 then begin
>                 writeln('Produces a beep of the indicated frequency 
> and duration.');
>                 writeln('Usage: beeper frequency duration');
>                 halt(1);
>         end;
>
>
>         frequency:= round(ParamStr(1));
>         duration:= ParamStr(2);
> *)
>
>         frequency:= 500;
>         duration:=  1.2;
>
>
>         RequestedDuration.tv_sec:=      trunc(duration);
>         RequestedDuration.tv_nsec:=     trunc(frac(duration)*1e9);
>
>         {ioperm(from, num, value)}
>         writeln($61, '   ', $42);
>         writeln(ioperm($61, 1, 1), ' ', ioperm($42, 2, 1));
>
>                 {timer prepare}
>         ReadPort($43, Saved43);
>         writeln('43h', ' ', Saved43);
>         writeport($43, byte($B6));      {Channel 2, LSB/MSB}
>
>         LoadClock:= 1193180 div frequency;
>         writeport($42, Lo(LoadClock));
>         writeport($42, Hi(LoadClock));
>
>         ReadPort($61, Saved61);
>         writeln('61h', ' ', Saved61);
>         writeport($61, byte(Saved61 or $3));    {Speaker on}
>
>
>                 {Select(0, nil, nil, nil, 1000);}
>         gettime(hh,mm,ss, msec, usec);
>         writeln(hh,':', mm, ':', ss, '.', msec, ' ', usec);
>         nanosleep(RequestedDuration, RemainingDuration);
>         gettime(hh,mm,ss, msec, usec);
>         writeln(hh,':', mm, ':', ss, '.', msec, ' ', usec);
>
>         writeport($61, Saved61);        {Speaker off}
>
> end.
>
>
> I also have copies of some c code I got from fidonet posts that I can 
> look at another day, in assembler. I don't remember if they worked, 
> probably not.
>
>
> - -- Cheers,
>        Carlos E. R.
>        (from openSUSE 42.3 x86_64 "Malachite" at Telcontar)
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2
>
> iEYEARECAAYFAlq8vCgACgkQtTMYHG2NR9W0MQCfW3PJfWFopnrWMV9V+bCcA1ZQ
> 2goAn3C6b2V2kwsunTiqB5o1vIQIaF8H
> =v6dw
> -----END PGP SIGNATURE-----
>
>
Thanks Carlos!

I am presently recovering from surgery and taking medication for pain.  
I will try your suggestion once my pain is gone and I can think straight 
;-).

Don

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20180329/ef5e3acc/attachment-0001.html>


More information about the Lazarus mailing list