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

  • The ChucK Tutorial

This tutorial was written for the command line version of ChucK (currently the most stable(稳定的) 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 pass
2::second => now;

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

chuck foo.ck

For now, we can just take the second line of code to mean “let 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 time
while( 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 patch
SinOsc s => dac;// time-loop, in which the osc's frequency is changed every 100 ms
while( 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.

目前运行的结果是有并不规律的声音产生,这就是那个时刻变形的声波


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's
1 => f.eqzs;//不理解
// initialize float variable
0.0 => float v;// infinite time-loop
while( true )
{// set the current sample/impulse1.0 => i.next;// sweep the filter resonant frequency(共振频率)Std.fabs(Math.sin(v)) * 4000.0 => f.pfreq;// increment(增量) vv + .1 => v;// advance time100::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(发出) the lower-frequency pulses(脉冲).

ChucK supports sample-synchronous concurrency(并发性), via the ChucK timing mechanism(机制). 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

ChucK初步(1)相关推荐

  1. TensorRT 7.2.1开发初步

    TensorRT 7.2.1开发初步 TensorRT 7.2.1开发人员指南演示了如何使用C ++和Python API来实现最常见的深度学习层.它显示了如何采用深度学习框架构建现有模型,并使用该模 ...

  2. SOC,System on-a-Chip技术初步

    SOC,System on-a-Chip技术初步 S O C(拼作S-O-C)是一种集成电路,它包含了电子系统在单个芯片上所需的所有电路和组件.它可以与传统的计算机系统形成对比,后者由许多不同的组件组 ...

  3. 《OpenCV3编程入门》学习笔记3 HighGUI图形用户界面初步

    第3章 HighGUI图形用户界面初步 3.1 图像的载入.显示和输出到文件 1.OpenCV命名空间2种访问方法 (1)代码开头加:usingnamespace cv; (2)每个类或函数前加:cv ...

  4. 初步判断内存泄漏方法

    有时候,内存泄漏不明显,或者怀疑系统有内存泄漏,我们可以通过下面介绍的方法初步确认系统是否存在内存泄漏. 首先在Java命令行中增加-verbose:gc参数, 然后重新启动java进程. 当系统运行 ...

  5. android蓝牙4.0(BLE)开发之ibeacon初步

    一个april beacon里携带的信息如下 ? 1 <code class=" hljs ">0201061AFF4C0002159069BDB88C11416BAC ...

  6. 游戏AI之初步介绍(0)

    目录 游戏AI是什么? 游戏AI和理论AI 智能的假象 (更新)游戏AI和机器学习 介绍一些游戏AI 4X游戏AI <求生之路>系列 角色扮演/沙盒游戏中的NPC 游戏AI 需要学些什么? ...

  7. 【转】ibatis的简介与初步搭建应用

    [转]ibatis的简介与初步搭建应用 一.ibatis的简介 ibatis是什么东西就不介绍了,自己去找谷老师. 这里讲下自己的使用体会.之前自己学过Hibernate,是看尚学堂的视频教学的,看完 ...

  8. 初步了解:使用JavaScript进行表达式(De Do Do Do,De Da Da Da)

    by Donavon West 由Donavon West 初步了解:使用JavaScript进行表达式(De Do Do Do,De Da Da Da) (A first look: do expr ...

  9. 存储过程和存储函数初步

    2019独角兽企业重金招聘Python工程师标准>>> 存储过程和函数初步 简单的来说,存储过程就是一条或者多条 SQL 语句的集合,可视为批处理文件,但是其作用不仅限于批处理. # ...

  10. 【spring框架】spring整合hibernate初步

    spring与hibernate做整合的时候,首先我们要获得sessionFactory. 我们一般只需要操作一个sessionFactory,也就是一个"单例",这一点很适合交给 ...

最新文章

  1. 前端必须会的基本知识题目
  2. Android Studio离线打包5+SDK
  3. Talairach空间、MNI空间、Native空间、Stereotaxic空间
  4. JAVA 设计模式 : 状态模式
  5. mysql字符集调整总结
  6. Ubuntu系统初识-常用命令和软件安装
  7. 从10秒到2秒!ElasticSearch性能调优实践
  8. 关于SubSonic3.0插件使用SubSonic.Query.Select查询时,字段类型为tinyint时列丢失问题的Bug修复...
  9. 中国科学技术大学生物信息学考试复习资料(整理版)
  10. 小程序的发布并发布为Android App流程
  11. java 中Shallow Heap与Retained Heap的区别
  12. QQ-----无形的“扫描器”
  13. Python基础笔记(二)整数缓存、字符串驻留机制、字符串格式化等
  14. 如何有效管理和快速盘点固定资产?
  15. ChatGPT4 的体验 一站式 AI工具箱 -—Poe(使用教程)
  16. jQuery Ui Tabs插件使用问题记录
  17. 《SystemUI》修改SystemUI锁屏界面时间格式
  18. 【计算机毕业设计】2.酒店预订管理系统
  19. 小学数学计算机教案模板,小学数学万能教案模板
  20. Ternary weight networks 论文笔记

热门文章

  1. win10做好备份如何恢复系统
  2. Linux入侵痕迹清理
  3. 小米pro15拆机_小米笔记本Pro 15增强版值得买吗 小米笔记本Pro 15增强版拆解+评测...
  4. MongoDB分片集群部署(三)
  5. parameter与argument,property与attribute,这些翻译意思相近的词的区别
  6. python中f‘{}‘用法
  7. 安卓投屏传输手机声音到电脑最简单的方式
  8. What Makes a Good Teacher
  9. 理解Netflow工作原理
  10. 摸爬滚打DirectX11_day02——VS2010+DirectX11的环境配置