
for teaching how to make video games with racket with 2htdp, is there a sound playing library that comes with 2htdp or would i have to use require rsound?

For simple sounds, you can use play-sound
.

I’m just getting static background noises from it… along with another user on discord

I should mention we’re both on linux

tested on .ogg and .wav files, and both not playing correctly, only getting static noises. Sometimes I get this error : . invalid memory reference. Some debugging context lost
and the error will loop forcing me to restart racket to reset everything..

The docs say
On Unix, the function invokes an external sound-playing program—looking by default for a few known programs (aplay, play, esdplay, sndfile-play, audioplay). A play command can be defined through the ’GRacket:playcmd preference preference (see Preferences). The preference can hold a program name, or a format string containing a single ~a where the filename should be substituted—and used as a shell command. (Don’t use ~s, since the string that is used with the format string will be properly quoted and wrapped in double quotes.) A plain command name is usually better, since execution is faster. The command’s output is discarded, unless it returns an error code, in which case the last part of the error output is shown.

I don’t know the default.

seemsl ike it has no default

The racket/gui/base library supports a number of preferences for global configuration. The preferences are stored in the common file reported by find-system-path for ’pref-file, and preference values can be retrieved and changed through get-preference and put-preferences. Except for the except the ’GRacket:playcmd preference preference, the racket/gui/base library reads each of the preferences below once at startup.

(get-preference 'GRacket:defaultMenuPrefix)
returns #f though…

You mean (get-preference 'GRacket:playcmd)
?

So it’s locating ones @soegaard2 listed in that order. If not there should be an error though

It’s defined here: https://github.com/racket/gui/blob/master/gui-lib/mred/private/misc.rkt#L63

It’s not impossible that the order of play commands were chosen a long time ago. Maybe there is a better order today?

no, even trying to (get-preference 'GRacket:default-font-size)
returns false, not just the playcmd one

That sounds okay

thought it would be defined…

anywhoo, i have aplay
installed already

ahh

Does directly calling aplay with the file works?

seeems like aplay is the issue

yepp, ran it through CLI and its doing the same thing

interesting

Are you on Ubuntu?

arch linux, but someone else is having this same issue on discord and he’s running debian with racket built from source

I was reading this - but ended up being more confused :slightly_smiling_face: https://linuxhint.com/guide_linux_audio/

https://unix.stackexchange.com/questions/363176/ogg-audio-file-and-aplay-white-noise
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.
Use some other program that can actually decode ogg files, e.g. mplayer, ogg123 etc.

so if this is the case we should probably switch out aplay for something else….

I know it’s not 2htdp, but did want to toss out there (err… shamelessly plug) https://r-cade.io as a possible alternative

i remember seeing r-cade somewhere lol! but i forgot the name and was trying to remember wtf was the name again

my .wav file doesnt work with aplay also ;s

I only have mpv
so I tried this (put-preferences '(GRacket:playcmd) '("mpv --no-audio-display ~a"))

… but of course that sets the preference so maybe it’s not good for others

sndfile-play
, so maybe we should reorder aplay to sndfile-play

ill file an issue on gh for discussion on what the default should be

It might be a good topic for the mailing list - to get word from users of different linux distributions.

+1, mailing list is more visible to the users than a GH issue


alright

Are you using mpv? I’m confused why the issue mentioned that

I’m not using mpv no, i have it installed but im using snd-play
for this case because racket eventually searches for that if it cant find aplay

Okay. Because that mpv
code should work.

OHHH, i forgot to remove that line, the mpv one does work but we should default to to sndfile-play or something out of the box

can someone test something for me (particularly on an ARM Mac)? Try installing this url: <http://www.cs.indiana.edu/classes/c211/c211-handin.plt>
using “Install .plt file” in the File menu of DrRacket? Let me know if it’s successful.

Successful
raco setup: Unpacking C211 from /var/folders/8v/ssfgpb5d67n4jrvmszsh7y800000gn/T/tmp16298338131629833813892.plt
raco setup: making directory c211-handin in /Users/sorawee/Library/Racket/development/collects/
raco setup: unpacking client-gui.rkt in /Users/sorawee/Library/Racket/development/collects/c211-handin/
raco setup: unpacking client.rkt in /Users/sorawee/Library/Racket/development/collects/c211-handin/
raco setup: unpacking handin-multi.rkt in /Users/sorawee/Library/Racket/development/collects/c211-handin/
raco setup: unpacking icon.png in /Users/sorawee/Library/Racket/development/collects/c211-handin/
raco setup: unpacking info.rkt in /Users/sorawee/Library/Racket/development/collects/c211-handin/
raco setup: unpacking server-cert.pem in /Users/sorawee/Library/Racket/development/collects/c211-handin/
raco setup: unpacking this-collection.rkt in /Users/sorawee/Library/Racket/development/collects/c211-handin/
raco setup: unpacking updater.rkt in /Users/sorawee/Library/Racket/development/collects/c211-handin/
raco setup: version: 8.2.0.7
raco setup: platform: aarch64-macosx [cs]
raco setup: target machine: tarm64osx
raco setup: installation name: development
raco setup: variants: cs, 3m
raco setup: main collects: /Users/sorawee/projects/racket/racket/collects/
raco setup: collects paths:
raco setup: /Users/sorawee/Library/Racket/development/collects
raco setup: /Users/sorawee/projects/racket/racket/collects/
raco setup: main pkgs: /Users/sorawee/projects/racket/racket/share/pkgs
raco setup: pkgs paths:
raco setup: /Users/sorawee/projects/racket/racket/share/pkgs
raco setup: /Users/sorawee/Library/Racket/development/pkgs
raco setup: links files:
raco setup: /Users/sorawee/projects/racket/racket/share/links.rktd
raco setup: /Users/sorawee/Library/Racket/development/links.rktd
raco setup: main docs: /Users/sorawee/projects/racket/racket/doc
raco setup: --- updating info-domain tables --- [12:36:55]
raco setup: updating: <user>/info-domain/compiled/cache.rktd
raco setup: --- pre-installing collections --- [12:36:55]
raco setup: --- installing foreign libraries --- [12:36:55]
raco setup: --- installing shared files --- [12:36:55]
raco setup: --- compiling collections --- [12:36:55]
raco setup: making: <user>/c211-handin (C211)
raco setup: in <user>/c211-handin
raco setup: --- creating launchers --- [12:36:59]
raco setup: --- installing man pages --- [12:36:59]
raco setup: --- building documentation --- [12:36:59]
raco setup: --- installing collections --- [12:37:00]
raco setup: --- post-installing collections --- [12:37:00]
Installation complete.

what kind of machine?

Mac M1

what racket version?

Commit 762b803f0a49090c4930961b9a which is from a few days ago

can I get you to try 8.2?

Like, the released 8.2? Sure

It works fine too

raco setup: version: 8.2
raco setup: platform: aarch64-macosx [cs]
raco setup: target machine: tarm64osx
raco setup: installation name: 8.2
raco setup: variants: cs

another issue is with sndfile-play
if I run the file again I get: invalid memory reference. Some debugging context lost
and it wont go away until i restart drracket entirely again..

ok thanks

the reason for rhombus is mainly because s-expression syntax isn;t popular? so in an alternate scenario where it is popular then rhombus would not exist? or are there more reasons for it?

there’s several reasons. I would say the main one is that Racket is supposed to be a platform for language oriented programming, and telling people “you can make any language you want as long as it uses s-expressions” is akin to Henry Ford telling people “you can have any color car you want as long as it’s black”

Fresh clean reinstall of windows 10 may update 2021 and trying (play-sound "./somefile.ogg" #t)
and I get: mciSendStringW: The specified device is not open or is not recognized by MCI.
LOL

There’s also reason where Racket has a long history so in retrospect some design decisions were wrong but Racket can’t change them as that breaks existing code

Taht sounds like a serious bug

think i might be forced to use rsound then..

LOP Racket isn’t at all limited to s-expressions though? They might be the least work to implement, but as a relative (and non-academic) newcomer I feel like the examples of LOP I was exposed to while learning might have been 50/50 s-exp based vs not

@samth can you block “michaelchinnick”? He sent the spam 15 days ago, and just did it again today

#lang racket
(require 2htdp/image
(only-in racket/gui/base play-sound))
;<https://opengameart.org/sites/default/files/vgmenuselect.wav>
(play-sound "./vgmenuselect.wav" #t)
can any windows 10 users test this and see if it plays? I am getting: mciSendStringW: All wave devices that can play files in the current format are in use. Wait until a wave device is free, and then try again.
also re-run the file a few times to make sure it plays again. Please post your build number of windows also, to find it type in System Information
on the start menu and a table should have a Version
for the build number, in my case its 19043 https://github.com/racket/gui/issues/239#issuecomment-905199159

the problem is that the wav file you mentioned is 32 bit. I used audacity to convert it to 16 bit and it plays fine.