亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

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

ChucK初步(5)

2019-11-14 08:53:45
字體:
來源:轉載
供稿:網友

Operators & operations

=> (chuck)+ - * / (arithmetic)% (modulo)&& || == != >= <=” (logic)& | ^ (bitwise)++ – (inc / dec)! + - new (unary)

You may have seen many of the operators in other PRogramming languages (C/java). Some others are native to ChucK. We start with the family of ChucK operators.

=> (the ChucK operator)

The ChucK operator (=>) is a massively(大量地) overloaded operator that, depending on the types involved(包含), performs various actions(執行各種操作). It denotes(表示) **action**, can be chained(鏈接), and imposes(強制執行) and clarifies order(理清順序) (always goes *from left to right*). The ChucK operator is the means by which work is done in ChucK. Furthermore(此外), the ChucK operator is not a single operator, but a family of operators.

=> (foundational(基礎的) ChucK operator)

We start with the standard, plain-vanilla(普通的,無修飾的) ChucK operator (=>). It is left-associative (all ChucK operators are), which allows us to specify(指定) any ordered flow of data/tasks/modules (such as unit generator connection) from left to right, as in written (English) text. What => does depends on the context(環境). It always depends on the type of the entity(實體) on the left (the chucker(投手)) and the one on the right (the chuckee(接球手)), and it sometimes also depends on the nature of the entity (such as whether it is a variable(變量的) or not).

Some examples: (用了c的高亮,至少好看點)

// a unit generator patch - the signal flow is apparent// (in this case, => connects two unit generators)SinOsc b => Gain g => BiQuad f => dac;// add 4 to foo, chuck result to new 'int' variable 'bar'// (in this case, => assigns a value to a variable (int)4 + foo => int bar;// chuck values to a function == function call// (same as Math.rand2f( 30, 1000))( 30, 1000 ) => Math.rand2f;

There are many other well-defined(定義明確的) uses of the ChucK operator, depending on the context.

@=> (explicit(明確的) assignment(分配) ChucK operator)

In ChucK, there is no stardard assignment operator (=), found in many other programming languages. Assignment is carried out using ChucK operators. In the previous examples, we have used => for assignment:

// assign 4 to variable foo4 => int foo;// assign 1.5 to variable bar1.5 => float bar;// assign duration of 100 millisecond to duh100::ms => dur duh;// assign the time "5 second from now" to later5::second + now => time later;

The @=> explicit assignment ChucK operator behaves exactly the same for the above types (int, float, dur, time). However, the difference is that @=> can also be used for reference assignments(分配) of objects (see objects and classes) whereas(然而) => only does assignment on primitive(原始的) types (int, float, dur, time). The behavior(行為) of => on objects is completely context-dependent(上下文相關的).

// using @=> is same as => for primitive types4 @=> int foo;// assign 1.5 to variable bar1.5 @=> float bar;// (only @=> can perform reference assignment on objects)// reference assign moe to larry// (such that both moe and larry reference the same object)Object moe @=> Object @ larry;// array initialization[ 1, 2 ] @=> int ar[];// using newnew Object @=> moe;

In its own screwed-up(糟透了的) way, this is kind of nice because there is no confusion(混淆) between assignment (@=> or =>) and equality (==). In fact, the following is not a valid ChucK statement(聲明):

// not a valid ChucK statement!int foo = 4;

+=> -=> *=> /=> etc. (arithmetic(算數) ChucK operators)

These operators are used with variables(變量) (using ‘int’ and ‘float’) to perform one operation with assignment(執行一個有分配的操作).

// add 4 to foo and assign result to foofoo + 4 => foo;// add 4 to foo and assign result to foo4 +=> foo;// subtract 10 from foo and assign result to foo// remember this is (foo-10), not (10-foo)10 -=> foo;// 2 times foo assign result to foo2 *=> foo;// divide 4 into foo and assign result to foo// again remember this is (foo/4), not (4/foo)4 /=> foo;

It is important to note the relationship between the value and variable when using -=> and /=>, since these operations are not commutative(交換的).

// mod foo by T and assign result to fooT %=> foo;// bitwise(按位) AND 0xff and bar and assign result to bar0xff &=> bar;// bitwise OR 0xff and bar and assign result to bar0xff |=> bar;

+ - * / (arithmetic)

// divide (and assign)16 / 4 => int four;// multiply2 * 2 => four;// add3 + 1 => four;// subtract93 - 89 => four;

cast(轉換)

ChucK implicitly(隱式地) casts int values to float when float is expected, but not the other around. The latter could result in a loss of information and requires an explicit(明確的) cast.

// adding float and int produces a float9.1 + 2 => float result;// however, going from float to int requires cast4.8 $ int => int foo; // foo == 4//這里的$是什么意思?// this function expects two floatsMath.rand2f( 30.0, 1000.0 );// this is ok because of implicit castMath.rand2f( 30, 1000 );

% (modulo(取模))

The modulo operator % computes the remainder(余數) after integer(整數), floating point, duration, and time/duration division.

// 7 mod 4 (should yield(產生) 3)7 % 4 => int result;// 7.3 mod 3.2 floating point mod (should yield .9)7.3 % 3.2 => float resultf;// duration mod5::second % 2::second => dur foo;// time/duration modnow % 5::second => dur bar;

the latter (time/duration mod) is one of many ways to dynamically(動態地) synchronize(同步) timing in shreds. the examples otf_01.ck through otf_07.ck (see under examples) make use of this to on-the-fly(運行時) synchronize its various parts, no matter when each shred is added to the virtual(虛擬的) machine:

// define period (agreed upon by several shreds).5::second => dur T;// compute the remainder(余數) of the current period ...// and advance time by that amountT - (now % T) => now;// when we reach this point, we are synchronized to T period boundary// the rest of the code// ...

This is one of many ways to compute and reason about(思考) time in ChucK. The appropriate(適當的) solution(解決方案)(s) in each case depends on the intended(打算的) functionality(功能).

&& || == != > >= < <= (logic)(邏輯)

Logical operators - each of these need two operands(操作數). The result is an integer value of 0 or 1.

&& : and|| : or== : equals!= : does not equal> : greater than>= : greater than or equal to< : less than<= : less than or equal to // test some universal truths(普遍的真理)if( 1 <= 4 && true ) <<<"horray">>>;

>> << & | ^ (bitwise)(按位)

These are used on int values at the bit level, often for bit masking.

>> : shift bits right(右移位) ( 8 >> 1 = 4 )<< : shift bits left ( 8 << 1 = 16 )& : bitwise AND| : bitwise OR^ : bitwise XOR

++ – (inc / dec)

Values may be incremented or decremented by appending(附加) the ++ or -- operators.

4 => int foo;foo++;foo--;

! + - new (unary(一元的))

These operators come before(位于…之前) one operand(操作數).

// logical invertif( !true == false ) <<<"yes">>>;// negative-1 => int foo;// instantiate objectnew object @=> object @ bar;
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
国产亚洲欧美日韩美女| 国产精品一区二区三区在线播放| 国产精品一区二区3区| 国产精品美女在线观看| 午夜精品理论片| 久久综合免费视频影院| 中文字幕欧美国内| 国产精品18久久久久久麻辣| 日韩在线观看高清| 亚洲美腿欧美激情另类| 国语自产精品视频在免费| 77777亚洲午夜久久多人| 日本一区二区不卡| 91欧美激情另类亚洲| 亚洲激情中文字幕| 日韩成人中文字幕在线观看| 精品视频一区在线视频| 亚洲va欧美va国产综合剧情| 国产欧美一区二区白浆黑人| 亚洲欧美激情精品一区二区| 亚洲欧美日韩在线一区| 欧美成人一区二区三区电影| 久久97精品久久久久久久不卡| 北条麻妃99精品青青久久| 少妇高潮 亚洲精品| 日韩欧美在线第一页| 欧美视频专区一二在线观看| 中文字幕av一区二区三区谷原希美| 九九热精品视频| 91精品国产色综合久久不卡98口| 久久精品成人一区二区三区| 亚洲欧洲黄色网| 欧美成人免费视频| 人人做人人澡人人爽欧美| 亚洲第一av网| 日韩精品有码在线观看| 日韩国产欧美精品一区二区三区| 成人国产在线视频| 久久久久久999| 一本色道久久综合狠狠躁篇怎么玩| xxx一区二区| 国产美女精彩久久| 在线国产精品播放| 亚洲国产精品久久| 亚洲欧美日韩国产成人| 亚洲最大在线视频| 欧美成人自拍视频| 国产精品一区二区久久久| 91亚洲精品视频| 日韩av综合中文字幕| 日韩有码在线观看| 欧美一乱一性一交一视频| 久久久久久国产| 中文字幕精品久久| 久久天天躁狠狠躁老女人| 亚洲欧美www| 38少妇精品导航| 国模私拍视频一区| 成人黄色免费看| 96sao精品视频在线观看| 中文字幕日韩免费视频| 午夜精品一区二区三区视频免费看| 国产欧美婷婷中文| 丝袜亚洲欧美日韩综合| 久久99热精品这里久久精品| 国产在线观看一区二区三区| 日本精品一区二区三区在线播放视频| 欧美在线一级va免费观看| 中国日韩欧美久久久久久久久| 亚洲品质视频自拍网| 久久久国产影院| 亚洲网站视频福利| 亚洲图片在区色| 在线日韩日本国产亚洲| 国产精品丝袜视频| 性欧美激情精品| 国产精品久久久久久av下载红粉| 2020欧美日韩在线视频| 91亚洲永久免费精品| 日韩三级影视基地| 欧美乱大交xxxxx另类电影| 国产精品免费视频久久久| 成人黄色免费在线观看| 日韩精品在线观看网站| 高潮白浆女日韩av免费看| 亚洲欧美日本伦理| 国产日韩欧美一二三区| 日韩av电影国产| 国产欧美日韩中文字幕在线| 久久久欧美精品| 欧美激情xxxxx| 夜夜嗨av色一区二区不卡| 久久99国产精品自在自在app| 2021国产精品视频| 中文字幕精品在线| 国产美女扒开尿口久久久| 国产精品白嫩初高中害羞小美女| 欧美伊久线香蕉线新在线| 国产精品美女免费看| 精品视频在线播放色网色视频| 午夜精品久久久久久久男人的天堂| 国产成人精品国内自产拍免费看| 成人啪啪免费看| 成人黄色免费在线观看| 91色视频在线导航| 亚洲一区二区三区xxx视频| 欧美亚洲国产视频| 88国产精品欧美一区二区三区| 国产日韩欧美夫妻视频在线观看| 亚洲高清色综合| 98午夜经典影视| 97人洗澡人人免费公开视频碰碰碰| 欧美自拍大量在线观看| 中文字幕日韩欧美精品在线观看| 51视频国产精品一区二区| 正在播放国产一区| 欧美在线亚洲在线| 欧美成人免费小视频| 欧美大尺度激情区在线播放| 日韩av观看网址| 狠狠躁夜夜躁人人爽天天天天97| 在线观看精品国产视频| 国产精品久久不能| 亚洲第一区第二区| 97色在线观看| 国产精品福利网站| 欧美中文字幕视频在线观看| 欧美日本啪啪无遮挡网站| 一本大道亚洲视频| 国产91精品不卡视频| 国产精品久久久久秋霞鲁丝| 91在线精品视频| 美女性感视频久久久| 国产在线精品成人一区二区三区| 中文字幕成人在线| 日韩免费观看在线观看| 亚洲免费av网址| 欧美一级大片在线免费观看| 亚洲美女在线观看| 亚洲国产天堂久久综合网| 国产精品扒开腿做爽爽爽男男| 亚洲精品视频播放| 91wwwcom在线观看| 91在线精品视频| 俺去亚洲欧洲欧美日韩| 中文字幕日韩欧美精品在线观看| 国产精品久久久久91| 久久亚洲综合国产精品99麻豆精品福利| 亚洲a∨日韩av高清在线观看| 久久夜色精品国产| 日韩免费观看高清| 久久91亚洲精品中文字幕奶水| 最近免费中文字幕视频2019| 欧美日韩另类字幕中文| 神马久久久久久| 欧美极品少妇xxxxⅹ裸体艺术| 亚洲热线99精品视频| 久久久av一区| 91欧美精品成人综合在线观看| 亚洲第一页自拍| 亚洲欧美在线一区二区| 国产精品久久久久久久app| 国产成人精品综合久久久| 97人人模人人爽人人喊中文字|