首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >结构化泛音项目

结构化泛音项目
EN

Stack Overflow用户
提问于 2013-12-31 18:37:28
回答 2查看 1.4K关注 0票数 3

我刚开始使用Overtone,但我想从一开始就让事情组织起来。

project.clj:

代码语言:javascript
复制
(defproject overtone-sketchbook "0.1.0-SNAPSHOT"
  :dependencies [[org.clojure/clojure "1.5.1"]
                 [overtone "0.9.1"]])

src/overtone_sketchbook/synths.clj:

代码语言:javascript
复制
(ns overtone-sketchbook.synths
  (:use [overtone.live]))

(definst pluck-saw [f 800 d 3]
         (* (saw (+ 100 (* 200 (saw d))))
            (pluck (* (white-noise)
                      (env-gen (perc 0.001 2) :action FREE))
                   1 3 (/ 1 f))))

REPL第1次会议:

代码语言:javascript
复制
> lein repl
nREPL server started on port 52425
REPL-y 0.2.0
Clojure 1.5.1
    Docs: (doc function-name-here)
          (find-doc "part-of-name-here")
  Source: (source function-name-here)
 Javadoc: (javadoc java-object-or-class-here)
    Exit: Control+D or (exit) or (quit)

user=> (use 'overtone.live)
--> Loading Overtone...
  ********************************************************** 
       WARNING: JVM argument TieredStopAtLevel=1 is active, and may 
       lead to reduced performance. This happens to currently be the 
       default lein setting:

       https://github.com/technomancy/leiningen/pull/1230

       If you didn't intend this JVM arg to be specified, you can turn 
       it off in your project.clj file or your global 
       ~/.lein/profiles.clj file by adding the key-val

       :jvm-opts ^:replace [] 
       ********************************************************** 
--> Booting internal SuperCollider server...
Found 0 LADSPA plugins
*** ERROR: open directory failed '/Users/ilya/Library/Application Support/SuperCollider/synthdefs'
Number of Devices: 2
   0 : "Built-in Input"
   1 : "Built-in Output"

"Built-in Input" Input Device
   Streams: 1
      0  channels 2

"Built-in Output" Output Device
   Streams: 1
      0  channels 2

SC_AudioDriver: sample rate = 44100.000000, driver's block size = 512
--> Connecting to internal SuperCollider server...
--> Connection established

    _____                 __
   / __  /_  _____  _____/ /_____  ____  ___
  / / / / | / / _ \/ ___/ __/ __ \/ __ \/ _ \
 / /_/ /| |/ /  __/ /  / /_/ /_/ / / / /  __/
 \____/ |___/\___/_/   \__/\____/_/ /_/\___/

   Collaborative Programmable Music. v0.9.1


Hey Ilya, I feel something magical is only just beyond the horizon...

nil
user=> (demo overtone-sketchbook.synths/pluck-saw)

IllegalArgumentException Don't know how to create ISeq from: clojure.lang.Symbol  clojure.lang.RT.seqFrom (RT.java:505)
user=> (use 'overtone-sketchbook.synths)
nil
user=> (demo overtone-sketchbook.synths/pluck-saw)

IllegalArgumentException Don't know how to create ISeq from: clojure.lang.Symbol  clojure.lang.RT.seqFrom (RT.java:505)
user=> (demo pluck-saw)

IllegalArgumentException Don't know how to create ISeq from: clojure.lang.Symbol  clojure.lang.RT.seqFrom (RT.java:505)
user=> (require 'overtone-sketchbook.synths)
nil
user=> (demo pluck-saw)

IllegalArgumentException Don't know how to create ISeq from: clojure.lang.Symbol  clojure.lang.RT.seqFrom (RT.java:505)
user=> (demo overtone-sketchbook.synths/pluck-saw)

IllegalArgumentException Don't know how to create ISeq from: clojure.lang.Symbol  clojure.lang.RT.seqFrom (RT.java:505)
user=> Bye for now!

REPL第2次会议:

代码语言:javascript
复制
> lein repl
nREPL server started on port 52100
REPL-y 0.2.0
Clojure 1.5.1
    Docs: (doc function-name-here)
          (find-doc "part-of-name-here")
  Source: (source function-name-here)
 Javadoc: (javadoc java-object-or-class-here)
    Exit: Control+D or (exit) or (quit)

user=> (use 'overtone-sketchbook.synths)
--> Loading Overtone...
  ********************************************************** 
       WARNING: JVM argument TieredStopAtLevel=1 is active, and may 
       lead to reduced performance. This happens to currently be the 
       default lein setting:

       https://github.com/technomancy/leiningen/pull/1230

       If you didn't intend this JVM arg to be specified, you can turn 
       it off in your project.clj file or your global 
       ~/.lein/profiles.clj file by adding the key-val

       :jvm-opts ^:replace [] 
       ********************************************************** 
--> Booting internal SuperCollider server...
Found 0 LADSPA plugins
*** ERROR: open directory failed '/Users/ilya/Library/Application Support/SuperCollider/synthdefs'
Number of Devices: 2
   0 : "Built-in Input"
   1 : "Built-in Output"

"Built-in Input" Input Device
   Streams: 1
      0  channels 2

"Built-in Output" Output Device
   Streams: 1
      0  channels 2

SC_AudioDriver: sample rate = 44100.000000, driver's block size = 512
--> Connecting to internal SuperCollider server...
--> Connection established

    _____                 __
   / __  /_  _____  _____/ /_____  ____  ___
  / / / / | / / _ \/ ___/ __/ __ \/ __ \/ _ \
 / /_/ /| |/ /  __/ /  / /_/ /_/ / / / /  __/
 \____/ |___/\___/_/   \__/\____/_/ /_/\___/

   Collaborative Programmable Music. v0.9.1


Hello Ilya, may algorithmic beauty pour forth from your fingertips today.

nil
user=> pluck-saw
#overtone.studio.inst.Inst{:name "pluck-saw", :params ({:value #<Atom@24fc9cde: 800.0>, :name "f", :default 800.0, :rate :kr} {:value #<Atom@449ec5ca: 3.0>, :name "d", :default 3.0, :rate :kr}), :args ("f" "d"), :sdef {:name "overtone-sketchboo96d/pluck-saw", :constants [0.0 0 2.0 3.0 0.5 1.0 50.0 100.0 200.0 1 2 -99 -4 5 0.001], :params (800.0 3.0), :pnames ({:name "f", :index 0} {:name "d", :index 1}), :ugens ({:n-inputs 0, :args nil, :outputs ({:rate 1} {:rate 1}), :name "Control", :rate 1, :n-outputs 2, :rate-name :kr, :inputs (), :special 0, :id 280} #<sc-ugen: saw:ar [1]> #<sc-ugen: binary-op-u-gen:ar [2]> #<sc-ugen: binary-op-u-gen:ar [3]> #<sc-ugen: saw:ar [4]> #<sc-ugen: white-noise:ar [0]> #<sc-ugen: env-gen:kr [0]> #<sc-ugen: binary-op-u-gen:ar [2]> #<sc-ugen: binary-op-u-gen:kr [1]> #<sc-ugen: pluck:ar [5]> #<sc-ugen: binary-op-u-gen:ar [11]> #<sc-ugen: out:ar [12]>)}, :group #<synth-group[live]: Inst pluck-saw Container 31>, :instance-group #<synth-group[live]: Inst pluck-saw 32>, :fx-group #<synth-group[live]: Inst pluck-saw FX 33>, :mixer #<synth-node[live]: overtone.stu547/mono-inst-mixer 34>, :bus #<audio-bus: No Name, mono, id 50>, :fx-chain [], :volume #<Atom@6e9cebcc: 1.0>, :pan #<Atom@3cd6d0: 0.0>, :n-chans 1}
user=> (demo pluck-saw)

CompilerException java.lang.RuntimeException: Unable to resolve symbol: demo in this context, compiling:(NO_SOURCE_PATH:1:1) 
user=> (overtone.live/demo pluck-saw)

IllegalArgumentException Don't know how to create ISeq from: clojure.lang.Symbol  clojure.lang.RT.seqFrom (RT.java:505)
user=> Bye for now!

我是不是错过了一些很基本的东西?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-01-02 10:46:05

首先,如果你能使你的问题变得更简单和简洁,这样就很容易找出可能的解决方案,这将是非常有帮助的。

另外,谢谢你给了我一次尝试-抱歉,事情没有立即明朗。这里有很多事情要做,所以在路上要问几个问题:-)

然而,看看你的两个REPL摘录,很明显你还没有完全理解三件事:

  • Overtone如何使用Clojure的命名空间
  • 合成器是如何设计的
  • 如何触发合成器

让我简要地讨论每一个问题,希望它们能揭示出正在发生的事情。

第一,Overtone对Clojure名称空间的使用。当您将use overtone.live导入到当前命名空间中时,Overtone的所有公共API函数都会被导入。这意味着,一旦操作完成,所有的公共API都将提供给您--即demodefsynthsin-osc等。

在您的第二个REPL示例中,您要做的第一件事是:(demo overtone-sketchbook.synths/pluck-saw),它无法工作,因为Clojure还不知道什么是demo,也不知道您的命名空间overtone-sketchbook.synth。要想了解这些,您需要userequire名称空间。有关更多信息,请阅读有关Clojure的ns宏的信息。

其次,泛音的合成器是通过调用函数来设计的,这些函数代表了合成器的各个部分(称为“绝对”)。例如sawsin-osclpf。您可以在Overtone:https://github.com/overtone/overtone/raw/master/docs/cheatsheet/overtone-cheat-sheet.pdf中看到可用的绝对单位的完整列表。

demo是一个宏,允许您传入(部分) synthdef并播放它:

  • (demo (sin-osc))
  • (demo (sin-osc 440))

注意,绝对函数是为了允许您传递参数来修改它们的行为(例如,440 hz参数到sin-osc ugen)。

同样重要的是要注意的是,绝对不能(目前)被视为同样的合成器。ugen是合成器的组成部分,合成器是绝对的树。这就引出了第三个问题--你在尝试demo pluck-saw合成器。这是一个已经设计好的合成器,只能被触发。要触发合成器,只需将其作为函数调用:

(pluck-saw)

您还可以将params (如果设计允许)传递给synth触发器函数。

因此,总结一下:

  • 使用Clojure的ns宏加载外部名称空间,并引入函数以使它们可用。对于Overtone的默认API,您需要输入overtone.liveovertone.core (如果没有启动服务器,则第一次引导服务器)。
  • 合成器是绝对的树。Ugens是标准的Clojure函数和返回数据结构,宏demodefsynth都能理解这些结构。您可以将参数传递给ugen函数以指定它们的行为。
  • 合成人不是绝对的。调用ugen函数返回可用于synth设计的数据结构。调用合成器作为函数触发(即播放)该合成器。

最后,一定要来加入我们的邮件列表-我们很想看看你正在做什么(和计划做),并与您分享我们的热情:

http://groups.google.com/group/overtone/

票数 10
EN

Stack Overflow用户

发布于 2013-12-31 20:19:53

尝试:(demo 'overtone-sketchbook.synths/pluck-saw)

我仍然会在你的代码中发现错误,我不明白,但这会让你更深入。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20861851

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档