跳转到内容
查看源码

audio自动生成

分类:包 · 清单:use "kernels/";

声音的基本单元:每帧一块立体声采样;时钟、事件触发、噪声、音调、包络、滤波与延迟线。

Sound’s atoms, a block of stereo samples a frame: the clock, the cues a program’s events set going, noise, a tone and an envelope, and the filters and delay lines that shape them.

Layer: Media. Uses: random.

use "audio.entpkg";
  • kernels/clock.ent — Sound made from tones and noise, a block of stereo samples a frame. Kernels: audio.clock_start@1, audio.clock@1, audio.paced_start@1, audio.paced@1, audio.paced_clock@1, audio.paced_size@1.
  • kernels/cue.ent — Cues. Kernels: audio.cues_start@1.
  • kernels/delay.ent — Delay lines in a memory carried from frame to frame.
  • kernels/filter.ent — Filters, sample by sample.
  • kernels/instrument.ent — What sounds are made of, as functions of time: noise, a tone, an envelope, and the turns a moving pitch has run (glide_cycles, vibrato_cycles, sounded by cycle).

tests/ holds scenes and their replays, run on every backend: clock.replay, delay.replay, filters.replay, glide.replay. Every Kernel of the package is reached by one of them.

Used by the slg, sound, spells examples.

Kernel 执行模式 简述
audio.clock@1 map The clock a block on.
audio.clock_start@1 map The clock before the first block, which synth.clock counts on from: the first block begins at sample 0.
audio.cues_start@1 map The voices, quiet.
audio.paced@1 map
audio.paced_clock@1 map The paced clock as the voices and the sound read it, and the block’s size for the sound’s domain.
audio.paced_size@1 map
audio.paced_start@1 map
函数 简述
block() -> Int The samples a frame, the voices, the samples a second (the device’s, 48000 without one).
hz() -> Float
tau() -> Float
low_bits(n: Long) -> Int Sample n’s low 31 bits, an Int a hash takes: what is made from them repeats every half day of samples.
paced_step() -> Int
paced_first() -> Int
paced_most() -> Int
paced_margin() -> Int
paced_ahead_most() -> Int
voices() -> Int
cue(kind: Int, param: Int, start: Long) -> Cue A cue of kind and param starting at sample start, in the middle and at full gain: what a program’s event sets going.
quiet() -> Cue A voice with nothing to play.
delay_tap(line: Rows<Float>, base: Int, length: Int, head: Int, back: Int) -> Float What the line held back samples before the head, 1 being the last sample written.
delay_push(line: Rows<Float>, base: Int, length: Int, head: Int, x: Float) -> Int Writes x at the head; yields the head one sample on.
delay_echo(line: Rows<Float>, base: Int, length: Int, head: Int, x: Float, feedback: Float) -> Float A feedback echo: what the line gives back length samples late, after x and that much of the echo have gone in at the head. The head moves on with delay_push’s rule, (head + 1) % length.
string_pluck(line: Rows<Float>, base: Int, length: Int, seed: Int) -> Int Fills a line with a burst of noise from seed seed, which is what plucks a string.
string_step(line: Rows<Float>, base: Int, length: Int, head: Int, decay: Float) -> Float A plucked string, one sample on: what the head holds comes out, and its average with the next one goes back in decay quieter, so the high partials fade first. The head moves on as delay_push’s does.
one_pole_coefficient(corner: Float, rate: Float) -> Float The one-pole coefficient that puts a filter’s corner at corner Hz, at rate samples a second.
one_pole_low(y: Float, x: Float, a: Float) -> Float A one-pole low-pass: the last output y moved toward x by a, 0 to 1.
biquad_quiet() -> BiquadState
biquad_corner(corner: Float, rate: Float) -> Float
biquad_alpha(w: Float, q: Float) -> Float
biquad_scaled(b0: Float, b1: Float, b2: Float, a0: Float, a1: Float, a2: Float) -> Biquad
biquad_low_pass(corner: Float, q: Float, rate: Float) -> Biquad Passes what is below corner Hz; q 0.7071 is flat to the corner.
biquad_high_pass(corner: Float, q: Float, rate: Float) -> Biquad Passes what is above corner Hz.
biquad_band_pass(corner: Float, q: Float, rate: Float) -> Biquad Passes a band around corner Hz, at full gain at its middle.
biquad_notch(corner: Float, q: Float, rate: Float) -> Biquad Takes out a band around corner Hz.
biquad_step(f: Biquad, s: BiquadState, x: Float) -> BiquadState One sample through the filter: the memory after x, its output in y1.
white(n: Long, s: Int) -> Float White noise, -1 to 1, at sample n.
soft_noise(x: Float, s: Int) -> Float Noise smoothed between random values x apart: its pitch rises with how fast x runs. For a pitch that moves, x is the phase it has run (glide_cycles), not the pitch times the time.
envelope(t: Float, a: Float, d: Float) -> Float
tone(f: Float, t: Float) -> Float A tone at a steady pitch f, t seconds in. Only for a steady pitch: the pitch times the time of a pitch that moves is heard as the pitch plus the time times how fast it moves (a falling glide turns and rises); for one that moves, cycle of the phase it has run.
cycle(p: Float) -> Float A sine p turns round (its phase counted in turns).
glide_cycles(from: Float, to: Float, time: Float, closing: Bool, t: Float) -> Float The turns a pitch gliding from from to to has run t seconds in: straight over time seconds and then held at to, or (closing) closing in on to as exp(-t / time).
vibrato_cycles(f: Float, depth: Float, rate: Float, t: Float) -> Float The turns a pitch f wavering by depth (a share of it) rate times a second has run t seconds in.
名称 写法
Clock struct Clock { n: Long; }
Clocks type Clocks = Rows<Clock>;
Paced struct Paced { n: Long; block: Int; seen: Long; }
Paceds type Paceds = Rows<Paced>;
Cue struct Cue { kind: Int; param: Int; start: Long; pan: Float; gain: Float; head: Int; }
Cues type Cues = Rows<Cue>;
Biquad struct Biquad { b0: Float; b1: Float; b2: Float; a1: Float; a2: Float; }
BiquadState struct BiquadState { x1: Float; x2: Float; y1: Float; y2: Float; }

The clock a block on.

执行模式 map
需要能力 field.read, field.write
输入 previous: Rows<Clock>
参数 —
输出 result: Rows<Clock>
源码 packages/audio.entpkg/kernels/clock.ent

The clock before the first block, which synth.clock counts on from: the first block begins at sample 0.

执行模式 map
需要能力 field.write
输入 —
参数 —
输出 result: Rows<Clock>
源码 packages/audio.entpkg/kernels/clock.ent

The voices, quiet.

执行模式 map
需要能力 field.write
输入 —
参数 —
输出 result: Rows<Cue>
源码 packages/audio.entpkg/kernels/cue.ent
执行模式 map
需要能力 field.read, field.write, time.read
输入 previous: Rows<Paced>
参数 —
输出 result: Rows<Paced>
源码 packages/audio.entpkg/kernels/clock.ent

The paced clock as the voices and the sound read it, and the block’s size for the sound’s domain.

执行模式 map
需要能力 field.read, field.write
输入 paced: Rows<Paced>
参数 —
输出 result: Rows<Clock>
源码 packages/audio.entpkg/kernels/clock.ent
执行模式 map
需要能力 field.read, field.write
输入 paced: Rows<Paced>
参数 —
输出 result: Rows<Float>
源码 packages/audio.entpkg/kernels/clock.ent
执行模式 map
需要能力 field.write
输入 —
参数 —
输出 result: Rows<Paced>
源码 packages/audio.entpkg/kernels/clock.ent

clock.replay, delay.replay, filters.replay, glide.replay