@audio/effect-ringmod 1.1.2 → 1.1.4
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 +33 -0
- package/audio.d.ts +30 -0
- package/package.json +11 -4
- package/ring-mod.d.ts +15 -0
package/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# @audio/effect-ringmod [](https://www.npmjs.com/package/@audio/effect-ringmod) [](https://github.com/krishnized/license)
|
|
2
|
+
|
|
3
|
+
Ring modulator — multiplies signal by a carrier oscillator
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
npm install @audio/effect-ringmod
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
import ringMod from '@audio/effect-ringmod'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Multiplies signal by a carrier oscillator — produces sum and difference frequencies.
|
|
14
|
+
|
|
15
|
+
**`fc`** carrier frequency Hz (default 440) · **`mix`** wet/dry 0–1 (default 1) · **`fs`** sample rate
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
import { ringMod } from '@audio/effect'
|
|
19
|
+
|
|
20
|
+
let p = { fc: 300, mix: 1, fs: 44100 }
|
|
21
|
+
for (let buf of stream) ringMod(buf, p)
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
**Use when**: metallic/robotic tones, experimental textures, AM synthesis<br>
|
|
25
|
+
**Not for**: clean frequency shifting
|
|
26
|
+
|
|
27
|
+
<!--  -->
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
Part of [@audio/effect](https://github.com/audiojs/effect) — the effect family umbrella. This README is generated from the umbrella docs.
|
|
32
|
+
|
|
33
|
+
MIT © [audiojs](https://github.com/audiojs)
|
package/audio.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
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 'ringmod' */
|
|
12
|
+
export interface RingmodOptions {
|
|
13
|
+
/** 1..5000 Hz (default 440) */
|
|
14
|
+
"fc"?: Auto
|
|
15
|
+
/** 0..1 (default 1) */
|
|
16
|
+
"mix"?: Auto
|
|
17
|
+
at?: number | string
|
|
18
|
+
duration?: number | string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export declare const ringmod: {
|
|
22
|
+
(ctx: Ctx): Process
|
|
23
|
+
channels: "any"
|
|
24
|
+
params: {
|
|
25
|
+
/** 1..5000 Hz (default 440) */
|
|
26
|
+
"fc": { type: "number", default: 440 }
|
|
27
|
+
/** 0..1 (default 1) */
|
|
28
|
+
"mix": { type: "number", default: 1 }
|
|
29
|
+
}
|
|
30
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@audio/effect-ringmod",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"description": "Ring modulator — multiplies signal by a carrier oscillator",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -8,11 +8,16 @@
|
|
|
8
8
|
"exports": {
|
|
9
9
|
".": "./ring-mod.js",
|
|
10
10
|
"./package.json": "./package.json",
|
|
11
|
-
"./audio":
|
|
11
|
+
"./audio": {
|
|
12
|
+
"types": "./audio.d.ts",
|
|
13
|
+
"default": "./audio.js"
|
|
14
|
+
}
|
|
12
15
|
},
|
|
13
16
|
"files": [
|
|
14
17
|
"ring-mod.js",
|
|
15
|
-
"audio.js"
|
|
18
|
+
"audio.js",
|
|
19
|
+
"audio.d.ts",
|
|
20
|
+
"ring-mod.d.ts"
|
|
16
21
|
],
|
|
17
22
|
"keywords": [
|
|
18
23
|
"audio",
|
|
@@ -37,5 +42,7 @@
|
|
|
37
42
|
"publishConfig": {
|
|
38
43
|
"access": "public"
|
|
39
44
|
},
|
|
40
|
-
"
|
|
45
|
+
"types": "ring-mod.d.ts",
|
|
46
|
+
"audio": "./audio.js",
|
|
47
|
+
"funding": "https://github.com/sponsors/audiojs"
|
|
41
48
|
}
|
package/ring-mod.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Ring modulator — multiplies the signal by a carrier oscillator, produces sum and difference frequencies. */
|
|
2
|
+
export interface RingModOptions {
|
|
3
|
+
/** carrier frequency, Hz, default 440 */
|
|
4
|
+
fc?: number
|
|
5
|
+
/** wet/dry, 0–1, default 1 */
|
|
6
|
+
mix?: number
|
|
7
|
+
/** sample rate, default 44100 */
|
|
8
|
+
fs?: number
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Mutates `data` in place and returns the same reference. Pass the same params
|
|
13
|
+
* object across calls — the running carrier phase persists on it (`_phase`).
|
|
14
|
+
*/
|
|
15
|
+
export default function ringMod(data: Float32Array, params?: RingModOptions): Float32Array
|