@audio/amp-cabinet 1.3.0 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/audio.d.ts +7 -5
- package/cabinet.d.ts +1 -1
- package/cabinet.js +13 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ npm install @audio/amp-cabinet
|
|
|
10
10
|
import cabinet from '@audio/amp-cabinet'
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
With an `ir` (capture your own with `@audio/measure-ir`), convolves through `@audio/reverb-convolution` (`normalize: true`, so output level tracks input level regardless of the IR's own loudness) — the accurate path. Without one, a fixed classical speaker-sim biquad chain approximates a closed-back 12" cab: 70 Hz highpass, a low-mid bump, a presence peak around 2.4 kHz, and a steep rolloff above ~4.5 kHz.
|
|
13
|
+
With an `ir` (capture your own with `@audio/measure-ir`), convolves through `@audio/reverb-convolution` (`normalize: true`, so output level tracks input level regardless of the IR's own loudness) — the accurate path. Without one, a fixed classical speaker-sim biquad chain approximates a closed-back 12" cab: 70 Hz highpass, a low-mid bump, a presence peak around 2.4 kHz, and a steep rolloff above ~4.5 kHz. A section's frequency is held at 0.49 of the sample rate (past Nyquist its poles leave the unit circle), so at 8 kHz the rolloff sits at 3.92 kHz.
|
|
14
14
|
|
|
15
15
|
```js
|
|
16
16
|
cabinet(data, { fs: 44100 }) // biquad approximation, no IR
|
package/audio.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
// Generated from the audio.js manifest (params metadata is the source of truth).
|
|
2
|
-
// Regenerate: node tools/dts.js in @audio/
|
|
2
|
+
// Regenerate: node tools/dts.js in @audio/plugin. Do not edit by hand.
|
|
3
3
|
|
|
4
4
|
/** Automatable number — scalar, `t => value` fn, or breakpoint curve {t, v} */
|
|
5
5
|
type Auto = number | ((t: number) => number) | { t: number[], v: number[] }
|
|
6
6
|
/** Per-block param values as delivered by hosts (numbers arrive as 1-length Float32Array) */
|
|
7
7
|
type Live = Record<string, Float32Array | string | boolean>
|
|
8
|
-
type
|
|
8
|
+
type Transport = Readonly<{ playing: boolean, bpm: number, beat: number, barStart: number, timeSig: [number, number] }>
|
|
9
|
+
/** What a host hands a processor it builds: the contract's Context (CONTRACT.d.ts, 1.0) */
|
|
10
|
+
type Ctx = { readonly sampleRate: number, readonly maxBlockSize: number, readonly maxChannels: number, readonly layouts?: { readonly inputs: readonly (string | undefined)[], readonly outputs: readonly (string | undefined)[] }, readonly params: Live, readonly buffers: Readonly<Record<string, Float32Array[] | undefined>>, readonly events?: readonly { time: number, kind: 'on' | 'off', midi: number, velocity: number, id: number }[], emit(name: string, value: number): void, readonly transport: Transport }
|
|
9
11
|
type Process = (inputs: Float32Array[][], outputs: Float32Array[][], params: Live) => void
|
|
10
12
|
|
|
11
13
|
/** Chainable-host options for 'cabinet' */
|
|
@@ -17,12 +19,12 @@ export interface CabinetOptions {
|
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
export declare const cabinet: {
|
|
20
|
-
(ctx: Ctx & { buffers: { "ir"
|
|
22
|
+
(ctx: Ctx & { buffers: { "ir"?: Float32Array[] | undefined } }): Process
|
|
21
23
|
channels: "any"
|
|
22
24
|
buffers: {"ir":{"channels":1}}
|
|
23
|
-
tail: (at: { sampleRate: number, params: Live, buffers
|
|
25
|
+
tail: (at: { sampleRate: number, params: Live, buffers?: { "ir"?: Float32Array[] | undefined }, transport: Transport }) => number
|
|
24
26
|
params: {
|
|
25
27
|
/** 0..1 (default 1) */
|
|
26
|
-
"mix": { type: "number", default: 1 }
|
|
28
|
+
"mix": { type: "number", min: 0, max: 1, default: 1, smoothing: 0.02 }
|
|
27
29
|
}
|
|
28
30
|
}
|
package/cabinet.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export default function cabinet(data: Float32Array, options?: CabinetOptions): F
|
|
|
14
14
|
/** A biquad section, normalized (a0 = 1), as `@audio/biquad` makes it. */
|
|
15
15
|
export interface Section { b0: number; b1: number; b2: number; a1: number; a2: number }
|
|
16
16
|
|
|
17
|
-
/** The biquad chain's sections at `fs`, in order: 70 Hz highpass, 110 Hz bump, 2.4 kHz peak, 4.5 and 5.2 kHz lowpasses. */
|
|
17
|
+
/** The biquad chain's sections at `fs`, in order: 70 Hz highpass, 110 Hz bump, 2.4 kHz peak, 4.5 and 5.2 kHz lowpasses, each frequency held at 0.49 of `fs`. */
|
|
18
18
|
export function chain(fs: number): Section[]
|
|
19
19
|
|
|
20
20
|
/** A number as a host gives a processor its values: a 1-length array. */
|
package/cabinet.js
CHANGED
|
@@ -5,14 +5,19 @@
|
|
|
5
5
|
import convolve from '@audio/reverb-convolution'
|
|
6
6
|
import { lowpass, highpass, peaking, process as biquad } from '@audio/biquad'
|
|
7
7
|
|
|
8
|
-
/** The biquad chain's sections at `fs`, in order
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
/** The biquad chain's sections at `fs`, in order, each frequency held at 0.49 of the rate: past Nyquist a section's
|
|
9
|
+
* poles leave the unit circle (the 4.5 and 5.2 kHz lowpasses at rates under 10.4 kHz wrote NaN), the rule every
|
|
10
|
+
* /audio processor of @audio/filter and @audio/eq keeps */
|
|
11
|
+
export const chain = fs => {
|
|
12
|
+
const at = f => Math.min(f, fs * 0.49)
|
|
13
|
+
return [
|
|
14
|
+
highpass(at(70), 0.707, fs),
|
|
15
|
+
peaking(at(110), 1, fs, 2),
|
|
16
|
+
peaking(at(2400), 1.2, fs, 3),
|
|
17
|
+
lowpass(at(4500), 0.707, fs),
|
|
18
|
+
lowpass(at(5200), 0.707, fs),
|
|
19
|
+
]
|
|
20
|
+
}
|
|
16
21
|
|
|
17
22
|
/**
|
|
18
23
|
* @param {Float32Array} data — mono PCM, processed in place
|
package/package.json
CHANGED