FreeBSD Programming Tips
From Lazarus wiki
Jump to navigationJump to search
│ English (en) │
Note: Work in Progress
FreeBSD Programming Tips
Making a Beep
As SysUtils.Beep
has no effect on FreeBSD, I looked around for a way to make a beep and found nothing useful. So, I reinvented the wheel as follows:
{$IFDEF FREEBSD}
procedure FBSDbeep;
var
BProcess: TProcess;
begin
BProcess:= TProcess.Create(nil);
BProcess.CommandLine := 'sh -c "echo xxxxxxx > /dev/dsp"';
BProcess.Execute;
BProcess.Free;
end;
{$ENDIF}
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 you're really fussy, you could send a real .wav file to /dev/dsp and play any musical note(s) you desire.
- 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.
Using HTTPS
Placeholder. Content to come.