@audio/synth-osc 1.0.2 → 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.
- package/README.md +36 -0
- package/audio.d.ts +38 -0
- package/osc.d.ts +20 -0
- package/package.json +16 -4
package/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# @audio/synth-osc [](https://www.npmjs.com/package/@audio/synth-osc) [](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/audio.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
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 'osc' */
|
|
12
|
+
export interface OscOptions {
|
|
13
|
+
/** 20..20000 Hz (default 440) */
|
|
14
|
+
"freq"?: Auto
|
|
15
|
+
/** -1200..1200 cents (default 0) */
|
|
16
|
+
"detune"?: Auto
|
|
17
|
+
/** 0..1 (default 0.8) */
|
|
18
|
+
"gain"?: Auto
|
|
19
|
+
/** default "sine" */
|
|
20
|
+
"type"?: "sine" | "square" | "sawtooth" | "triangle"
|
|
21
|
+
at?: number | string
|
|
22
|
+
duration?: number | string
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export declare const osc: {
|
|
26
|
+
(ctx: Ctx): Process
|
|
27
|
+
channels: {"inputs":[],"outputs":1}
|
|
28
|
+
params: {
|
|
29
|
+
/** 20..20000 Hz (default 440) */
|
|
30
|
+
"freq": { type: "number", default: 440 }
|
|
31
|
+
/** -1200..1200 cents (default 0) */
|
|
32
|
+
"detune": { type: "number", default: 0 }
|
|
33
|
+
/** 0..1 (default 0.8) */
|
|
34
|
+
"gain": { type: "number", default: 0.8 }
|
|
35
|
+
/** default "sine" */
|
|
36
|
+
"type": { type: "enum", values: ["sine","square","sawtooth","triangle"], default: "sine" }
|
|
37
|
+
}
|
|
38
|
+
}
|
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
|
+
"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,
|
|
@@ -8,12 +8,18 @@
|
|
|
8
8
|
"exports": {
|
|
9
9
|
".": "./osc.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
|
"osc.js",
|
|
15
|
-
"
|
|
18
|
+
"osc.d.ts",
|
|
19
|
+
"audio.js",
|
|
20
|
+
"audio.d.ts"
|
|
16
21
|
],
|
|
22
|
+
"types": "osc.d.ts",
|
|
17
23
|
"dependencies": {
|
|
18
24
|
"periodic-function": "^2.1.0"
|
|
19
25
|
},
|
|
@@ -31,5 +37,11 @@
|
|
|
31
37
|
"publishConfig": {
|
|
32
38
|
"access": "public"
|
|
33
39
|
},
|
|
34
|
-
"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"
|
|
35
47
|
}
|