FreeBSD Speaker Device Network Server API
SPKRD provides HTTP access to FreeBSD's /dev/speaker device for remote melody playback. The server handles device concurrency automatically by retrying requests when the device is busy.
http://your-server:1111
Plays a melody on the FreeBSD speaker device.
Request:
- Method:
PUT - Path:
/play - Content-Type:
text/plain(optional) - Body: Melody string in FreeBSD speaker format
Request Body:
- Maximum 1000 characters
- FreeBSD speaker melody format (see
man 4 speaker) - Example:
"cdefgab"
Response:
- Success: HTTP 200 with empty body
- Validation Error: HTTP 400 with error message
- Device Busy (timeout): HTTP 503 with error message
- Server Error: HTTP 500 with error message
curl -X PUT http://localhost:1111/play -d "cdefgab"curl -X PUT http://localhost:1111/play -d "t120l8cdegreg"| Status Code | Meaning | Example |
|---|---|---|
| 200 | Success | Empty body |
| 400 | Invalid melody | "Melody exceeds 1000 characters" |
| 503 | Device busy/timeout | "Device busy - request timed out" |
| 500 | Server error | "Device error: Permission denied" |
The server accepts melodies in FreeBSD speaker format. Common syntax:
- Notes:
a,b,c,d,e,f,g(with optional#or+for sharp) - Octaves:
o1too7(default o4) - Length:
l1,l2,l4,l8,l16,l32(whole, half, quarter, etc.) - Tempo:
t60tot255(beats per minute) - Pause:
pfollowed by length - Repeat:
.after note extends by half
Example: "t120l4 c d e f g a b o5c"
spkrd --port 1111 --retry-timeout 30 --device /dev/speakerOptions:
--port: Server port (default: 1111)--retry-timeout: Device retry timeout in seconds (default: 30)--device: Path to speaker device (default: /dev/speaker)