国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

ChucK初步(11)

2019-11-11 02:33:55
字體:
來源:轉載
供稿:網友

unit generators(單元發生器)

declaringconnectingcontrolling (timing mechanism)mono + stereocreating (coming soon)

Unit Generators

Unit Generators are function generators that output(輸出) signals that can be used as audio or control signals. However, in ChucK, there is no fixed control rate. Any unit generator may be controlled at any rate. Using the timing mechanism(機制), you can PRogram your own control rate, and can dynamically(動態地) vary(變化) the control over time. Using concurrency(并發性), it is possible to have many different parallel(平行的) controls rates, each at any granularity(間隔尺寸).

Some more quick facts about ChucK unit generators

All ChucK unit generators are objects (not primitive(原始的) types).是對象,非原始類型All ChucK unit generators inherit(繼承) from the UGen class.繼承自UGen類The Operation foo => bar, where foo and bar are UGen’s, connects foo to bar.Unit generators are controlled by calling/chucking to member functions over time.通過隨時間喚起成員函數而控制單元發生器All unit generators have the functions gain, op, channels, chan, and last. (see below)Three default, global unit generators are provided. They are adc, dac, and blackhole. (see below)Unit generators are specially integrated(集合) into the virtual machine such that audio is computed for every sample(取樣) as time is advanced(隨時間被推進). Via the timing mechanism(機制), we have the ability to assert(維護) control over the audio generate process at any point in time and at any desired control rate.

View a list of ChucK’s built-in(嵌入的) unit generator classes View sample code for unit generators

declaring

Unit generators (UGens) are objects, and need to be instantiated before they can be used(在使用前需要被實例化). We declare unit generators the same way we declare objects.

// instantiate a SinOsc, assign reference to variable sSinOsc s;

connecting

The ChucK operator (=>) is specially overloaded for unit generators: ChucKing one UGen to another connects their respective(分別的) output(s) and input(s).

// instantiate a SinOsc, connect its output to dac's inputSinOsc s => dac;

It is also possible to linearly(線性地) chain many UGens together in a single statement.在一個單獨聲明中,線性連接許多單元發生器

// connect SinOsc to Gain to reverb(混響) to dacSinOsc s => Gain g => JCRev r => dac;

Furthermore(此外), it is possible to introduce feedback(反饋) in the network.網絡中可以引入反饋

// connect adc to Gain(增益) to delayline(延遲線) to dac; (feedforward(正反饋))adc => Gain g1 => DelayL d => dac;// adc to Gain to dac (feedforward)adc => Gain g2 => dac;// our delayline to Gain back to itself (feedback)d => Gain g3 => d;

UGens may be dynamically(動態地) connected in this fashion(以這種方式) into an audio synthesis network(音頻合成網絡). It is essential to note that the above only connects the unit generators, but does not actually generate(形成) audio - unless time is advanced. (see manipulating time and using events)要注意上面只是鏈接了單元發生器,并未形成音頻,除非時間被推進

// connect SinOsc to dacSinOsc s => dac;// set initial frequency (see next section)440 => s.freq;// advance time; allow audio to compute1::second => now;

It is also possible to dynamically disconnect(斷開) unit generators, using the UnChucK operator (=< or !=>):

// connect SinOsc to dac SinOsc s => dac; // let time pass for 1 second letting audio be computed for that amount of time 1::second => now; // disconnect s from the dac s =< dac; // let time pass for another second - should hear silence 1::second => now; // duh, connect them again s => dac; // let time pass... 1::second => now;

controlling (over time)

In ChucK, parameters(參數) of unit generators may be controlled and altered at any point in time and at any control rate. We only have to move through time and assert(維護) the control at appropriate(適當的) points in time, by setting various parameters on the unit generator. 通過在單元發生器設定各種各樣的參數 To set the a value for a parameter of a unit generator, a value of the proper type should be ChucKed to the corresponding control fucntion. 為了設定一個單元發生器的參數值,一個合適的類型的值應該被ChucK到相應的控制函數上。

// connect SinOsc to dacSinOsc s => dac;// set initial frequency to 440 hz440 => s.freq;// let time pass for 1 second1::second => now;// change the frequency to 880 hz880 => s.freq;

Since the control functions are member functions of the unit generator, 控制函數就是單元發生器的成員函數 the above syntax(語法) is equivalent to calling functions(等價于調用函數).

// connect SinOsc to dacSinOsc s => dac;// set frequency to 440s.freq( 440 );// let time pass1::second => now;

For a list of unit generators and their control methods, consult(查閱) UGen reference.

To read the current value of certain parameters(參數) (not all parameters can be read), we may call an overloaded function of the same name. 為了讀取某個參數的當前值,需要調用一個同名的重載函數

// connect SinOsc to dacSinOsc s => dac;// store the current value of the freqs.freq() => float the_freq;

You can chain assignments(分配) together when you want to assign(分配) one value to multiple targets. Note that the parentheses(括號) are only needed when the read function is on the very left. 只有當讀函數位于最左邊時,才需要括號

// SinOsc to dacSinOsc foo => dac;// triosc to dactriosc bar => dac;// set frequency of foo and then bar500 => foo.freq => bar.freq;// set one freq to the otherfoo.freq() => bar.freq;// the above is same as:bar.freq( foo.freq() );

Of course, varying(不同的) parameters over time is often more interesting.不同參數隨時間推移是很有趣的。

// SinOsc to dacSinOsc s => dac;// infinite time loopwhile( true ){ // set the frequency ( s.freq() + 200 ) % 5000 => s.freq; // advance time 100::ms => now;}

All ugen’s have at least the following three control parameters: 以下參數至少有三個

gain(float) (of type float): set/get the gain of the UGen’s output(輸出).設置或獲取單元發生器輸出的增益last() (of type float): get the last sample computed by the UGen. if UGen has more than one channel, the average of all components(成分) channels are returned. 得到被單元發生器計算的最后的樣本,如果單元發生器有不止一個通道,則返回所有通道的平均值。channels() (of type int): get the number of channels in the UGen.獲取單元發生器的通道數chan(int) (of type UGen): return reference to nth channel (or null if no such channel).返回第幾個通道引用,沒有的話就返回nullop(int) (of type int): set/get operation at the UGen. 設定或獲取單元發生器的操作 Values: 0 : stop - always output 01 : normal operation, add all inputs (default)2 : normal operation, subtract(減去) inputs starting from the earliest connected減去從最早的鏈接開始的輸入(不甚理解???)3 : normal operation, multiply(乘以) all inputs4 : normal operation, divide inputs starting from the earlist connected-1 : passthru - all inputs to the ugen are summed and passed directly to output所有單元生成器的輸入被加在一起并且直接傳遞到輸出

mono + stereo(單聲道立體聲)

ChucK supports stereo(立體聲) (default) and multi-channel audio (see command line options to select interfaces(界面) and number of channels). The dac and the adc are now multi-channel UGens. By default, ChucKing two UGens containing the same number of channels (e.g. both stereo(立體聲) or both mono(單聲道放音)) automatically(自動地) matches the output(輸出) channels with the input(輸入) channels (e.g. left to left, right to right for stereo).

Stereo UGens mix their output channels when connecting to mono UGens. Mono UGens split their output channels when connecting to stereo UGens.

Stereo UGens contain the parameters(參數) .left and .right, which allow access(訪問) to the individual(個人的) channels.

// adding separate reverb(混響) to left and right channelsadc.left => JCRev rl => dac.left;adc.right => JCRev rr => dac.right;

The pan2 stereo object takes a mono signal and split it to a stereo signal, with control over the panning. The pan position may be changed with the .pan parameter (-1 (hard left) <= p <= 1 (hard right)范圍是固定的) pan2立體聲對象將單聲道分離成立體聲,通過控制panning(平移?),平移位置可能被用.pan參數改變。

// white noise to pan to dacnoise n => pan2 p => dac;// infinite time loopwhile( true ){ // modulate(調整) the pan Math.sin( now / 1::second * 2 * pi ) => p.pan; // advance time 10::ms => now;}

creating

( coming soon! )

built-in unit generators

ChucK has a number of built-in(嵌入的) UGen classes, included most of the Synthesis ToolKit (STK). A list of built-in ChucK unit generators can be found here(url:…/ugen.html).


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 股票| 广宁县| 万山特区| 蒲江县| 固原市| 平顺县| 陇川县| 沙湾县| 封开县| 安岳县| 渭源县| 双辽市| 汤原县| 南召县| 株洲市| 白银市| 龙山县| 巴中市| 刚察县| 乌什县| 张家口市| 贺州市| 井冈山市| 横山县| 顺义区| 南乐县| 泽普县| 宿州市| 彭阳县| 太仆寺旗| 会理县| 精河县| 专栏| 扶余县| 东安县| 永修县| 堆龙德庆县| 舒兰市| 云安县| 吉木萨尔县| 龙里县|