RSound and libportaudio-2.dll

Hello,
I'm trying to work with sounds and I installed the RSound package.
When I try to run:

(require rsound)
(play ding)

the result is an error:

I found the libportaudio-2.dll on dll-files.com. I tried to copy it in:
C:\Program Files\Racket\lib\
but it didn't work.

What can I do?

Matteo

The paths I'm seeing here suggest that this is Windows. You should not have to install any dll's yourself on Windows. Let me take a quick look to see where that should have been installed....

Ooh, here's a question. Is this a 32-bit or 64-bit machine / racket install? Can you run this program and tell me what it produces?

#lang racket/base

(list
 (system-type 'arch)
 (system-type 'word))

I'm working on windows 10 and intel i3 CPU.

#lang racket/base

(list
 (system-type 'arch)
 (system-type 'word))
=> '(x86_64 64)

Okay, that's good. Next up, can you check whether the "portaudio-x86_64-win32" package got installed? The easiest way to do this is probably to open the "File > Package Manager" menu, click on "Currently Installed", and type "portaudio". Here's what I see (I'm running this on a mac):

If the answer is yes

...

Hmm... I just went and poked around a bit, and now I'm wishing I had a windows platform to test on. I see that the installed dll is called "libportaudio.dll", not "libportaudio-2.dll". On the other hand, it looks to me like the code in the portaudio library should try the version-less name as well. Here's the beginning of that file:

#lang racket/base

;; this file provides an FFI wrapper around the existing portaudio
;; API.  It does not attempt to guarantee safety, and it's definitely
;; possible to crash DrRacket by calling these functions improperly.
;; there are a few utility functions at the bottom that are used in
;; order to manage things a bit.

(require setup/collection-search
         ffi/unsafe
         racket/runtime-path
         racket/match
         (for-syntax racket/base syntax/parse)
         (only-in '#%foreign ffi-callback))

(provide (all-defined-out))


(define linux-err-msg
  "Note: on Linux/unix, you need to install the libportaudio library\
 yourself. Underlying error message: ~a")

(define not-false? (λ (x) x))
(define portaudio-version-strings '("2" "2.0.0" #f))
(define libportaudio
  (with-handlers
      ([exn:fail?
        (lambda (exn)
          (cond
            [(equal? (system-type) 'unix)
             (error 'rsound
                    linux-err-msg
                    (exn-message exn))]
            [else
             (raise exn)]))])
    (ffi-lib "libportaudio"
             portaudio-version-strings)))

... and it looks to me like this should run as standalone code. Can you confirm for me that this signals the same error? If so, try removing the "2" and the "2.0.0" from the list above, and see what happens.

The "portaudio-x86_64-win32" package is installed:

The same error is signaled:

Matteo

Wait, I'm confused. It looks like you added an empty string to the list, rather than removing the two elements I suggested. Am I missing something here?

I'm sorry John, I thought it was the same.

I tried to remove and reinstall RSound and portaudio. An error came out:

Matteo

Yep... this is definitely a bug. I see what appears to be the problem, and I've pushed a change to the relevant repo. It will be a few hours before the catalog picks up that change, I believe. I will test again once that happens. My sincere apologies!

Yeah no... there's another bug now. I hope to take a look at this in the next day or two.

Okay, I took a look, and I see the problem. The dll for Windows is an older version; the change to version 19 changed the interface to the dll; basically, the dll needs to be recompiled. I feel like the right solution here is to use something like we use for building the windows binaries for Racket, but I totally have not had time to set this up, and I'm betting I'll run into some interesting roadblocks. So basically: this package needs a more up-to-date version of the portaudio dll. Ugh.

1 Like

I would like to share what I did when I got the error messages : racket\8.12\collects\ffi\unsafe.rkt:134:0: ffi-lib: could not load foreign library , path: libportaudio-2.dll , system error: could not find the module.; win_err=126

I manually compiled the portaudio package and got libportaudio-2.dll then copy the dll to two paths where libportaudio.dll is located : $HOME$\AppData\Roaming\Racket\8.12\lib\libportaudio-2.dll , $HOME$\AppData\Roaming\Racket\8.12\pkgs\portaudio-x86_64-win32\libportaudio-2.dll

I went to PortAudio - an Open-Source Cross-Platform Audio API and downloaded portaudo_stable file : pa_stable_v190700_20210406.tgz from https://files.portaudio.com/archives/pa_stable_v190700_20210406.tgz

My system has Windows 11 and mingW64 with gcc installed.

I unziped the pa_stable_v190700_20210406.tgz file, changed to the unzipped directory, then did compilation process : using =mingW64=, installed =gcc=

Command lines in mingW64 terminal was
$ ./configure --prefix=some_path
$ make
$ make install

The compilation was successful.
I didn't use special options for "./configuration" except "--prefix=some_directory" option.

After the "configure / make / make install" process , I found "libportaudio-2.dll" in a subdirectory of the compilation and copied the dll file to two paths where "libportaudio.dll" is located : $HOME$\AppData\Roaming\Racket\8.12\lib\libportaudio-2.dll , $HOME$\AppData\Roaming\Racket\8.12\pkgs\portaudio-x86_64-win32\libportaudio-2.dll

Then I tried "(require rsound)" in DrRacket and got another error messages

rsound/private/win32/x86_64/3m/buffer-add.dll
AppData\Roaming\Racket\8.12\pkgs\rsound\rsound\private.\win32\x86_64\cs\buffer-add.dll
system error: could not find the module ; win_err=126

My Racket installation didn't have the directory of "x86_64\cs\whatever".
I manually made new directory with the name : AppData\Roaming\Racket\8.12\pkgs\rsound\rsound\private\win32\x86_64\cs

And I copied "3m/buffer-add.dll" to "cs/buffer-add.dll" ; actually
from AppData\Roaming\Racket\8.12\pkgs\rsound\rsound\private\win32\x86_64\3m\buffer-add.dll to AppData\Roaming\Racket\8.12\pkgs\rsound\rsound\private\win32\x86_64\cs\buffer-add.dll

I tried "(require rsound)" in DrRacket again and got no error messages.
Next, I tried "(play ding)" in DrRacket and heard clear "ding" sound from my PC speaker.

I hope what I showed may give a bit useful information.

4 Likes

Is there an easy fix for this yet? I've got students who want to use this package for a class project, and prefer a slightly less technical solution than building the library themselves!

ooh... let me see if I can make some progress on this in the next hour. Okay, actually, the first thing I should do is ask for help with cross-compilation using MinGW.

Okay, actually, I got pretty far by following the lead of distro-build. Specifically, it looks like the racket/distro-build:crosswin docker image probably has what I need. I can use remote-shell instructions to start the docker container and copy the image in, and the I have successfully shelled in and tried to run the build. My first try failed because I didn't do anything special in configure && make, so unsurprisingly I got linux/aarch64 shared libs, which are not what you want. I'm not at all familiar with building using mingw, so there are probably standard ways to tell configure to use mingw. I think I should probably ask the portaudio folks...

Oh! Here's a question: portaudio supports a bunch of different interfaces; specifically, [wmme|directx|asio|wasapi|wdmks]. It looks like wmme is the "lowest common denominator", and that portaudio can compile to this interface without additional header files. Do you know whether wmme support is supported and/or performant on the machines you're using? No problem if you don't know. I really should get a windows machine so I can test this...

okay, spent more time researching and paging everything in... looks like wasapi is probably the interface we want to use, and x86_64-w64-mingw is probably the host setting.

Whoa! Got a dll. Crazy. That's not the only one, I need to compile the other little baby dll for copying blocks of memory. This could be a 30-minute job. Maybe later tonight!

Sorry for dragging you through my stream of consciousness, I have no faith that I will complete the task, urggh. I have committed and pushed my work in a new file in the portaudio repo...

1 Like

@kingjaceo Okay, progress is being made. I've updated the portaudio library, and it now appears to me that the rsound library has a tiny buffer-copying dll which needs to be recompiled as well.