cantor-digitalis 0.0.2 → 0.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 +62 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +390 -272
- package/dist/index.js.map +1 -1
- package/dist/nodes/anti-resonance.d.ts +6 -0
- package/dist/nodes/anti-resonance.d.ts.map +1 -1
- package/dist/nodes/formant-bank.d.ts +6 -0
- package/dist/nodes/formant-bank.d.ts.map +1 -1
- package/dist/nodes/formant-resonator.d.ts +6 -0
- package/dist/nodes/formant-resonator.d.ts.map +1 -1
- package/dist/nodes/gain.d.ts +6 -0
- package/dist/nodes/gain.d.ts.map +1 -1
- package/dist/nodes/glottal-flow-derivative.d.ts +7 -0
- package/dist/nodes/glottal-flow-derivative.d.ts.map +1 -1
- package/dist/nodes/glottal-formant.d.ts +6 -0
- package/dist/nodes/glottal-formant.d.ts.map +1 -1
- package/dist/nodes/noise-source.d.ts +7 -0
- package/dist/nodes/noise-source.d.ts.map +1 -1
- package/dist/nodes/pulse-train.d.ts +7 -0
- package/dist/nodes/pulse-train.d.ts.map +1 -1
- package/dist/nodes/spectral-tilt.d.ts +12 -0
- package/dist/nodes/spectral-tilt.d.ts.map +1 -1
- package/dist/nodes/types.d.ts +8 -0
- package/dist/nodes/types.d.ts.map +1 -1
- package/dist/nodes/vocal-tract.d.ts +6 -0
- package/dist/nodes/vocal-tract.d.ts.map +1 -1
- package/dist/nodes/voice.d.ts +6 -0
- package/dist/nodes/voice.d.ts.map +1 -1
- package/dist/nodes/worklet-utils.d.ts +18 -0
- package/dist/nodes/worklet-utils.d.ts.map +1 -0
- package/dist/parameters/index.d.ts +21 -5
- package/dist/parameters/index.d.ts.map +1 -1
- package/dist/parameters/vowels.d.ts +33 -5
- package/dist/parameters/vowels.d.ts.map +1 -1
- package/dist/utils/frequency-response.d.ts +58 -0
- package/dist/utils/frequency-response.d.ts.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -83,6 +83,48 @@ Additionally, the synthesizer exposes `AudioParam` objects for the synth-level p
|
|
|
83
83
|
| `vocalTractSize` | 0–1 | Vocal tract scaling (child to giant) |
|
|
84
84
|
| `isFalsetto` | bool | Laryngeal mechanism (M1/M2) |
|
|
85
85
|
|
|
86
|
+
### Custom Vowel Tables
|
|
87
|
+
|
|
88
|
+
You may notice that the synthesizer sings with a french accent. The default vowels are the French vowel sounds from the research paper. The frequency and bandwidths of the formants for each vowel can change the character of the produced sound significantly. You can provide a custom vowel table, mapping locations in vowel space to a set of formant frequencies, amplitudes, and bandwidths. You can source these from other research papers, or analyze the formant frequencies of recorded vowel sounds using tools like [Praat](https://www.fon.hum.uva.nl/praat/).
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
import { generateSynthParams, VowelTable, defaultVowelTable } from "cantor-digitalis";
|
|
92
|
+
|
|
93
|
+
// Create a custom vowel table
|
|
94
|
+
const customTable: VowelTable = {
|
|
95
|
+
vowels: [
|
|
96
|
+
{
|
|
97
|
+
ipa: "a",
|
|
98
|
+
h: 0.5, // backness: 0 = back, 1 = front
|
|
99
|
+
v: 1, // height: 0 = close, 1 = open
|
|
100
|
+
formants: [
|
|
101
|
+
{ frequency: 700, amplitude: 0, bandwidth: 100 },
|
|
102
|
+
{ frequency: 1200, amplitude: -3, bandwidth: 120 },
|
|
103
|
+
{ frequency: 2500, amplitude: -10, bandwidth: 150 },
|
|
104
|
+
{ frequency: 3500, amplitude: -15, bandwidth: 200 },
|
|
105
|
+
{ frequency: 4500, amplitude: -20, bandwidth: 250 },
|
|
106
|
+
{ frequency: 5500, amplitude: -25, bandwidth: 300 },
|
|
107
|
+
],
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
ipa: "i",
|
|
111
|
+
h: 1, v: 0,
|
|
112
|
+
formants: [/* ... */],
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
ipa: "u",
|
|
116
|
+
h: 0, v: 0,
|
|
117
|
+
formants: [/* ... */],
|
|
118
|
+
volumeAdjustment: -5, // optional: balance overall amplitude for this vowel
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
idwPower: 2, // optional: interpolation sharpness (default: 2)
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
// Use with generateSynthParams
|
|
125
|
+
const synthParams = generateSynthParams(params, { vowelTable: customTable });
|
|
126
|
+
```
|
|
127
|
+
|
|
86
128
|
### Synth Parameters
|
|
87
129
|
|
|
88
130
|
These low-level parameters directly control the audio processing and correspond to the physical/acoustic properties in the research paper.
|
|
@@ -159,6 +201,26 @@ formant.out.connect(ctx.destination);
|
|
|
159
201
|
pulseTrain.start();
|
|
160
202
|
```
|
|
161
203
|
|
|
204
|
+
## Frequency Response Analysis
|
|
205
|
+
|
|
206
|
+
All nodes provide `getFrequencyResponse(frequencies, sampleRate)` for computing magnitude response at specified frequencies, useful for visualisation and analysis.
|
|
207
|
+
|
|
208
|
+
```typescript
|
|
209
|
+
import { linearToDb } from "cantor-digitalis";
|
|
210
|
+
|
|
211
|
+
// Generate log-spaced frequencies from 20 Hz to 20 kHz
|
|
212
|
+
const frequencies = Array.from({ length: 500 }, (_, i) => 20 * Math.pow(1000, i / 499));
|
|
213
|
+
|
|
214
|
+
// Get response from the complete voice...
|
|
215
|
+
const voiceResponse = voice.getFrequencyResponse(frequencies, ctx.sampleRate);
|
|
216
|
+
// ...or individual components
|
|
217
|
+
const tractResponse = voice.tract.getFrequencyResponse(frequencies, ctx.sampleRate);
|
|
218
|
+
const f1Response = voice.tract.formants[0].getFrequencyResponse(frequencies, ctx.sampleRate);
|
|
219
|
+
|
|
220
|
+
// Convert to dB for plotting
|
|
221
|
+
const responseDb = linearToDb(voiceResponse);
|
|
222
|
+
```
|
|
223
|
+
|
|
162
224
|
## License
|
|
163
225
|
|
|
164
226
|
ISC
|
package/dist/index.d.ts
CHANGED
|
@@ -7,10 +7,9 @@
|
|
|
7
7
|
* @packageDocumentation
|
|
8
8
|
*/
|
|
9
9
|
export { Voice } from "./nodes/voice";
|
|
10
|
-
export { generateSynthParams } from "./parameters";
|
|
11
|
-
export type { PerceptualParams, SynthParams, SynthFormant, SynthFeatures } from "./parameters";
|
|
12
|
-
export { interpolateFormants
|
|
13
|
-
export type { Formant, VowelData } from "./parameters/vowels";
|
|
10
|
+
export { generateSynthParams, defaultVowelTable } from "./parameters";
|
|
11
|
+
export type { PerceptualParams, SynthParams, SynthFormant, SynthOptions, SynthFeatures, VowelTable, VowelData, Formant, } from "./parameters";
|
|
12
|
+
export { interpolateFormants } from "./parameters/vowels";
|
|
14
13
|
export type { Node } from "./nodes/types";
|
|
15
14
|
export { GlottalFlowDerivative } from "./nodes/glottal-flow-derivative";
|
|
16
15
|
export type { GlottalFlowDerivativeParams } from "./nodes/glottal-flow-derivative";
|
|
@@ -32,4 +31,5 @@ export { AntiResonance } from "./nodes/anti-resonance";
|
|
|
32
31
|
export type { AntiResonanceParams } from "./nodes/anti-resonance";
|
|
33
32
|
export { Gain } from "./nodes/gain";
|
|
34
33
|
export type { GainParams } from "./nodes/gain";
|
|
34
|
+
export { evaluateBiquad, evaluateFirstOrder, linearToDb, combineSeries, combineParallel, } from "./utils/frequency-response";
|
|
35
35
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAGtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAGtC,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE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