@audio/synth-osc 1.0.3 → 1.0.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.
Files changed (3) hide show
  1. package/README.md +36 -0
  2. package/osc.d.ts +20 -0
  3. package/package.json +10 -2
package/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # @audio/synth-osc [![npm](https://img.shields.io/npm/v/@audio/synth-osc)](https://www.npmjs.com/package/@audio/synth-osc) [![MIT](https://img.shields.io/badge/MIT-%E0%A5%90-white)](https://github.com/krishnized/license)
2
+
3
+ Oscillator — periodic-function waveforms (sine/square/saw/triangle), detune, custom wave fn
4
+
5
+ ```
6
+ npm install @audio/synth-osc
7
+ ```
8
+
9
+ ```js
10
+ import osc from '@audio/synth-osc'
11
+ ```
12
+
13
+ Classic waveform oscillator rendered from [`periodic-function`](https://www.npmjs.com/package/periodic-function), with cents detune and phase offset. Pitched — `(freq, opts)`, the family generator contract.
14
+
15
+ ```js
16
+ osc(440, { type: 'sawtooth', detune: -5 }) // → Float32Array
17
+ ```
18
+
19
+ | Param | Default | |
20
+ |---|---|---|
21
+ | `freq` | — | Hz (positional) |
22
+ | `duration` | `1` | Seconds |
23
+ | `type` | `'sine'` | `'sine'` \| `'square'` \| `'sawtooth'` \| `'triangle'` |
24
+ | `amp` | `0.8` | Peak amplitude |
25
+ | `detune` | `0` | Cents |
26
+ | `phase` | `0` | Starting phase, 0..1 |
27
+ | `wave` | — | Custom waveform fn `t => v`, overrides `type` |
28
+ | `fs` | `44100` | Sample rate |
29
+
30
+ **Use when:** the base oscillator under [`synth-voice`](https://github.com/audiojs/synth/tree/main/packages/synth-voice) and [`synth-poly`](https://github.com/audiojs/synth/tree/main/packages/synth-poly), or any test tone with a classic waveform.
31
+
32
+ ---
33
+
34
+ Part of [@audio/synth](https://github.com/audiojs/synth) — the synth family umbrella.
35
+
36
+ MIT © [audiojs](https://github.com/audiojs)
package/osc.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ /** Classic waveform oscillator (periodic-function), with detune + phase offset. */
2
+ export interface OscOptions {
3
+ /** seconds, default 1 */
4
+ duration?: number
5
+ /** sample rate, default 44100 */
6
+ fs?: number
7
+ /** default 'sine' */
8
+ type?: 'sine' | 'square' | 'sawtooth' | 'triangle'
9
+ /** peak amplitude, default 0.8 */
10
+ amp?: number
11
+ /** cents, default 0 */
12
+ detune?: number
13
+ /** starting phase 0..1, default 0 */
14
+ phase?: number
15
+ /** custom waveform fn, overrides type */
16
+ wave?: (t: number) => number
17
+ }
18
+
19
+ /** freq: Hz (positional) */
20
+ export default function osc(freq: number, options?: OscOptions): Float32Array
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@audio/synth-osc",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Oscillator — sine/square/sawtooth/triangle with detune (wraps periodic-function)",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -15,9 +15,11 @@
15
15
  },
16
16
  "files": [
17
17
  "osc.js",
18
+ "osc.d.ts",
18
19
  "audio.js",
19
20
  "audio.d.ts"
20
21
  ],
22
+ "types": "osc.d.ts",
21
23
  "dependencies": {
22
24
  "periodic-function": "^2.1.0"
23
25
  },
@@ -35,5 +37,11 @@
35
37
  "publishConfig": {
36
38
  "access": "public"
37
39
  },
38
- "audio": "./audio.js"
40
+ "audio": "./audio.js",
41
+ "repository": {
42
+ "type": "git",
43
+ "url": "git+https://github.com/audiojs/synth.git",
44
+ "directory": "packages/synth-osc"
45
+ },
46
+ "funding": "https://github.com/sponsors/audiojs"
39
47
  }