Can't get sound using Racket RSound - racket

I'm trying to play sounds using Racket Rsound. I have a simple program in play.rkt that I'm running with racket play.rkt.
Using play-sound from the GUI library plays the sound as I'd expect:
#lang racket/base
(require racket/gui/base)
(play-sound "/media/tamayo/ExtraDrive1/Dropbox/fclooper/poc/sample.wav" #t)
Output:
$ racket play.rkt
ALSA lib pcm_dsnoop.c:618:(snd_pcm_dsnoop_open) unable to open slave
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
#t ;; plays audio correctly
But using RSound doesn't play any audio:
#lang racket/base
(require rsound)
(play (rs-read "/media/tamayo/ExtraDrive1/Dropbox/fclooper/poc/sample.wav"))
The output is the same as above except for the last line, which is "played sound" instead of #t.
Calling andplay instead also fails:
#lang racket/base
(require rsound)
(andplay (rs-read "/media/tamayo/ExtraDrive1/Dropbox/fclooper/poc/sample.wav" #t))
It also correctly plays audio when I run the same code directly from the Racket REPL:
$ racket
Welcome to Racket v7.3.
> (require rsound)
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
> (play (rs-read "/media/tamayo/ExtraDrive1/Dropbox/fclooper/poc/sample.wav"))
"played sound" ;; <-- and it does.
>
So the REPL knows how to correctly play audio via RSound, and racket can play using (play-sound ...), but my program just fails. Why?
Details
Ubuntu 18.04
$ racket --version
Welcome to Racket v7.3.
$ uname -a
Linux toast 5.0.0-23-generic #24~18.04.1-Ubuntu SMP Mon Jul 29 16:12:28 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

It turns out the program was simply exiting before it got a chance to actually play the sound!
I suppose this should have tipped me off to the fact that RSound works asynchronously:
Plays concurrently with an already-playing sound
This also explains why the REPL worked but the CLI didn't, since the REPL waits around for user input while continuing to run code in the background.
For now, a simple sleep hack works:
#lang racket/base
(play (rs-read "/media/tamayo/ExtraDrive1/Dropbox/fclooper/poc/sample.wav"))
(sleep 10)
(This is part of a looper program which runs forever waiting for user input to do things like swap out the sample sound. That's obviously way out of scope for this question, so sleep is the workaround for now, but in the actual GUI version will become irrelvant.)

According to the documentation for play, the function can't be used in the sub module main.
You can use the function like:
#lang racket/base
(play (rs-read "/media/tamayo/ExtraDrive1/Dropbox/fclooper/poc/sample.wav"))

Related

Emacs failed to load initialization file

I am using Emacs 25.3 under windows 10 platform.
It works fine until one time I started it and got the following message:
Warning (initialization): An error occurred while loading ‘
c:/Users/shore/AppData/Roaming/.emacs’:
Wrong type argument: listp, <html>
To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file. Start Emacs with
the ‘--debug-init’ option to view a complete error backtrace.
As instructed I used --debug-init option to start and got the following message:
Debugger entered--Lisp error: (wrong-type-argument listp <html>)
package--read-archive-file("archives/gnu/archive-contents")
package-read-archive-contents("gnu")
package-read-all-archive-contents()
package-initialize()
eval-buffer(#<buffer *load*> nil "c:/Users/shore/AppData/Roaming/.emacs" nil t) ; Reading at buffer position 275
load-with-code-conversion("c:/Users/shore/AppData/Roaming/.emacs" "c:/Users/shore/AppData/Roaming/.emacs" t t)
load("~/.emacs" t t)
[init-file-user system-type delayed-warnings-list user-init-file inhibit-default-init inhibit-startup-screen ms-dos "~" "/_emacs" windows-nt "/.emacs" directory-files nil "^\\.emacs\\(\\.elc?\\)?$" "~/.emacs" "^_emacs\\(\\.elc?\\)?$" initialization format-message "`_emacs' init file is deprecated, please use `.emacs'" "~/_emacs" t load expand-file-name "init" file-name-as-directory "/.emacs.d" file-name-extension "elc" file-name-sans-extension ".el" file-exists-p file-newer-than-file-p message "Warning: %s is newer than %s" sit-for 1 "default"] 7]()
command-line()
normal-top-level()
Can anyone tell me where my problem is and how to fix it?
It's telling you that when it tried to read file archives/gnu/archive-contents it expected to read Lisp (more specifically a Lisp list). Instead, it encountered <html> (presumably text in the file).
A guess is that you somehow downloaded or picked up an HTML file (perhaps one that describes the archive file or that has links to download it) instead of downloading or picking up a file of Lisp code. Try once again to obtain that archive file.

How do I fix the URL for the <TAB>-triggered automatic documentation lookup in the Common Lisp REPL?

SYNOPSIS
I'm trying to become competent at using Lisp. Though I'm very comfortable with
the command line and various REPLs for other interpreters (i.e. python,
irb/pry, perl -d), I keep feeling like an absolute newbie when it comes
to Lisp, for some reason.
In the Common Lisp REPL (clisp), when I use the key at the end of a
function name, it seems to be trying to provide me with reference information
about that function. This sounds damn useful.. if it actually worked. Below
is what actually happens when I do this. As far as I can tell, it seems to be
looking up the functions on a URL that doesn't (or no longer) exist/s. Perhaps
the HyperSpec has moved? What's the right way to fix this? What should I do?
ADDENDA
How I'm running Lisp
$ uname -a
Linux bob 4.4.0-38-generic #57-Ubuntu SMP Tue Sep 6 15:42:33 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
$ clisp --version
GNU CLISP 2.49 (2010-07-07) (built on toyol.buildd [127.0.1.1])
Software: GNU C 4.8.2
gcc -falign-functions=4 -W -Wswitch -Wcomment -Wpointer-arith -Wimplicit -Wreturn-type -Wmissing-declarations -Wno-sign-compare -Wno-format-nonliteral -O -falign-functions=4 -DENABLE_UNICODE -DDYNAMIC_FFI -DDYNAMIC_MODULES -I. -lreadline -lncurses -ldl /usr/lib/libavcall.so /usr/lib/libcallback.so -lsigsegv libgnu_cl.a
SAFETY=0 TYPECODES WIDE_HARD GENERATIONAL_GC SPVW_BLOCKS SPVW_MIXED TRIVIALMAP_MEMORY
libsigsegv 2.10
libreadline 5.2
libffcall 1.11
Features:
(READLINE REGEXP SYSCALLS I18N LOOP COMPILER CLOS MOP CLISP ANSI-CL COMMON-LISP LISP=CL INTERPRETER SOCKETS GENERIC-STREAMS LOGICAL-PATHNAMES SCREEN
FFI GETTEXT UNICODE BASE-CHAR=CHARACTER WORD-SIZE=64 PC386 UNIX)
C Modules: (clisp i18n syscalls regexp readline)
Installation directory: /usr/lib/clisp-2.49/
User language: ENGLISH
Machine: X86_64 (X86_64) bob [127.0.1.1]
Lisp-related packages currently installed on the system
$ aptitude search lisp | grep '^i'
i clisp - GNU CLISP, a Common Lisp implementation
i clisp-doc - GNU CLISP, a Common Lisp implementation (d
i A common-lisp-controller - Common Lisp source and compiler manager
i dh-lisp - Debhelper to support Common Lisp related p
What I get when I try to look up a function:
$ clisp -q
[1]> (write-line <TAB><TAB>
WRITE-LINE is the symbol WRITE-LINE, lies in #<PACKAGE COMMON-LISP>, is accessible in 11 packages CLOS, COMMON-LISP, COMMON-LISP-USER, EXPORTING,
EXT, FFI, POSIX, READLINE, REGEXP, SCREEN, SYSTEM, names a
;; connecting to "http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Data/Map_Sym.txt"...connected...HTTP/1.1 404 Not Found
;; "Date: Tue, 04 Oct 2016 02:34:52 GMT"
;; "Server: Apache/2.2.16 (Debian)"
;; "Content-Length: 333"
;; "Connection: close"
;; "Content-Type: text/html; charset=iso-8859-1"
;; ""
;; "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">"
;; "<html><head>"
;; "<title>404 Not Found</title>"
;; "</head><body>"
;; "<h1>Not Found</h1>"
;; "<p>The requested URL /projects/iiip/doc/CommonLISP/HyperSpec/Data/Map_Sym.txt was not found on this server.</p>"
;; "<hr>"
;; "<address>Apache/2.2.16 (Debian) Server at www.ai.mit.edu Port 80</address>"
;; "</body></html>"
;; connecting to "http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Data/Symbol-Table.text"...connected...HTTP/1.1 200 OK...45,322 bytes
;; SYSTEM::GET-CLHS-MAP(#<IO INPUT-BUFFERED SOCKET-STREAM CHARACTER www.ai.mit.edu:80>)...978/978 symbols
function.
ANSI-CL Documentation is at
"http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/fun_write-str_m_write-line.html"
;; connecting to "http://clisp.cons.org/impnotes/id-href.map"...connected...HTTP/1.1 302 Found --> "https://clisp.cons.org:80/impnotes/id-href.map"
;; connecting to "http://clisp.cons.orghttps://clisp.cons.org:80/impnotes/id-href.map"...
*** - PARSE-INTEGER: substring "" does not have integer syntax at position 0
The following restarts are available:
ABORT :R1 Abort main loop
Break 1 [2]>
I think this article should help you.
In essence you have to set up your CUSTOM:*BROWSERS* list, so clisp knows how to open the documentation.
In your .clisprc.lisp
(setf CUSTOM:*BROWSERS* '(
(:CHROMIUM "/usr/bin/chromium" "~a")))
(setf CUSTOM:*BROWSER* :CHROMIUM)
(setf CUSTOM:CLHS-ROOT "http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/FrontMatter/")
But you have to have chromium installed on your system. But you get the idea.

Can't run emacs as daemon

Trying to run
>emacs --daemon
in a shell produces
Warning: due to a long standing Gtk+ bug
http://bugzilla.gnome.org/show_bug.cgi?id=85715
Emacs might crash when run in daemon mode and the X11 connection is unexpectedly lost.
Using an Emacs configured with --with-x-toolkit=lucid does not have this problem.
Loading /home/me/.emacs.d/customizations/navigation.el (source)...
Loading /home/me/.emacs.d/.recentf...
Loading /home/me/.emacs.d/.recentf...done
Cleaning up the recentf list...
Loading /home/me/.emacs.d/customizations/navigation.el (source)...done
Loading /home/me/.emacs.d/customizations/ui.el (source)...
Backtrace:
emacs[0x505e79]
emacs[0x4ed4cc]
emacs[0x504b2e]
emacs[0x504ce3]
emacs[0x504d6f]
/lib/x86_64-linux-gnu/libpthread.so.0(+0xfc90)[0x7f1ba0acac90]
emacs[0x44cd4e]
emacs[0x471ad2]
emacs[0x55f137]
emacs[0x5939c3]
emacs[0x55ef53]
emacs[0x55f3fa]
emacs[0x566333]
emacs[0x566592]
emacs[0x55f137]
emacs[0x5939c3]
emacs[0x55ef53]
emacs[0x5939c3]
emacs[0x55ef53]
emacs[0x5939c3]
emacs[0x55ef53]
emacs[0x5939c3]
emacs[0x55ef53]
emacs[0x5939c3]
emacs[0x560148]
emacs[0x55e3e6]
emacs[0x58219a]
emacs[0x5824a9]
emacs[0x55f0fb]
emacs[0x5939c3]
emacs[0x55eb92]
emacs[0x55ef53]
emacs[0x55f309]
emacs[0x582a73]
emacs[0x55e607]
emacs[0x58219a]
emacs[0x5824a9]
emacs[0x55f0fb]
emacs[0x5939c3]
emacs[0x55eb92]
emacs[0x55ef53]
...
Error: server did not start correctly
Similar happens when I go with
> emacsclient -c -a ""
Starting emacs the normal way, I can do
M-x (server-start)
but I don't think it's actually working, because running
(defun --running-as-server ()
"Returns true if `server-start' has been called."
(condition-case nil
(and (boundp 'server-process)
(memq (process-status server-process)
'(connect listen open run)))
(error)))
in ielm gives only
(listen open run)
back instead of T or nil, and running
ELISP> (daemonp)
gives back nil. My version of Emacs is GNU Emacs 25.0.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.12.2) on Ubuntu 14.10. How can I get Emacs to run as a server/daemon?
I run emacs on Slackware 14.2 in daemon mode. My only issue was I was tired of seeing the warning. Other than that, the server ran fine for my purposes. What I did to get rid of the warning was to download the latest version of emacs from their official site
(emacs 26.1), removed the emacs package that came with my Slackware version, then unpacked and compiled the new version:
sudo tar -xvf emacs-26.1.tar.xz
./configure --with-x-toolkit=lucid
make
sudo make install
It's been running fine, no problems and no warning when the server starts.
You might want to give that a try. The GNU Project site here http://mirror.keystealth.org/gnu/emacs/ has the latest versions in .tar.gz format as well if you prefer
I was encountering this same error and was able to resolve it by removing my .emacs.d directory.
rm -fr ~/.emacs.d

SIGSEGV on memory access in Beaglebone Black (ARM) cross-compilation w/ Eclipse - Linaro

I am new to this, or better rusted (being 62).
Trying to develop on Beaglebone Black running Debian over IP using Eclipse Luna CDT and linaro tools.
I succeed in running and debugging standard helloworld.c.
Need to control GPIO fast (to connect to uncommon peripheral) but
all attempts to read or write to memory mapped registers fail.
Instruction
i = (*((volatile unsigned int *)(0x4804c130)))
which should read GPIO status register results in
Child terminated with signal = 0xb (SIGSEGV)
GDBserver exiting
logout
This is the source (hellobone.c) I compile without errors:
int main(void)
{
unsigned int i = 1;
i = (*((volatile unsigned int *)(0x4804c130))) ;
}
(I tried all variations on this pointer arithmetic)
Makefile trace: (ignore includes)
---COMPILE--- C:/hellobone/source/hellobone.c
"C:\gcc-linaro\bin\arm-linux-gnueabihf-gcc.exe" -c -o C:/hellobone/object/hellobone.o C:/hellobone/source/hellobone.c -marm -O0 -g -I. -IC:/hellobone/include
.
---LINK---
"C:\gcc-linaro\bin\arm-linux-gnueabihf-gcc.exe" -o hellobone C:/hellobone/object/hellobone.o C:/hellobone/object/tools.o C:/hellobone/object/gpio_v2.o -marm -O0 -g -I. -IC:/hellobone/include
.
The binary also crashes running as root from TTY:
root#beaglebone:~# ./hellobone
Segmentation fault
I installed Eclipse on the BBB Debian and read and write to memory works just fine. Just too slow compiling, and unstable, to be practical.
Reading memory should be doable. What am I doing wrong?
I suspect
GNU gdbserver (GDB) 7.4.1-debian
This gdbserver was configured as "arm-linux-gnueabihf"
But maybe I am missing something obvious, have not seen any post on this problem...
Really stuck. Being working on this for months now. Setting up toolchain very frustrating, nothing works as in YouTube videos..
Any help would be really appreciated
Marco
You need to mmap /dev/mem to access memory mapped peripherals through physical addresses. Easiest example / code I know does this goes by the name devmem2.
Thank you a lot, that certainly helped.
I compiled the program you gave me and it worked perfect in run mode in Eclipse, and in terminal on the remote machine.
Curiously, when running the Eclipse debugger, it crashes executing:
if((fd = open("/dev/mem", O_RDWR | O_SYNC)) == -1) FATAL;
I get this error message from gdbserver
Remote debugging from host 192.168.1.2
/root/hellobone: relocation error: /root/hellobone: symbol �pen, version GLIBC_2.4 not defined in file libc.so.6 with link time reference
Child exited with status 127
GDBserver exiting
Have been trying to use fopen but that gives a segmentation fault. Anyhow, I think that is a toolchain issue and not a programming issue.

Error starting sbcl under slime on Vista

I'm having trouble getting SBCL to start under slime. I've messed things up and I don't know how to recover. This was working fine until I...
Had a problem loading a package via asdf. At which point I started debugging the asdf.lisp provided with SBCL to see what was going wrong. The sole change I made was to put a (break) in which I removed once I'd figured out what was wrong. All was fine until the next time I tried to start SBCL.
Then I got a swank compilation error saying that the asdf.fasl was older than the asdf.lisp file. That made sense to me so I recompiled the asdf.fasl. The output I'm now getting is:
(progn (load "c:\\emacs-23.1\\site-lisp\\slime\\swank-loader.lisp" :verbose t) (funcall (read-from-string "swank-loader:init")) (funcall (read-from-string "swank:start-server") "c:\\Users\\GILESR~1\\AppData\\Local\\Temp\\slime.3068" :coding-system "iso-latin-1-unix"))
This is SBCL 1.0.37, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.
SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses. See the CREDITS and COPYING files in the
distribution for more information.
This is experimental prerelease support for the Windows platform: use
at your own risk. "Your Kitten of Death awaits!"
*
; loading #P"c:\\emacs-23.1\\site-lisp\\slime\\swank-loader.lisp"
; loading #P"c:\\hacking\\emacs\\.slime\\fasl\\2010-07-30\\sbcl-1.0.37-win32-x86\\swank-backend.fasl"
; loading #P"c:\\hacking\\emacs\\.slime\\fasl\\2010-07-30\\sbcl-1.0.37-win32-x86\\swank-source-path-parser.fasl"
; loading #P"c:\\hacking\\emacs\\.slime\\fasl\\2010-07-30\\sbcl-1.0.37-win32-x86\\swank-source-file-cache.fasl"
; compiling file "c:\\emacs-23.1\\site-lisp\\slime\\swank-sbcl.lisp" (written 22 JUL 2010 08:15:02 AM):
; file: c:\emacs-23.1\site-lisp\slime\swank-sbcl.lisp
; in: EVAL-WHEN (:COMPILE-TOPLEVEL :LOAD-TOPLEVEL :EXECUTE)
; (REQUIRE 'SWANK-BACKEND::SB-BSD-SOCKETS)
;
; caught ERROR:
; (during compile-time-too processing)
; The function ASDF::MODULE-PROVIDE-ASDF is undefined.
; (REQUIRE 'SWANK-BACKEND::SB-INTROSPECT)
;
; caught ERROR:
; (during compile-time-too processing)
; The function ASDF::MODULE-PROVIDE-ASDF is undefined.
; (REQUIRE 'SWANK-BACKEND::SB-POSIX)
;
; caught ERROR:
; (during compile-time-too processing)
; The function ASDF::MODULE-PROVIDE-ASDF is undefined.
; (REQUIRE 'SWANK-BACKEND::SB-CLTL2)
;
; caught ERROR:
; (during compile-time-too processing)
; The function ASDF::MODULE-PROVIDE-ASDF is undefined.
;
; compilation unit aborted
; caught 1 fatal ERROR condition
; caught 4 ERROR conditions
;
; compilation aborted because of fatal error:
; SB-INT:SIMPLE-READER-PACKAGE-ERROR at 1839 (line 62, column 18) on #<SB-SYS:FD-STREAM
; for "file c:\\emacs-23.1\\site-lisp\\slime\\swank-sbcl.lisp"
; {24564B89}>:
; package "SB-POSIX" not found
; ; compilation aborted after 0:00:00.045
;;
;; Error while compiling c:\emacs-23.1\site-lisp\slime\swank-sbcl.lisp:
;; COMPILE-FILE returned NIL.
;; Aborting.
So it's not finding some stuff it needs in my recompiled asdf. In order to resolve this I've done a complete uninstall and reinstall of SBCL. No joy. I've got nothing in my .sbclrc either.
Update: On viewing the asdf.lisp source code the missing functions are definitely in the file. The thing that's preventing them from compiling is I think the line:
#+(and sbcl sbcl-hooks-require)
My knowledge of lisp is currently not sufficient to compile the asdf file in the environment to trigger the above conditional compilation statement.
I've sorted the problem using the following steps:
Fire up sbcl from Windows start menu.
Run the following code to add the sbcl-hooks-require symbol to the feature list:
(push :sbcl-hooks-require features)
Recompile asdf.lisp. In order to do this I needed to recompile asdf outside of the installed C:\Program files\Steel... directory as the UAC on Windows Vista will stop the fasl being written. For example:
(compile-file "C:\foobar\asdf.lisp")
Copy the generated fasl back to C:\Program files\Steel... to overwrite the original fasl.
Update: The formatting on stackoverflow has knocked out some of the code bits. The code should be as follows:
(push :sbcl-hooks-require *features*)
(compile-file "C:\\foobar\\asdf.lisp")