Fix linux (play-sound) sound output as aplay does not work, swap for something else

54 views
Skip to first unread message

jest array

unread,
Aug 24, 2021, 3:19:25 PM8/24/21
to Racket Users
https://github.com/racket/gui/issues/239

So this does not work on both Arch Linux with prebuilt racket binaries and Debian with built from source binaries(according to a user JSGRANT on the racket discord server https://discord.com/channels/571040468092321801/618895179343986688/879797867903057921):
```
#lang racket

(require 2htdp/image
         (only-in racket/gui/base play-sound))


(put-preferences '(GRacket:playcmd) '("mpv --no-audio-display ~a"))

 (play-sound "./Nl-honk.ogg" #t)
```
because of this:
It uses `aplay` first to try and play the sound but according to this:
> You cannot decode ogg files with aplay. According to the man page, the only formats aplay understands are voc, wav, raw and au. My guess is that aplay interprets the ogg file as raw data, hence the white noise.

so I suggest swapping the order to `sndfile-play` or whichever command line audioplayer is available on most linux installations.

A side issue is that we should probably provide an easier way to import `play-sound` because I want to use it with 2htdp/image with students.

Hendrik Boom

unread,
Aug 24, 2021, 3:31:27 PM8/24/21
to Racket Users
On Tue, Aug 24, 2021 at 12:19:25PM -0700, jest array wrote:
> https://github.com/racket/gui/issues/239
>
> So this does not work on both Arch Linux with prebuilt racket binaries and
> Debian with built from source binaries(according to a user JSGRANT on the
> racket discord server
> https://discord.com/channels/571040468092321801/618895179343986688/879797867903057921):

Ten years ago I remarked that audio on Linux is a black art. Ten years
later, it is still a back art.

-- hendrik

jest array

unread,
Aug 24, 2021, 3:39:15 PM8/24/21
to Racket Users
Woops so I left:

(put-preferences '(GRacket:playcmd) '("mpv --no-audio-display ~a"))
which changes it to use mpv instead. This fixes the issue but nonetheless we should fix this out of the box and have it not look for aplay first
Reply all
Reply to author
Forward
0 new messages