jestarray
2021-8-24 18:16:49

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?


soegaard2
2021-8-24 18:26:17

For simple sounds, you can use play-sound.


jestarray
2021-8-24 18:35:13

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


jestarray
2021-8-24 18:35:18

I should mention we’re both on linux


jestarray
2021-8-24 18:36:15

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..


soegaard2
2021-8-24 18:45:31

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.


soegaard2
2021-8-24 18:47:11

I don’t know the default.


jestarray
2021-8-24 18:48:46

seemsl ike it has no default


jestarray
2021-8-24 18:48:48

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.


jestarray
2021-8-24 18:51:51

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


soegaard2
2021-8-24 18:52:43

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


shu--hung
2021-8-24 18:53:12

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



soegaard2
2021-8-24 18:55:02

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


jestarray
2021-8-24 18:57:27

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


shu--hung
2021-8-24 18:57:58

That sounds okay


jestarray
2021-8-24 18:58:11

thought it would be defined…


jestarray
2021-8-24 18:58:20

anywhoo, i have aplay installed already


jestarray
2021-8-24 18:58:48

ahh


shu--hung
2021-8-24 18:58:50

Does directly calling aplay with the file works?


jestarray
2021-8-24 18:58:51

seeems like aplay is the issue


jestarray
2021-8-24 18:59:07

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


jestarray
2021-8-24 18:59:08

interesting


soegaard2
2021-8-24 19:02:33

Are you on Ubuntu?


jestarray
2021-8-24 19:03:05

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


soegaard2
2021-8-24 19:03:42

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


jestarray
2021-8-24 19:04:22

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.


jestarray
2021-8-24 19:05:28

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


massung
2021-8-24 19:06:05

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


jestarray
2021-8-24 19:06:39

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


jestarray
2021-8-24 19:06:42

my .wav file doesnt work with aplay also ;s


shu--hung
2021-8-24 19:08:43

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


shu--hung
2021-8-24 19:09:36

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


jestarray
2021-8-24 19:10:01

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


jestarray
2021-8-24 19:11:29

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


soegaard2
2021-8-24 19:13:07

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


shu--hung
2021-8-24 19:13:50

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


jestarray
2021-8-24 19:17:06

jestarray
2021-8-24 19:17:08

alright


shu--hung
2021-8-24 19:22:49

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


jestarray
2021-8-24 19:31:28

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


shu--hung
2021-8-24 19:32:57

Okay. Because that mpv code should work.


jestarray
2021-8-24 19:33:35

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


samth
2021-8-24 19:36:07

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.


sorawee
2021-8-24 19:37:17

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: &lt;user&gt;/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: &lt;user&gt;/c211-handin (C211) raco setup: in &lt;user&gt;/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.


samth
2021-8-24 19:37:38

what kind of machine?


sorawee
2021-8-24 19:37:46

Mac M1


samth
2021-8-24 19:38:16

what racket version?


sorawee
2021-8-24 19:39:34

Commit 762b803f0a49090c4930961b9a which is from a few days ago


samth
2021-8-24 19:39:49

can I get you to try 8.2?


sorawee
2021-8-24 19:39:59

Like, the released 8.2? Sure


sorawee
2021-8-24 19:43:42

It works fine too


sorawee
2021-8-24 19:44:03

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


jestarray
2021-8-24 19:47:06

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..


samth
2021-8-24 19:47:19

ok thanks


jestarray
2021-8-24 19:57:02

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?


notjack
2021-8-24 20:09:08

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”


jestarray
2021-8-24 20:26:03

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


shu--hung
2021-8-24 20:30:39

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


shu--hung
2021-8-24 20:37:44

Taht sounds like a serious bug


jestarray
2021-8-24 22:16:32

think i might be forced to use rsound then..


joel
2021-8-25 00:07:53

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


sorawee
2021-8-25 03:07:51

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


jestarray
2021-8-25 05:47:58

#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


alexharsanyi
2021-8-25 06:36:58

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.