in depth explanation of the side effects interface in clojure overtone generators

StackOverflow https://stackoverflow.com/questions/17353781

  •  01-06-2022
  •  | 
  •  

문제

I an new to overtone/supercollider. I know how sound forms physically. However I don't understand the magic inside overtone's sound generating functions.

Let's say I have a basic sound:

(definst sin-wave [freq 440 attack 0.01 sustain 0.4 release 0.1 vol 0.4] 
  (* (env-gen (lin-env attack sustain release) 1 1 0 1 FREE)
     (+ (sin-osc freq)
        (sin-osc (* freq 2))
        (sin-osc (* freq 4)))
     vol))

I understand the ASR cycle of sound envelope, sin wave, frequency, volume here. They describe the amplitude of the sound over time. What I don't understand is the time. Since time is absent from the input of all functions here, how do I control stuffs like echo and other cool effects into the thing?

If I am to write my own sin-osc function, how do I specify the amplitude of my sound at specific time point? Let's say my sin-osc has to set that at 1/4 of the cycle the output reaches the peak of amplitude 1.0, what is the interface that I can code with to control it?

Without knowing this, all sound synth generators in overtone doesn't make sense to me and they look like strange functions with unknown side-effects.

도움이 되었습니까?

해결책

Overtone does not specify the individual samples or shapes over time for each signal, it is really just an interface to the supercollider server (which defines a protocol for interaction, of which the supercollider language is the canonical client to this server, and overtone is another). For that reason, all overtone is doing behind the scenes is sending signals for how to construct a synth graph to the supercollider server. The supercollider server is the thing that is actually calculating what samples get sent to the dac, based on the definitions of the synths that are playing at any given time. That is why you are given primitive synth elements like sine oscillators and square waves and filters: these are invoked on the server to actually calculate the samples.

다른 팁

I got an answer from droidcore at #supercollider/Freenode IRC

d: time is really like wallclock time, it's just going by

d: the ugen knows how long each sample takes in terms of milliseconds, so it knows how much to advance its notion of time

d: so in an adsr, when you say you want an attack time of 1.0 seconds, it knows that it needs to take 44100 samples (say) to get there

d: the sampling rate is fixed and is global. it's set when you start the synthesis process

d: yeah well that's like doing a lookup in a sine wave table

d: they'll just repeatedly look up the next value in a table that represents one cycle of the wave, and then just circle around to the beginning when they get to the end

d: you can't really do sample-by sample logic from the SC side

d: Chuck will do that, though, if you want to experiment with it

d: time is global and it's implicit it's available to all the oscillators all the time but internally it's not really like it's a closed form, where you say "give me the sample for this time value"

d: you say "time has advanced 5 microseconds. give me the new value"

d: it's more like a stream

d: you don't need to have random access to the oscillators values, just the next one in time sequence

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top