@audio/effect-ringmod 1.1.3 → 1.1.5

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 ADDED
@@ -0,0 +1,33 @@
1
+ # @audio/effect-ringmod [![npm](https://img.shields.io/npm/v/@audio/effect-ringmod)](https://www.npmjs.com/package/@audio/effect-ringmod) [![MIT](https://img.shields.io/badge/MIT-%E0%A5%90-white)](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-ringmod'
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
+ <!-- ![Ring mod](plot/ring-mod.svg) -->
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@audio/effect-ringmod",
3
- "version": "1.1.3",
3
+ "version": "1.1.5",
4
4
  "description": "Ring modulator — multiplies signal by a carrier oscillator",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -16,7 +16,8 @@
16
16
  "files": [
17
17
  "ring-mod.js",
18
18
  "audio.js",
19
- "audio.d.ts"
19
+ "audio.d.ts",
20
+ "ring-mod.d.ts"
20
21
  ],
21
22
  "keywords": [
22
23
  "audio",
@@ -41,5 +42,7 @@
41
42
  "publishConfig": {
42
43
  "access": "public"
43
44
  },
44
- "audio": "./audio.js"
45
+ "types": "ring-mod.d.ts",
46
+ "audio": "./audio.js",
47
+ "funding": "https://github.com/sponsors/audiojs"
45
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<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