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

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

ChucK初步(3)

2019-11-14 09:27:29
字體:
來源:轉載
供稿:網友

Types, Values, and Variables(變量)

ChucK is a strongly-typed language, meaning that types are resolved(決定) at compile-time. However, it is not quite statically-typed, because the compiler/type system is a part of the ChucK virtual(虛擬的) machine, and is a runtime component(成分). This type system helps to impose(強加) PRecision(精度) and clarity(清楚) in the code, and naturally lends to organization of complex(復雜的) programs. At the same time, it is also dynamic in that changes to the type system can take place (in a well-defined(定義明確的) manner) at runtime. This dynamic(動態的) aspect(方面) forms the basis(基礎) for on-the-fly programming.

This section deals with types, values, and the declaration(聲明) and usage(使用) of variables. As in other strongly-typed programming languages, we can think of a type as associated(關聯的) behaviors(行為) of data. (For example, an ‘int’ is a type that means integer(整數), and adding two integer is defined(定義) to produce a third integer representing the sum.) Classes and objects allow us to extend(延伸) the type system with our own custom types, but we won’t cover them in this section. We will focus mainly on primitive(原始的) types here, and leave the discussion of more complex types for classes and objects.

primitive types(原始類型)

The primitive(原始的), or intrinsic(本質的) types are those which are simple datatypes (they have no additional(附加的) data attributes(屬性)). Objects are not primitive types. Primitive types are passed by value. Primitive types cannot be extended(延伸). The primitive types in ChucK are:

int : integer(整數) (signed)float : floating point number (in ChucK, a float is by default double-precision(雙精度))time : ChucKian timedur : ChucKian duration(持續)void : (no type)complex : complex number in rectangular(矩形的) form a + bi (see [below][1])polar: complex number in polar(極面) form (see [below][1])

For a summary of Operations on these types, go to operations and operators.

All other types are derived(派生) from ‘object’, either as part of the ChucK standard library, or as a new class that you create. For specification(規格), go to classes and objects.

values (literals(字面值))

Literal values are specified(指定) explicitly(明確地) in code and are assigned(分配) a type by the compiler(編譯器).The following are some examples of literal values:

int:42int (hexidecimal):0xaf30float:1.323dur:5.5::second//In the above code, second is an existing duration(持續) variable(變量). //For more on durations, see the [manipulating time(時間調節)][4] section.

variables

Variables(變量) are locations in memory that hold data. Variables have to be declared in ChucK before they are used. For example, to declare a variable of type int called foo:

// declare an 'int' called 'foo'int foo;

We can assign(分配) a value to an existing variable by using the ChucK operator (=>). This is one of the most commonly used operators in ChucK, it’s the way to do work and take action! (后面會討論)

// assign value of 2 to 'foo'2 => foo;

It is possible to combine the two statements(聲明) into one:

// assign 2 to a new variable 'foo' of type 'int'2 => int foo;

To use a variable, just refer to it by name:

// debug-print the value of foo<<< foo >>>;

To update the value of foo, for example:

// multiply 'foo' by 10, assign back to 'foo'foo * 10 => foo;

You can also do the above using a *=> (mult-chuck):

// multiply 'foo' by 10, and then assign to 'foo'10 *=> foo;

Here is an example of a duration(持續):

// assign value of '5 seconds' to new variable bar5::second => dur bar;

Once you have bar, you can inductively(歸納的) use it to construct new durations:

// 4 bar, a measure?4::bar => dur measure;

輸出: C:/Users/abc1/Desktop>chuck test.ck 882000.000000 :(dur)

Since time is central to programming ChucK, it is important to understand time, dur, the relationship and operations between them. There is more information in the manipulating time section.

reference types(引用類型)

Reference(參考) types are types which inherit(繼承) from the object class. Some default reference types include:

Object : base type that all classes inherit from (directly or indirectly)所有類繼承的基本類型array : N-dimensional ordered(有序的) set of data (of the same type)Event : fundamental(基本的), extendable(可擴展的), synchronization(同步) mechanism(機制)UGen : extendable unit generator(單元發生器) base class (U = unit, Gen = generator)string : string (of characters)

New classes can be created. All classes are reference types. We will leave the full discussion to the objects and classes section.

complex types

(虛數:直角坐標系,極坐標系)

Two special primitive types are available to to represent complex (復雜的)data, such as the output (輸出)of an FFT: complex and polar. A complex number of the form a + bi can be declared as

#(2,3) => complex cmp; //cmp is now 2 + 3i

where the #(…) syntax(語法) explicitly(明確地) denotes(表示) a complex number in rectangular form(矩形). Similarly, explicit complex numbers can be manipulated(操縱) directly:

#(5, -1.5) => complex cmp; // cmp is 5 - 1.5i#(2,3) + #(5,6) + cmp => complex sum; // sum is now 12 + 7.5i

The (floating point) real and imaginary parts(實虛部) of a complex number can be accessed(存取) with the .re and .im components of a complex number:

#(2.0,3.5) => complex cmp;cmp.re => float x; // x is 2.0cmp.im => float y; //y is 3.5

The polar type(極坐標) offers an equivalent(等價的), alternative(供選擇的) representation(表示) of complex numbers in terms of a magnitude(大小) and phase(相) value. A polar representation of a complex number can be declared as

%(2, .5*pi) => polar pol; // pol is 2∠.5π(沒有想到,竟然有這個(●'?'●))

The magnitude(大小) and phase(相) values can be accessed via .mag and .phase:

%(2, .5*pi) => polar pol;pol.mag => float m; // m is 2pol.phase => float p; //p is .5π

polar and complex representations(代表) can be cast to each other and multiplied/added/assigned(分配)/etc.:

%(2, .5*pi) => polar pol;#(3, 4) => complex cmp;pol $ complex + #(10, 3) + cmp => complex cmp2;cmp $ polar + %(10, .25*pi) - pol => polar pol2;

(這里的$實現了兩種坐標系下表示的轉換)

輸出: C:/Users/abc1/Desktop>chuck test.ck %(2.0000,0.5000*pi) :(polar) #(3.0000,4.0000) :(complex) #(13.0000,9.0000) :(complex) %(13.5540,0.2334*pi) :(polar)


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
日韩av成人在线| 国内揄拍国内精品少妇国语| 欧美国产日韩免费| 久久影视电视剧免费网站清宫辞电视| 日韩av电影手机在线| 亚洲欧美变态国产另类| 欧美一乱一性一交一视频| 一区二区三区美女xx视频| 国产精品久久久久aaaa九色| 国产亚洲精品高潮| 精品亚洲国产成av人片传媒| 日韩欧美中文免费| 亚洲乱码一区av黑人高潮| 国产精品扒开腿做爽爽爽男男| 欧美性视频精品| 国产成人高清激情视频在线观看| 国产精品免费视频xxxx| 国产美女精彩久久| 国产欧美亚洲精品| 日韩亚洲欧美中文在线| 国产91免费观看| 国产成人精品最新| 欧美一乱一性一交一视频| 亚洲免费电影一区| 中文字幕亚洲一区二区三区五十路| 日韩欧美在线字幕| 欧美激情视频网| 亚洲黄页网在线观看| 日韩人体视频一二区| 久久频这里精品99香蕉| 久久成人人人人精品欧| 亚洲成人免费在线视频| 国产精品日本精品| 亚洲精品国产精品自产a区红杏吧| 久久香蕉国产线看观看av| 久久久国产影院| 国产精品黄视频| 欧美中文在线观看| 国产午夜精品免费一区二区三区| 狠狠躁夜夜躁人人爽超碰91| 成人精品久久一区二区三区| 欧美一级电影久久| 久久久噜久噜久久综合| 精品久久在线播放| 欧美自拍视频在线观看| 国产精品视频色| 日韩欧美a级成人黄色| 精品调教chinesegay| 91免费精品国偷自产在线| 九九视频这里只有精品| 欧美另类交人妖| 久久亚洲综合国产精品99麻豆精品福利| 亚洲第一精品电影| 国产一区私人高清影院| 亚洲香蕉成人av网站在线观看| 欧美成人精品不卡视频在线观看| 亚洲精品久久久久久久久久久久久| 久久精品人人做人人爽| 欧美性猛交xxxx久久久| 亚洲大尺度美女在线| 亚洲欧美日韩在线高清直播| 国产精品久久久久久久久影视| 国产精品偷伦一区二区| 久久久久久久国产精品视频| 日本精品一区二区三区在线| 欧美日韩亚洲精品内裤| 亚洲欧美日韩国产精品| 国产精品日日摸夜夜添夜夜av| 日韩免费在线播放| 成人免费大片黄在线播放| 国产精品久久久999| 国产精品久久久久不卡| 国产精品精品国产| 美女999久久久精品视频| xxxxx成人.com| 欧美成人中文字幕在线| 另类色图亚洲色图| 97久久精品视频| 久久久电影免费观看完整版| 色偷偷av一区二区三区| 92看片淫黄大片欧美看国产片| 国产精品草莓在线免费观看| 亚洲欧美日韩在线高清直播| 综合网日日天干夜夜久久| 国产精品视频一区国模私拍| 91沈先生作品| 亚洲va欧美va在线观看| 26uuu亚洲伊人春色| 免费不卡在线观看av| 欧美成人在线影院| 国产精品爱久久久久久久| 亚洲电影中文字幕| 欧美激情久久久| 欧洲成人性视频| 亚洲精品福利免费在线观看| 久久久久女教师免费一区| 亚洲电影免费观看高清| 国产精品午夜一区二区欲梦| 欧美精品成人91久久久久久久| 国模精品视频一区二区三区| 久久视频免费在线播放| 日本亚洲欧美成人| 97av在线视频免费播放| 亚洲欧洲午夜一线一品| 国产精品人成电影在线观看| 成人免费大片黄在线播放| 精品久久久久久久久久国产| www.日本久久久久com.| 4388成人网| 蜜臀久久99精品久久久无需会员| 亚洲国产婷婷香蕉久久久久久| 久久久久久久久久久久久久久久久久av| 国产精品精品国产| 国产亚洲精品久久久优势| 91综合免费在线| 欧美性猛交xxxx乱大交| 亚洲精品福利视频| 欧美性猛交xxxx富婆弯腰| 97热在线精品视频在线观看| 国产精品专区一| 日韩成人小视频| 国产精品成人av在线| 91精品久久久久久久久不口人| 精品国偷自产在线视频99| 亚洲第一精品久久忘忧草社区| 国产精品久久久久久久久久久久| 精品国产精品三级精品av网址| 欧美激情网友自拍| 亚洲精品免费网站| 狠狠色狠色综合曰曰| 日本精品一区二区三区在线播放视频| 久久91精品国产| 亚洲一区二区久久| 91色琪琪电影亚洲精品久久| 久操成人在线视频| 日韩在线视频观看正片免费网站| 国产亚洲精品久久| 91精品国产成人| 欧美国产欧美亚洲国产日韩mv天天看完整| 亚洲永久免费观看| 91精品久久久久| 亚洲国产精品一区二区三区| 久久国产精品网站| 亚洲国产精品久久久久秋霞蜜臀| 日韩高清电影免费观看完整| 欧美精品在线免费播放| 亚洲黄色有码视频| 欧美巨猛xxxx猛交黑人97人| 正在播放国产一区| 国产福利精品视频| 久久久久久久久久国产| 欧美精品在线视频观看| 5566日本婷婷色中文字幕97| 狠狠躁夜夜躁人人爽超碰91| 国产精品成人v| 92看片淫黄大片欧美看国产片| 成人免费网站在线| 午夜精品久久久久久久久久久久久| 亚洲国产高清福利视频| 国产一区二区成人| 狠狠综合久久av一区二区小说| 国产不卡av在线免费观看| 91精品美女在线| 日韩中文在线不卡|