@audio/effect-ringmod 1.1.4 → 1.1.6

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 CHANGED
@@ -15,7 +15,7 @@ Multiplies signal by a carrier oscillator — produces sum and difference freque
15
15
  **`fc`** carrier frequency Hz (default 440) · **`mix`** wet/dry 0–1 (default 1) · **`fs`** sample rate
16
16
 
17
17
  ```js
18
- import { ringMod } from '@audio/effect'
18
+ import ringMod from '@audio/effect-ringmod'
19
19
 
20
20
  let p = { fc: 300, mix: 1, fs: 44100 }
21
21
  for (let buf of stream) ringMod(buf, p)
package/audio.js CHANGED
@@ -1,11 +1,12 @@
1
1
  // atom manifest — wraps the ring-mod atom; pure oscillator multiply, no sizing
2
- // params — every param stays live, per-channel state is just the running carrier phase.
2
+ // params — every param stays live, per-channel state is just the running carrier phase,
3
+ // made here so the first block sets nothing up.
3
4
 
4
5
  import ringModFn from './ring-mod.js'
5
6
 
6
7
  export const ringmod = (ctx) => {
7
8
  const chP = []
8
- for (let c = 0, N = ctx.maxChannels ?? 8; c < N; c++) chP.push({ fs: ctx.sampleRate })
9
+ for (let c = 0, N = ctx.maxChannels ?? 8; c < N; c++) chP.push({ fs: ctx.sampleRate, _phase: 0 })
9
10
  return (inputs, outputs, params) => {
10
11
  const inp = inputs[0], out = outputs[0]
11
12
  if (!inp || !inp.length) return
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@audio/effect-ringmod",
3
- "version": "1.1.4",
3
+ "version": "1.1.6",
4
4
  "description": "Ring modulator — multiplies signal by a carrier oscillator",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -13,6 +13,9 @@
13
13
  "default": "./audio.js"
14
14
  }
15
15
  },
16
+ "scripts": {
17
+ "prepublishOnly": "node ../../../compile/tools/tested.js"
18
+ },
16
19
  "files": [
17
20
  "ring-mod.js",
18
21
  "audio.js",
package/ring-mod.d.ts CHANGED
@@ -12,4 +12,4 @@ export interface RingModOptions {
12
12
  * Mutates `data` in place and returns the same reference. Pass the same params
13
13
  * object across calls — the running carrier phase persists on it (`_phase`).
14
14
  */
15
- export default function ringMod(data: Float32Array, params?: RingModOptions): Float32Array
15
+ export default function ringMod<T extends Float32Array | Float64Array>(data: T, params?: RingModOptions): T
package/ring-mod.js CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  let {sin, PI} = Math
6
6
 
7
- export default function ringMod (data, params) {
7
+ export default function ringMod (data, params = {}) {
8
8
  let fc = params.fc || 440
9
9
  let fs = params.fs || 44100
10
10
  let mix = params.mix == null ? 1 : params.mix