conjure
conjure copied to clipboard
REPL hangs using overtone
Hi, i'm encountering issues using overtone with conjure.
I use a new lein project (tutorial
) with the following project.clj
:
(defproject tutorial "0.1.0-SNAPSHOT"
:dependencies [[org.clojure/clojure "1.9.0"]
[overtone "0.10.6"]]
:jvm-opts ^:replace []
:plugins [[cider/cider-nrepl "0.24.0"]]
:repl-options {:init-ns tutorial.core})
There is one source file src/tutorial/core.clj
with the following content
(ns tutorial.core
(:use overtone.live))
(defsynth foo [freq 300 dur 0.5]
(let [src (saw [freq (* freq 1.01) (* 0.99 freq)])
low (sin-osc (/ freq 2))
filt (lpf src (line:kr (* 10 freq) freq 10))
env (env-gen (perc 0.1 dur) :action FREE)]
(out 0 (pan2 (* 0.8 low env filt)))))
Inside a lein repl
everything works just fine. Overtone loads correctly and I can use the (foo)
to play the synth repeatedly. But when I connect to the repl from Conjure, and run (foo)
the repl seems never to return and I cannot run any command unless I ConjureCljInterrupt
.
I am using neovim with an init.vim
containing only:
call plug#begin('~/.config/nvim/plugged')
Plug 'Olical/conjure'
call plug#end()
I hope anyone can help.
Hm, and what happens if you use (future (foo))
? So as to run the code within another thread? I'm not sure how the synth functions work, if they block forever then this behaviour is expected and the right approach would be to wrap them in future
s or something similar to run them outside the main thread.
Like the other issue, would you be able to reproduce this with let g:conjure#debug = v:true
for me? Thanks a lot!
When running (future (foo))
it works and the repl returns responsive. So that can be used as a workaround.
Yesterday I gave overtone a try with cider and emacs and the behavior was also unexpected. So maybe there is a more general problem. I had a look at the implementations in overtone, but at the moment I'm not familiar enough with Clojure. Maybe some day I have the time to investigate more.
The outptut with conjure#debug
set is (executed (foo)
three times using \ee
):
; eval (current-form): (foo)
; debug: send
{:code "(ns tutorial.core)"
:id "2160ff4d-f87b-4f95-80d3-f5cbb46d2802"
:nrepl.middleware.print/options {:associative 1 :length 500 :level 50}
:nrepl.middleware.print/print "conjure.internal/pprint"
:op "eval"
:session "93d387b0-673e-4c88-b018-3905d750c208"}
; debug: send
{:code "(foo)"
:column 1
:file "/home/dweber/gh/tutorial/src/tutorial/core.clj"
:id "94fe9c20-aaee-4d43-b636-a0ad25ee737c"
:line 17
:nrepl.middleware.print/options {:associative 1 :length 500 :level 50}
:nrepl.middleware.print/print "conjure.internal/pprint"
:ns "tutorial.core"
:op "eval"
:session "93d387b0-673e-4c88-b018-3905d750c208"}
; debug: receive
{:id "2160ff4d-f87b-4f95-80d3-f5cbb46d2802"
:ns "tutorial.core"
:session "93d387b0-673e-4c88-b018-3905d750c208"
:value "nil"}
; debug: receive
{:id "2160ff4d-f87b-4f95-80d3-f5cbb46d2802"
:session "93d387b0-673e-4c88-b018-3905d750c208"
:status ["done"]}
; debug: receive
{:changed-namespaces {}
:id "2160ff4d-f87b-4f95-80d3-f5cbb46d2802"
:repl-type "clj"
:session "93d387b0-673e-4c88-b018-3905d750c208"
:status ["state"]}
; --------------------------------------------------------------------------------
; eval (current-form): (foo)
; debug: send
{:code "(foo)"
:column 1
:file "/home/dweber/gh/tutorial/src/tutorial/core.clj"
:id "7f7d1740-b436-400b-b655-a67a609d4115"
:line 17
:nrepl.middleware.print/options {:associative 1 :length 500 :level 50}
:nrepl.middleware.print/print "conjure.internal/pprint"
:ns "tutorial.core"
:op "eval"
:session "93d387b0-673e-4c88-b018-3905d750c208"}
; --------------------------------------------------------------------------------
; eval (current-form): (foo)
; debug: send
{:code "(foo)"
:column 1
:file "/home/dweber/gh/tutorial/src/tutorial/core.clj"
:id "52649ed4-bc47-4d23-a198-bcafe2a471a8"
:line 17
:nrepl.middleware.print/options {:associative 1 :length 500 :level 50}
:nrepl.middleware.print/print "conjure.internal/pprint"
:ns "tutorial.core"
:op "eval"
:session "93d387b0-673e-4c88-b018-3905d750c208"}
A following \ei
leads to this output:
; debug: send
{:id "059e3314-001f-4d5d-ba1e-253ea9d85b9e"
:op "interrupt"
:session "93d387b0-673e-4c88-b018-3905d750c208"}
; debug: send
{:code "#?(:clj 'clj :cljs 'cljs :cljr 'cljr :default 'unknown)"
:id "47826573-d40b-4f73-bfd8-2829a765d6c4"
:op "eval"
:session "93d387b0-673e-4c88-b018-3905d750c208"}
; debug: receive
{:id "94fe9c20-aaee-4d43-b636-a0ad25ee737c"
:session "93d387b0-673e-4c88-b018-3905d750c208"
:status ["done" "interrupted"]}
; debug: receive
{:id "059e3314-001f-4d5d-ba1e-253ea9d85b9e"
:session "93d387b0-673e-4c88-b018-3905d750c208"
:status ["done"]}
; --------------------------------------------------------------------------------
; Interrupted: session: Field Spaniel (Timeout)
Oh interesting! Maybe it's just when it's evaluated under an nREPL process... I'd definitely have a look at the overtone issues just to see if there are any open (or closed) issues to do with nREPL things.
I'd definitely have a look at the overtone issues
Yes I had a look but didn't find one.
I am facing the same issue, i am simply following https://github.com/overtone/overtone/blob/master/src/overtone/examples/getting_started/basic.clj
And ran the (foo 440) but nRepl hanged and didnt respond. Despite of executing (future (foo)) the nRepl yet hanged. Checked the activity log, found 45% RAM is idle