Recent

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

trev

  • Full Member
  • ***
  • Posts: 153
[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.
o Lazarus v2.1.0 r61676, FPC v3.3.1 r42640, macOS 10.14.6 (with supplemental update), Xcode 10.3
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.0
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 18.04

marcov

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

trev

  • Full Member
  • ***
  • Posts: 153
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].
o Lazarus v2.1.0 r61676, FPC v3.3.1 r42640, macOS 10.14.6 (with supplemental update), Xcode 10.3
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.0
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 18.04

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 7293
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

  • Full Member
  • ***
  • Posts: 153
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-)
o Lazarus v2.1.0 r61676, FPC v3.3.1 r42640, macOS 10.14.6 (with supplemental update), Xcode 10.3
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.0
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 18.04