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

Saving output to file #35

Closed
jagrg opened this issue Aug 9, 2022 · 2 comments
Closed

Saving output to file #35

jagrg opened this issue Aug 9, 2022 · 2 comments

Comments

@jagrg
Copy link
Contributor

jagrg commented Aug 9, 2022

How can I save an excerpt of the output to an audio file? For example, using this example:

(ql:quickload :cl-collider)
(in-package #:cl-collider)

(setf *s* (make-external-server "localhost" :port 4444))
(server-boot *s*)
(jack-connect)

(defsynth beep ((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))))

(ql:quickload :cl-patterns/supercollider)
(cl-patterns:backend-start :supercollider)
(in-package #:cl-patterns)
(start-clock-loop :tempo 110/60)

(pb :beat
  :embed (pcycles "x-xx-x-xx-xx" :dur 3)
  :instrument :beep)

(play (list :beat))
@defaultxr
Copy link
Owner

Sorry for the delay in responding, I wanted to make sure everything was actually working first and it turned out things weren't.

I've fixed most of the issues now, so ensure you're using a local copy of cl-patterns updated to the latest commit on master, and then you can render a pattern with render like so:

(render (pdef :beat) "/path/to/output.wav" :duration 4) ; render 4 seconds of audio

(render (pdef :beat) "/path/to/output.wav" :dur 4) ; render 4 beats of audio

(render (pdef :beat) "/path/to/output.wav" :max-length 4) ; render the first 4 events of the pattern (note that rests are included)

Since your :beat pattern is infinite in length, you need to specify :duration, :dur, or :max-length if you want the rendered output to be a specific length.

Alternatively you can make it finite in length, and as long as it has fewer than :max-length (which defaults to *max-pattern-yield-length*) outputs, the full pattern will be rendered without needing to specify any keyword arguments.

I've tested this new implementation a bit and it seems to work, but there are probably some cases where it might still be broken. Let me know if you notice any.

@jagrg
Copy link
Contributor Author

jagrg commented Aug 13, 2022 via email

@jagrg jagrg closed this as completed Aug 13, 2022
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

2 participants