Recent

Author Topic: [SOLVED] Making FreeBSD beep...  (Read 2623 times)

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
[SOLVED] Making FreeBSD beep...
« on: July 18, 2019, 11:43:24 am »
As SysUtils.Beep has no effect on FreeBSD I looked around for a way  to make it beep and found nothing useful. So, I reinvented the wheel as follows:

Code: Pascal  [Select][+][-]
  1. {$IFDEF FREEBSD}
  2. procedure FBSDbeep;
  3. var
  4.   BProcess: TProcess;
  5.   begin
  6.     BProcess:= TProcess.Create(nil);
  7.     BProcess.CommandLine := 'sh -c "echo xxxxxxx > /dev/dsp"';
  8.     BProcess.Execute;
  9.     BProcess.Free;
  10.   end;
  11. {$ENDIF}  
  12.  

Note:

/dev/dsp will automatically reroute to the sound device's correct device node (eg /dev/dsp0.0) using the dynamic devfs(5) clone handler.

Qualifications:

* Ok, it's more of a burp than a beep, but it serves the purpose.

* If FreeBSD is using a GENERIC kernel, it will work.

* If FreeBSD is using a custom kernel and it's a desktop system, then it will most probably work because who doesn't want sound on their desktop system.

* If FreeBSD is using a custom kernel and is running on a server,  it may not work. I don't see this as a significant defect in user applications which is its use case for my purposes.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11382
  • FPC developer.
Re: [SOLVED] Making FreeBSD beep...
« Reply #1 on: July 18, 2019, 11:46:04 am »
Console.kiocsound(stdinput,1) or so?

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: [SOLVED] Making FreeBSD beep...
« Reply #2 on: July 18, 2019, 12:17:31 pm »
Code: Pascal  [Select][+][-]
  1. procedure FBSDbeep;
  2. begin
  3.   Console.kiocsound(stdinputhandle,1);
  4. end;
  5.  

No sound - I tried 1 through 1000 for the last argument.

[I assume you meant stdinputhandle - fpc couldn't find stdinput].

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11382
  • FPC developer.
Re: [SOLVED] Making FreeBSD beep...
« Reply #3 on: July 18, 2019, 12:50:43 pm »
You could also try stdouthandle. Afaik it is a boolean, so the exact value doesn't matter much.

It is very old though, and afaik syscons has been rewritten since.

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: [SOLVED] Making FreeBSD beep...
« Reply #4 on: July 18, 2019, 02:10:54 pm »
Nope, no sound with stdoutput or stdoutputhandle (both of which are recognised this time).

My wheel is looking good  8-)

 

TinyPortal © 2005-2018