cantor-digitalis 0.0.4 → 0.0.6

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 CHANGED
@@ -203,7 +203,11 @@ pulseTrain.start();
203
203
 
204
204
  ## Frequency Response Analysis
205
205
 
206
- All nodes provide `getFrequencyResponse(frequencies, sampleRate)` for computing magnitude response at specified frequencies, useful for visualisation and analysis.
206
+ All nodes provide methods for computing magnitude response at specified frequencies, useful for visualisation and analysis.
207
+
208
+ ### From Live Nodes
209
+
210
+ Use the member method to get the response based on current AudioParam values:
207
211
 
208
212
  ```typescript
209
213
  import { linearToDb } from "cantor-digitalis";
@@ -212,15 +216,43 @@ import { linearToDb } from "cantor-digitalis";
212
216
  const frequencies = Array.from({ length: 500 }, (_, i) => 20 * Math.pow(1000, i / 499));
213
217
 
214
218
  // Get response from the complete voice...
215
- const voiceResponse = voice.getFrequencyResponse(frequencies, ctx.sampleRate);
219
+ const voiceResponse = voice.getFrequencyResponse(frequencies);
216
220
  // ...or individual components
217
- const tractResponse = voice.tract.getFrequencyResponse(frequencies, ctx.sampleRate);
218
- const f1Response = voice.tract.formants[0].getFrequencyResponse(frequencies, ctx.sampleRate);
221
+ const tractResponse = voice.tract.getFrequencyResponse(frequencies);
222
+ const f1Response = voice.tract.formants[0].getFrequencyResponse(frequencies);
219
223
 
220
224
  // Convert to dB for plotting
221
225
  const responseDb = linearToDb(voiceResponse);
222
226
  ```
223
227
 
228
+ ### Without AudioContext (Static Method)
229
+
230
+ Use the static method to compute frequency response from explicit parameters, without needing an AudioContext. This is useful for server-side rendering, web workers, or precomputing response curves before audio initialisation.
231
+
232
+ ```typescript
233
+ import { Voice, generateSynthParams, linearToDb } from "cantor-digitalis";
234
+
235
+ const frequencies = Array.from({ length: 500 }, (_, i) => 20 * Math.pow(1000, i / 499));
236
+
237
+ // Generate synth params
238
+ const synthParams = generateSynthParams({
239
+ pitch: 0.5,
240
+ pitchOffset: 60,
241
+ vocalEffort: 0.7,
242
+ vowelHeight: 0.5,
243
+ vowelBackness: 0.5,
244
+ tenseness: 0.5,
245
+ breathiness: 0.02,
246
+ roughness: 0.01,
247
+ vocalTractSize: 0.3,
248
+ isFalsetto: false,
249
+ });
250
+
251
+ // Compute response without any AudioContext
252
+ const response = Voice.getFrequencyResponse(frequencies, synthParams);
253
+ const responseDb = linearToDb(response);
254
+ ```
255
+
224
256
  ## License
225
257
 
226
258
  ISC