@audio/amp-cabinet 1.2.1 → 1.2.3

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.
Files changed (3) hide show
  1. package/audio.d.ts +27 -0
  2. package/cabinet.js +6 -15
  3. package/package.json +13 -4
package/audio.d.ts ADDED
@@ -0,0 +1,27 @@
1
+ // Generated from the audio.js manifest (params metadata is the source of truth).
2
+ // Regenerate: node tools/dts.js in @audio/compile. Do not edit by hand.
3
+
4
+ /** Automatable number — scalar, `t => value` fn, or breakpoint curve {t, v} */
5
+ type Auto = number | ((t: number) => number) | { t: number[], v: number[] }
6
+ /** Per-block param values as delivered by hosts (numbers arrive as 1-length Float32Array) */
7
+ type Live = Record<string, Float32Array | string | boolean>
8
+ type Ctx = { sampleRate: number, maxBlockSize: number, maxChannels: number, currentTime: number, duration?: number, events?: readonly any[], emit?: (name: string, ...args: any[]) => void, [k: string]: unknown }
9
+ type Process = (inputs: Float32Array[][], outputs: Float32Array[][], params: Live) => void
10
+
11
+ /** Chainable-host options for 'cabinet' */
12
+ export interface CabinetOptions {
13
+ /** 0..1 (default 1) */
14
+ "mix"?: Auto
15
+ at?: number | string
16
+ duration?: number | string
17
+ }
18
+
19
+ export declare const cabinet: {
20
+ (ctx: Ctx): Process
21
+ channels: "any"
22
+ streaming: false
23
+ params: {
24
+ /** 0..1 (default 1) */
25
+ "mix": { type: "number", default: 1 }
26
+ }
27
+ }
package/cabinet.js CHANGED
@@ -3,16 +3,7 @@
3
3
  // closed-back 12" cab: 70 Hz highpass, low bump, presence peak, steep rolloff above ~4.5 kHz.
4
4
 
5
5
  import convolve from '@audio/reverb-convolution'
6
- import { lowpass, highpass, peaking } from '@audio/biquad'
7
-
8
- function biquadRun (data, c) {
9
- let x1 = 0, x2 = 0, y1 = 0, y2 = 0
10
- for (let i = 0; i < data.length; i++) {
11
- let x = data[i]
12
- let y = c.b0 * x + c.b1 * x1 + c.b2 * x2 - c.a1 * y1 - c.a2 * y2
13
- x2 = x1; x1 = x; y2 = y1; y1 = data[i] = y
14
- }
15
- }
6
+ import { lowpass, highpass, peaking, process as biquad } from '@audio/biquad'
16
7
 
17
8
  /**
18
9
  * @param {Float32Array} data — mono PCM, processed in place
@@ -20,10 +11,10 @@ function biquadRun (data, c) {
20
11
  */
21
12
  export default function cabinet (data, { fs = 44100, ir, mix = 1 } = {}) {
22
13
  if (ir) return convolve(data, { ir, mix, normalize: true })
23
- biquadRun(data, highpass(70, 0.707, fs))
24
- biquadRun(data, peaking(110, 1, fs, 2))
25
- biquadRun(data, peaking(2400, 1.2, fs, 3))
26
- biquadRun(data, lowpass(4500, 0.707, fs))
27
- biquadRun(data, lowpass(5200, 0.707, fs))
14
+ biquad(data, highpass(70, 0.707, fs))
15
+ biquad(data, peaking(110, 1, fs, 2))
16
+ biquad(data, peaking(2400, 1.2, fs, 3))
17
+ biquad(data, lowpass(4500, 0.707, fs))
18
+ biquad(data, lowpass(5200, 0.707, fs))
28
19
  return data
29
20
  }
package/package.json CHANGED
@@ -1,18 +1,22 @@
1
1
  {
2
2
  "name": "@audio/amp-cabinet",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "description": "Cabinet simulation — measured-IR convolution (pair with @audio/measure-ir) or classical speaker-sim biquads",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "main": "cabinet.js",
8
8
  "exports": {
9
9
  ".": "./cabinet.js",
10
- "./audio": "./audio.js",
10
+ "./audio": {
11
+ "types": "./audio.d.ts",
12
+ "default": "./audio.js"
13
+ },
11
14
  "./package.json": "./package.json"
12
15
  },
13
16
  "files": [
14
17
  "cabinet.js",
15
- "audio.js"
18
+ "audio.js",
19
+ "audio.d.ts"
16
20
  ],
17
21
  "dependencies": {
18
22
  "@audio/reverb-convolution": "^1.0.0",
@@ -33,5 +37,10 @@
33
37
  "publishConfig": {
34
38
  "access": "public"
35
39
  },
36
- "audio": "./audio.js"
40
+ "audio": "./audio.js",
41
+ "repository": {
42
+ "type": "git",
43
+ "url": "git+https://github.com/audiojs/amp.git",
44
+ "directory": "packages/amp-cabinet"
45
+ }
37
46
  }