-
Notifications
You must be signed in to change notification settings - Fork 11
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
Changing arguments interactively #28
Comments
Hi!
All patterns will repeat infinitely by default, and any changes made to a pattern definition (i.e. In the case of
Thinking about it now, having
Unfortunately, it's not super convenient to do that--at least, not yet. Mainly, (defparameter *mouse-x-value* 0)
(cl-collider:add-reply-responder
"/mouse-x"
(lambda (node trig &rest value)
(declare (ignorable node trig))
(setf *mouse-x-value* (car value))))
(proxy :mouse-x-value-poller
(let ((mouse-x (mouse-x.kr 0 1 :linear 0)))
(send-reply.kr (impulse.kr 10) "/mouse-x" (list mouse-x)))) The proxy will start a synth on the server that polls The Normally at this point I would say "now you can simply use something like I should also note that even with this change, Here's the full version of the code for you: (defparameter *mouse-x-value* 0)
(cl-collider:add-reply-responder
"/mouse-x"
(lambda (node trig &rest value)
(declare (ignorable node trig))
(setf *mouse-x-value* (car value))))
(proxy :mouse-x-value-poller
(let ((mouse-x (mouse-x.kr 0 1 :linear 0)))
(send-reply.kr (impulse.kr 10) "/mouse-x" (list mouse-x))))
(pb :pattern
:instrument :block
:embed (pbjorklund (pf (let ((v (round (* 16 *mouse-x-value*))))
(format t "~&~s~%" v)
v))
16
:dur 4
:repeats 1))
(play :pattern) In any case, let me know if any of this doesn't work for you, or is unclear. In the meantime I'll leave this issue open so I remember to look at making pbjorklund's |
Setting :repeats to 1 does what I want (:end-quant 4 also works).
Thanks a lot. I don't have an opinion on whether the pattern
should change immediately or after the cycle ends. I was expecting
the latter if that matters. I'll try the new code tomorrow.
|
I did a git pull and I can see the change, but the repl prints 0s
every second or so and I hear no sound.
|
If you're just using the code snippet I posted, the (cl-collider:add-reply-responder
"/mouse-x"
(lambda (node trig &rest value)
(declare (ignorable node trig))
(format t "~&Got value ~s from the server.~%" (car value))
(setf *mouse-x-value* (car value)))) If you run that and you don't see any messages like As for not hearing any sound, I'm guessing you restarted your Lisp, and maybe you forgot to start the SuperCollider server again (or connect it via JACK) after doing that. Are you sure you ran these? (setf *s* (make-external-server "localhost" :port 4444))
(server-boot *s*)
(jack-connect) If so, it could also be that you didn't re-send the Let me know if you're still having any issues after trying those suggestions. |
I see the "Got value 0.11145834 from the server" messages and the number changes as I move the mouse. Now with the original function, when I evaluate the pb function I see:
|
Looks like you're evaluating the |
Probably the best solution would be to define your own package, and make it (defpackage #:my-cool-package
(:use #:cl
#:cl-collider
#:cl-patterns)
(:shadowing-import-from #:cl-patterns
#:play
#:stop
#:quant))
(in-package #:my-cool-package)
;; your code goes here The Alternatively, this is shorter and works just as well, as long as you have (uiop:define-package #:my-cooler-package
(:mix #:cl
#:cl-patterns
#:cl-collider))
(in-package #:my-cooler-package)
;; your code goes here |
Let's take a step back. What's wrong with the script I'm using, and how do I fix it? (ql:quickload :cl-collider)
(in-package :sc-user)
(setf *s* (make-external-server "localhost" :port 4444))
(server-boot *s*)
(jack-connect)
(in-package :cl-collider)
(defsynth block ((gain 1))
(let* ((env (line.kr 4 0 .03 :act :free))
(sig (sin-osc.ar 500 0 env)))
(out.ar 0 (pan2.ar sig 0 gain))))
(defparameter *mouse-x-value* 0)
(cl-collider:add-reply-responder
"/mouse-x"
(lambda (node trig &rest value)
(declare (ignorable node trig))
(setf *mouse-x-value* (car value))))
(proxy :mouse-x-value-poller
(let ((mouse-x (mouse-x.kr 0 1 :linear 0)))
(send-reply.kr (impulse.kr 10) "/mouse-x" (list mouse-x))))
(ql:quickload :cl-patterns/supercollider)
(cl-patterns:start-backend :supercollider)
(in-package #:cl-patterns)
(start-clock-loop :tempo 130/60)
;; This one plays
;; (pb :pattern
;; :instrument :block
;; :embed (pbjorklund 7 16 :dur 4 :repeats 1))
;; This one fails
(pb :pattern
:instrument :block
:embed (pbjorklund (pf (let ((v (round (* 16 *mouse-x-value*))))
(format t "~&~s~%" v)
v))
16
:dur 4
:repeats 1))
(play :pattern)
;; (stop t) |
Because you have If you do the following instead, it should work (I just tested it from a fresh restart of SBCL): (ql:quickload '(:cl-collider :cl-patterns/supercollider))
(in-package :sc-user)
(setf *s* (make-external-server "localhost" :port 4444))
(server-boot *s*)
(jack-connect)
(uiop:define-package #:cl-patterns-scratch
(:mix #:cl
#:cl-patterns
#:cl-collider))
(in-package #:cl-patterns-scratch)
(cl-patterns:enable-backend :supercollider)
(start-clock-loop :tempo 130/60)
(defsynth block ((gain 1))
(let* ((env (line.kr 4 0 .03 :act :free))
(sig (sin-osc.ar 500 0 env)))
(out.ar 0 (pan2.ar sig 0 gain))))
;; this symbol's full name is cl-patterns-scratch::*mouse-x-value* here:
(defparameter *mouse-x-value* 0)
;; ...whereas in your previous reply, its full name was cl-collider::*mouse-x-value*
(cl-collider:add-reply-responder
"/mouse-x"
(lambda (node trig &rest value)
(declare (ignorable node trig))
(setf *mouse-x-value* (car value))))
(proxy :mouse-x-value-poller
(let ((mouse-x (mouse-x.kr 0 1 :linear 0)))
(send-reply.kr (impulse.kr 10) "/mouse-x" (list mouse-x))))
(pb :pattern
:instrument :block
:embed (pbjorklund (pf (let ((v (round (* 16 *mouse-x-value*))))
(format t "~&~s~%" v)
v))
16
:dur 4
:repeats 1))
(play :pattern) The reason this works is because we make a new package, So basically, the problem you're facing is due to the way symbols work in Common Lisp; each symbol belongs to a package, and when you're in one package, you won't be able to access the symbols of another package unless you either prefix the symbol name with the name of the package (i.e. If you're unfamiliar with how symbols and packages interact in Common Lisp, I would recommend reading a guide like this one or similar to familiarize yourself with them, since you basically can't use CL without using symbols (and thus packages). Otherwise you're likely to run into similar problems in the future. Hope that clarifies things a bit, let me know if not. |
Thanks! It works now. The pulses change sequentially by moving the
mouse sideways. Very nice. Also, many thanks for the guidance.
That was very helpful.
|
No problem, happy to be of help :) |
see `pmouse`, `pmousex`, `pmousey` also adds `skip-unless` macro to support tests for these patterns. if there is no supported display server, we skip testing them. related to the request in #28
Hi. Regarding your request for using the mouse position in patterns, I have added an initial implementation of this in 9ff3f25. It shells out to the A better implementation would probably use FFI to bypass shell command invocation entirely, and I may do that eventually. But maybe the current version would still be usable for you until then. If not, the best option would probably be to continue using the alternative I provided previously. |
Hi, is it possible to change the steps in the pbjorklund function interactively? For example, using this script, if I change 7 to some other integer while the pattern is playing and eval the expression, the pattern doesn't change. How do I do this?
Also, I was reading your tutorial and found a function that changes the pitch by moving the mouse/trackpad up and down, similar to a knob. Is it possible to do the same, but changing the steps instead in the pbjorklund function?
The text was updated successfully, but these errors were encountered: