You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Create synths, generate noise with Superpowered! Generator with sine wave, triangle, sawtooth, pulse wave (PWM), pink noise and white noise output. Synchronization of multiple generators, optional FM oscillator.
- AdvancedAudioPlayer and Decoder can understand both compressed and raw PCM AudioInMemory formats.
Copy file name to clipboardExpand all lines: docs.html
+97-10
Original file line number
Diff line number
Diff line change
@@ -1224,7 +1224,7 @@ <h3>Filter</h3>
1224
1224
<pre><codeclass="language-js">
1225
1225
// Constructor. Enabled is false by default.
1226
1226
let filter = new Superpowered.Filter(
1227
-
Superpowered.FilterType.Resonant_Lowpass, // The initial filter type.
1227
+
Superpowered.Filter.Resonant_Lowpass, // The initial filter type.
1228
1228
44100 // The initial sample rate in Hz.
1229
1229
);
1230
1230
@@ -1240,17 +1240,17 @@ <h3>Filter</h3>
1240
1240
filter.octave = 1; // Width in octave for bandlimited and parametric filters. Limit: 0.05 to 5.
1241
1241
filter.slope = 0.5; // Slope value for shelving filters. Limit: 0.001 to 1.
1242
1242
1243
-
filter.type = Superpowered.FilterType.Parametric; // Filter type. Changing the filter type often involves changing other parameters as well. Therefore in a real-time context change the parameters and the type in the same thread with the process() call.
1243
+
filter.type = Superpowered.Filter.Parametric; // Filter type. Changing the filter type often involves changing other parameters as well. Therefore in a real-time context change the parameters and the type in the same thread with the process() call.
1244
1244
1245
1245
// Superpowered filter types and their effective parameters:
// For advanced use. Set custom coefficients for the filter. Changes will be smoothly handled to prevent audio artifacts. Do not call this concurrently with process().
1256
1256
filter.setCustomCoefficients(
@@ -1558,6 +1558,93 @@ <h3>TimeStretching</h3>
1558
1558
ts.destruct();
1559
1559
</code></pre>
1560
1560
1561
+
<p>Using the time stretcher is more complex than using other effects, because it changes time and therefore buffering as well. It's fully integrated into the AdvancedAudioPlayer class, which is recommended for simple use. But if the time-stretcher has to be used alone, the logic could look like this:</p>
1562
+
1563
+
<pre><codeclass="language-js">
1564
+
while (ts.getOutputLengthFrames() <numberOfFramesNeeded){
// It's never blocking for real-time usage. You can change all properties on any thread, concurrently with this function.
1609
+
g.generate(
1610
+
output, // Pointer to floating point numbers. 32-bit MONO output.
1611
+
512 // Number of samples to produce.
1612
+
);
1613
+
1614
+
// Generates (outputs) audio for a frequency modulated (FM) oscillator.
1615
+
// It's never blocking for real-time usage. You can change all properties on any thread, concurrently with this function.
1616
+
g.generateFM(
1617
+
output, // Pointer to floating point numbers. 32-bit MONO output.
1618
+
512, // Number of samples to produce.
1619
+
fmsource, // Pointer to floating point numbers. Source for FM modulation containing numberOfSamples samples, usually from a previous call to generate().
1620
+
100 // Frequency modulation depth. 0 means no modulation, 1000 is a reasonable upper limit.
1621
+
);
1622
+
1623
+
// Generates audio for an oscillator that also serves as synchronization source for another oscillator.
1624
+
// It's never blocking for real-time usage. You can change all properties on any thread, concurrently with this function.
1625
+
g.generateAndCreateSync(
1626
+
output, // Pointer to floating point numbers. 32-bit MONO output.
1627
+
syncdata, // Pointer to a buffer to receive hard sync information for syncing oscillators. Should be numberOfSamples + 1 floats big minimum.
1628
+
512, // Number of samples to produce.
1629
+
);
1630
+
1631
+
// Generates audio for an oscillator that is hard-synced to another oscillator.
1632
+
// It's never blocking for real-time usage. You can change all properties on any thread, concurrently with this function.
1633
+
g.generateSynchronized(
1634
+
output, // Pointer to floating point numbers. 32-bit MONO output.
1635
+
syncdata, // Pointer to floating point numbers. Input sync data, previously produced by a call to generateAndCreateSync() with same numberOfSamples.
1636
+
512 // Number of samples to produce.
1637
+
);
1638
+
1639
+
// Start oscillator with given phase angle. In a synthesizer, this should be called whenever a voice starts.
1640
+
g.reset(
1641
+
0.5 // Start phase of the oscillator between 0.0 (0 degree) and 1.0 (180 degrees).
1642
+
);
1643
+
1644
+
// Destructor (to free up memory).
1645
+
g.destruct();
1646
+
</code></pre>
1647
+
1561
1648
<h2>Loading Audio</h2>
1562
1649
1563
1650
<p>Due to the nature of most JavaScript runtimes (such as no control over thread scheduling or no direct disk access), loading audio with Superpowered is a little bit different vs. native. <em>The entire audio file must be loaded into the WebAssembly Linear Memory memory</em> first, then the Superpowered Decoder can read and decode it.</p>
0 commit comments