Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(load-sample ...) results in NullPointerException #448

Open
ericclack opened this issue Dec 31, 2019 · 9 comments
Open

(load-sample ...) results in NullPointerException #448

ericclack opened this issue Dec 31, 2019 · 9 comments

Comments

@ericclack
Copy link

Following the lein instructions here:
https://github.com/overtone/overtone#installation

Then opening a REPL and running:

(use 'overtone.live)
(load-sample "resources/samples/clap.wav")

Results in:

1. Unhandled java.lang.NullPointerException
   (No message)
              Numbers.java: 1018  clojure.lang.Numbers/ops
              Numbers.java:  226  clojure.lang.Numbers/lt
                buffer.clj:   67  overtone.sc.buffer/assert-less-than-max-buffers
                buffer.clj:   62  overtone.sc.buffer/assert-less-than-max-buffers
                buffer.clj:  168  overtone.sc.buffer/buffer-alloc-read
                buffer.clj:  150  overtone.sc.buffer/buffer-alloc-read
                sample.clj:  128  overtone.sc.sample/load-sample*
                sample.clj:  119  overtone.sc.sample/load-sample*
                sample.clj:  163  overtone.sc.sample/load-sample
                sample.clj:  138  overtone.sc.sample/load-sample
               RestFn.java:  410  clojure.lang.RestFn/invoke
                  Var.java:  381  clojure.lang.Var/invoke
                      REPL:   97  user/eval17475
                      REPL:   97  user/eval17475
             Compiler.java: 7062  clojure.lang.Compiler/eval
             Compiler.java: 7025  clojure.lang.Compiler/eval
                  core.clj: 3206  clojure.core/eval
                  core.clj: 3202  clojure.core/eval
                  main.clj:  243  clojure.main/repl/read-eval-print/fn
                  main.clj:  243  clojure.main/repl/read-eval-print
                  main.clj:  261  clojure.main/repl/fn
                  main.clj:  261  clojure.main/repl
                  main.clj:  177  clojure.main/repl

This worked OK in Overtone 10.3.0.

@ericclack
Copy link
Author

ericclack commented Dec 31, 2019

Also, I'm running Mac OS 10.14.6, with Emacs and Cider. I had been running Overtone 0.10.3 prior to changing to the latest version.

This works fine:

user> (use 'overtone.inst.synth)
user> (overpad)

I'm happy to test / explore if you give me some pointers.

@ericclack
Copy link
Author

This is a duplicate of this closed issue?
#427

@hlolli
Copy link
Member

hlolli commented Jan 8, 2020

Yes this should be fixed on master, I'll try to brew a new release in next days. So if you put this in your deps.edn

 {overtone/overtone {:git/url "https://github.com/overtone/overtone.git" :sha "e55205fe9d3b499d0fb12931791fe6299d9624a6"}}

you should be fine, otherwise I plan to increase the default max-buffer size before next release.

@garaud
Copy link

garaud commented Feb 18, 2020

I had some similar issues. As @hlolli said, I increased the value of max-buffers.

I wrote this in my ~/.overtone/config.clj

:sc-args {:max-buffers 4096}

and this fixed the issue.

@heyarne
Copy link

heyarne commented Apr 22, 2020

Yes this should be fixed on master, I'll try to brew a new release in next days. So if you put this in your deps.edn

 {overtone/overtone {:git/url "https://github.com/overtone/overtone.git" :sha "e55205fe9d3b499d0fb12931791fe6299d9624a6"}}

I tried this via clj -Arebel -Sdeps '{:deps {overtone/overtone {:git/url "https://github.com/overtone/overtone.git" :sha "6ac57556014875357ef0c3355a11602069420a50"}}}' (latest master, -Arebel is an alias for rebel-readline). (use 'overtone.live) throws an error for me:

Checking out: https://github.com/overtone/overtone.git at 6ac57556014875357ef0c3355a11602069420a50
[Rebel readline] Type :repl/help for online help info
user=> (use 'overtone.live)
--> Loading Overtone...
Syntax error (IllegalArgumentException) compiling at (overtone/jna_path.clj:37:1).
Cannot open <nil> as a Reader.
user=>

The same happens with the commit you mentioned, so the sample problem remains for me. I can (use 'overtone.live) but can't play samples b/c of the mentioned NullPointerException. Any idea what's wrong? I'm using the linux kernel 5.6.5 and clojure 1.10.1.

@hlolli
Copy link
Member

hlolli commented Apr 22, 2020

I think I know what's causing this. You could try to physically clone the repository. It looks like I made a silly decision there expecting the deps.edn to be always available on classpath or in resource-path (inside .jar file from classpath). Alternatively, since clj is an executable which badigeon calls, it could be because of the alpha state of tools-deps, some non-backwards compatable change happened and your version is too new. Either case, this needs fixing.

@hlolli
Copy link
Member

hlolli commented Apr 22, 2020

I'm really caught up until sunday next week because of deadlines. You think you could debug that which is happening in this snippet

(defn- slurp-deps-edn []
  (if (.exists (io/file "deps.edn"))
    (deps-reader/slurp-deps "deps.edn")
    (-> "deps.edn"
        io/resource
        slurp
        edn/read-string
        canonicalize-all-syms)))

;; extract the native dependencies with badigeon
(bundle/extract-native-dependencies
 (System/getProperty "user.dir")
 {:deps-map (slurp-deps-edn)
  :allow-unstable-deps? true
  :native-path "native"
  :native-prefixes {'overtone/ableton-link ""
                    'overtone/scsynth "native"
                    'overtone/scsynth-extras "native"}})

Its only goal is to extract the .so files so that the ldload can call them from inside jna. In very simple term, just unzip operation.

I can approve a fixing pr quickly.

@heyarne
Copy link

heyarne commented Apr 22, 2020

I can confirm that it works with the clojure / clj command line tools when running it from the root of the coned repository – using the overtone.live namespace as well as setting up and playing samples. Cool! I'll try to take a look at the code you posted!

@bkushigian
Copy link
Contributor

Any updates on this? I'm getting a similar error with Emacs/cider running (sample (freesound-path nnnn)).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants