a亚洲精品_精品国产91乱码一区二区三区_亚洲精品在线免费观看视频_欧美日韩亚洲国产综合_久久久久久久久久久成人_在线区

首頁 > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

ChucK初步(1)

2019-11-14 10:16:34
字體:
供稿:網(wǎng)友

Build/Install Instructions 如是直接安裝(win)可以忽略上面的。

The ChucK Tutorial

This tutorial was written for the command line version of ChucK (currently the most stable(穩(wěn)定的) and widely supported). Other methods of running ChucK includes the miniAudicle (now on all major platforms) and the Audicle (in PRe-pre-alpha). The code is the same, but the way to run them differs, depending the ChucK system.

…generate a sine wave and send to the speaker…

…connecting audio processing modules (unit generators) and having them work together to compute the sound.

// connect sine oscillator to D/A convertor (sound card) SinOsc s => dac;

The above does several things:

(1) it creates a new unit generator of type 'SinOsc' (sine oscillator(振蕩器)), and store its reference(引用) in variable(變量的) 's'. (2) 'dac' (D/A convertor) is a special *unit generator* (created by the system) which is our abstraction(抽象) for the underlying(潛在的) audio interface(界面). (3) we are using the ChucK Operator (=>) to ChucK 's' to 'dac'.

In ChucK, when one unit generator is ChucKed to another, we connect them. We can think of this line as setting up a data flow from ‘s’, a signal generator, to ‘dac’, the sound card/speaker. Collectively(集體的), we will call this a ‘patch’.

…we simply have to “allow time to pass” for data to be computed…time and audio data are both inextricably(密不可分) related in ChucK (as in reality), and separated in the way they are manipulated(操縱).

let’s generate our sine wave and hear it by adding one more line:

// connect sine oscillator to D/A convertor (sound card)SinOsc s => dac;// allow 2 seconds to pass2::second => now;

Let’s now run this (assuming(假設(shè)) you saved the file as ‘foo.ck’):

chuck foo.ck

For now, we can just take the second line of code to mean “l(fā)et time pass for 2 seconds (and let audio compute during that time)”. If you want to play it indefinitely(無限制地), we could write a loop:

//////////////example1//////////////// connect sine oscillator to D/A convertor (sound card)SinOsc s => dac;// loop in timewhile( true ) { 2::second => now; //(we used 2::second here, but we could have used any number of //'ms', 'second', 'minute', 'hour', 'day', and even 'week') }

In ChucK, this is called a ‘time-loop’ (in fact this is an ‘infinite time loop’). To stop a ongoing ChucK program from the command line, hit (ctrl - c).

Now, let’s try changing the frequency randomly every 100ms:

// make our patchSinOsc s => dac;// time-loop, in which the osc's frequency is changed every 100 mswhile( true ) { 100::ms => now; Std.rand2f(30.0, 1000.0) => s.freq; }

Two more things to note here.

(1) We are advancing time inside the loop by 100::ms durations. (2) A random value between 30.0 and 1000.0 is generated and 'assigned' to the oscillator's frequency, every 100::ms.

目前運(yùn)行的結(jié)果是有并不規(guī)律的聲音產(chǎn)生,這就是那個(gè)時(shí)刻變形的聲波


Now let’s write another (slightly longer) program: (these files can be found in the examples/ directory, so you don’t have to type them in)

//////////////example2//////////////// impulse(脈沖信號) to filter to dac//Biquad filter(雙二階濾波器)Impulse i => BiQuad f => dac;// set the filter's pole radius( = prad).99 => f.prad;// set equal gain zero's1 => f.eqzs;//不理解// initialize float variable0.0 => float v;// infinite time-loopwhile( true ){ // set the current sample/impulse 1.0 => i.next; // sweep the filter resonant frequency(共振頻率) Std.fabs(Math.sin(v)) * 4000.0 => f.pfreq; // increment(增量) v v + .1 => v; // advance time 100::ms => now;}

Name this moe.ck, and run it:

chuck moe.ck

Now, make two copies of moe.ck - larry.ck and curly.ck. Make the following modifications(修改).

1) change larry.ck to advance time by 99::ms (instead of 100::ms). 2) change curly.ck to advance time by 101::ms (instead of 100::ms). 3) optionally, change the 4000.0 to something else (like 400.0 for curly).

Run all three in parallel:

chuck moe.ck larry.ck curly.ck

What you hear (if all goes well) should be ‘phasing’ between moe, larry, and curly, with curly emitting(發(fā)出) the lower-frequency pulses(脈沖).

ChucK supports sample-synchronous concurrency(并發(fā)性), via the ChucK timing mechanism(機(jī)制). Given any number of source files that uses the timing mechanism above, the ChucK VM can use the timing information to automatically(自動地) synchronize(合拍) all of them… Note that each process do not need to know about each other - it only has to deal with time locally. The VM will make sure things happen correctly and globally.

A large collection of pre-made examples have been arranged and provided with this distribution in the /doc/examples directory, and are mirrored here


發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 在线免费看污网站 | 日韩欧美一区二区三区久久婷婷 | 国产在线一级视频 | 国产美女精品视频免费观看 | 国产成人av电影 | 中文字幕在线看 | 碰在线视频 | 龙珠z普通话国语版在线观看 | 亚洲成人一区 | 亚洲专区在线播放 | 日本毛片视频 | 91免费视频观看 | 免费亚洲精品 | av福利在线观看 | 99re视频| 午夜免费小视频 | 亚洲人人 | 欧美日韩网站在线观看 | 日韩一区二区三区在线观看 | 欧美日韩免费一区二区三区 | 亚洲欧美在线观看 | 夜夜精品视频 | 国产乱码精品一区二区三区手机版 | 狠狠色综合色综合网络 | 国产suv精品一区二区6 | 亚洲高清一区二区三区 | 亚洲国产精品一区二区三区 | 国产乱码精品一品二品 | 日韩久久久精品 | 国内精品视频在线观看 | 欧美一区免费 | 美女视频黄色免费 | 日韩欧美中文字幕视频 | 蜜桃官网| 久久99这里只有精品 | 一级黄色毛片 | 日韩精品无玛区免费专区又长又大 | 久久亚洲精品国产一区 | 亚洲黄色在线观看 | 国产激情精品一区二区三区 | 色香蕉在线 |