unit generators(单元发生器)

declaring
connecting
controlling (timing mechanism)
mono + stereo
creating (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 s
SinOsc 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 input
SinOsc s => dac;

It is also possible to linearly(线性地) chain many UGens together in a single statement.在一个单独声明中,线性连接许多单元发生器

// connect SinOsc to Gain to reverb(混响) to dac
SinOsc 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 dac
SinOsc s => dac;
// set initial frequency (see next section)
440 => s.freq;// advance time; allow audio to compute
1::second => now;

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

    // connect SinOsc to dacSinOsc s => dac;// let time pass for 1 second letting audio be computed for that amount of time1::second => now;// disconnect s from the dacs =< dac;// let time pass for another second - should hear silence1::second => now;// duh, connect them agains => 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 dac
SinOsc s => dac;
// set initial frequency to 440 hz
440 => s.freq;// let time pass for 1 second
1::second => now;// change the frequency to 880 hz
880 => s.freq;

Since the control functions are member functions of the unit generator,
控制函数就是单元发生器的成员函数
the above syntax(语法) is equivalent to calling functions(等价于调用函数).

// connect SinOsc to dac
SinOsc s => dac;// set frequency to 440
s.freq( 440 );// let time pass
1::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 dac
SinOsc s => dac;// store the current value of the freq
s.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 dac
SinOsc foo => dac;
// triosc to dac
triosc bar => dac;// set frequency of foo and then bar
500 => foo.freq => bar.freq;// set one freq to the other
foo.freq() => bar.freq;// the above is same as:
bar.freq( foo.freq() );

Of course, varying(不同的) parameters over time is often more interesting.不同参数随时间推移是很有趣的。

// SinOsc to dac
SinOsc s => dac;// infinite time loop
while( true )
{// set the frequency( s.freq() + 200 ) % 5000 => s.freq;// advance time100::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).返回第几个通道引用,没有的话就返回null
  • op(int) (of type int): set/get operation at the UGen. 设定或获取单元发生器的操作 Values:
    • 0 : stop - always output 0
    • 1 : normal operation, add all inputs (default)
    • 2 : normal operation, subtract(减去) inputs starting from the earliest connected减去从最早的链接开始的输入(不甚理解???)
    • 3 : normal operation, multiply(乘以) all inputs
    • 4 : 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 channels
adc.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 dac
noise n => pan2 p => dac;// infinite time loop
while( true )
{// modulate(调整) the panMath.sin( now / 1::second * 2 * pi ) => p.pan;// advance time10::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).

ChucK初步(11)相关推荐

  1. 【财务危机】--2018.11债务

    2018年11月份债务说明 日期 名称 金额 状态 备注 2018-11-07 招商银行 3404 已还   2018-11-17 交通银行 20.60 已还   2018-11-10 蚂蚁花呗 20 ...

  2. 李煜东算法进阶指南打卡题解

    算法竞赛进阶指南 一.0x00 基本算法 1)位运算 2)递推与递归 3)前缀和与差分 4)二分 5)排序 6)倍增 7)贪心 8)习题 二.0x10 基本数据结构 1)栈 2)队列 3)链表与邻接表 ...

  3. matlab 祁彬彬,MATLAB 向量化编程基础精讲

    <MATLAB 向量化编程基础精讲>使用MATLAB新版本2016a,拣选Mathworks官方群组Cody中一些有趣的代码问题,分6章讲解这些优秀示例代码中使用数组.字符串操作.正则表达 ...

  4. Excle数据透视表学习大纲

    第一章:数据透视表初步 1-1.数据透视表及其用途 1-2.对数据源的要求 1-3.创建数据透视表 1-4.数据透视表的基本术语和4大区域 第二章:数据透视表的字段 2-1.数据透视表基本操作 2-2 ...

  5. 大一计算机导论教程总结,计算机导论实验教程--详细介绍

    第1篇&nbsp&nbsp操作技能篇 实验1&nbsp&nbsp键盘的使用方法与中/英文输入 1.1&nbsp&nbsp键盘的使用方法 1.2& ...

  6. latex_1_安装及语法基础入门

    latex安装及语法基础入门 1.LaTeX环境的安装与配置 2.LaTeX源文件的基本结构 3.LaTeX中的中文处理方法 4.LaTeX的字体设置 5.LaTeX的篇章结构 6.LaTeX中的特殊 ...

  7. Threejs系列--11游戏开发--沙漠赛车游戏【初步加载地面】

    Threejs系列--11游戏开发--沙漠赛车游戏[初步加载地面] 序言 目录结构 代码一览 world/index.js代码 world/Floor.js代码 materials/Floor.js代 ...

  8. Ubuntu18.04系统下,图像处理开源软件库 Opencv3.4.11的安装、编译及应用初步

    "学了opencv,妈妈再也不会担心你不会图像编程啦!" 文章目录 "学了opencv,妈妈再也不会担心你不会图像编程啦!" 前言 一.opencv-3.4.1 ...

  9. Lab08-数组初步(2019.11.19)

    Lab08-数组初步(2019.11.19) 文章目录 Lab08-数组初步(2019.11.19) 1. 向数组插入新元素[简单] 2. <Beginning C>5.1[简单] 3. ...

  10. redis-4.0.11主从配置初步探究

    redis-4.0.11相较于以前版本,新增了几个安全措施,稍稍研究了6379.conf配置文件,在这里记录一下. 实验环境: centos7.4 redis:redis-4.0.11 1. redi ...

最新文章

  1. Supervisor重新加载配置启动新的进程
  2. feedback from waic
  3. OpenCASCADE绘制测试线束:使用自定义命令扩展测试工具
  4. Java NIO ———— Buffer 缓冲区详解
  5. js定时器让动画隔秒运动
  6. Chrome浏览器 js 关闭窗口失效解决方法
  7. JVM之内存分配与回收策略
  8. 【Spring学习笔记-0】Spring开发所需要的核心jar包
  9. django高级之缓存与信号
  10. uni-app引入阿里Icon 图标方式(CustomIcon 扩展自定义图标库)
  11. 华为笔记本linux好不好,华为笔记本怎么样
  12. 计算机word虚线在哪里,在word中画虚线的五种方法
  13. java更新word目录_java aspose.words 生成word目录和更新目录
  14. python got an unexpected keyword argument
  15. 桌面计算机图标固定位置,win10桌面图标如何固定位置|win10电脑桌面图标固定位置方法...
  16. yolov3的weights文件获取方法(yolov3-spp.weights等等)
  17. 一对一语音直播系统源码——如何解决音视频直播技术难点
  18. 【渝粤教育】电大中专常见病药物治疗_1作业 题库
  19. 谷歌给应届毕业生的八条建议
  20. 基于计组实验软件CMStudio设计一种简单同或运算指令系统

热门文章

  1. java调用peopleSoft webservice
  2. Windows XP控制台图解
  3. OpenGL PowerVR SDK 编译:Could NOT find X11 (missing: X11_X11_INCLUDE_PATH X11_X11_LIB)
  4. 云上PDF怎么删除页眉页脚_PDF怎么删除页面?
  5. Android 开发常用性能优化工具总结
  6. ubuntu下dbus工具d-feet不显示路径和接口
  7. 微信授权 昵称显示微信用户、无头像
  8. JVM -- JVM内存结构:程序计数器、虚拟机栈、本地方法栈、堆、方法区(二)
  9. Android中的临时文件
  10. 2021年中式面点师(中级)最新解析及中式面点师(中级)模拟考试题库