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
// Runs after the constructor. This is "your" constructor basically.
194
197
}
198
+
onDestruct() {
199
+
// Runs before the node is destroyed.
200
+
// Clean up memory and objects here (such as free allocated linear memory or destruct Superpowered objects).
201
+
}
195
202
onMessageFromMainScope(message) {
196
203
// Runs when a message (data) is received from the main scope (main thread).
197
204
@@ -1145,11 +1152,62 @@ <h3>Compressor</h3>
1145
1152
// It's never blocking for real-time usage. You can change all properties and call getGainReductionDb() on any thread, concurrently with process().
1146
1153
// If process() returns with true, the contents of output are replaced with the audio output. If process() returns with false, the contents of output are not changed.
1147
1154
let changedOutput = compressor.process(
1148
-
input // Pointer to floating point numbers. 32-bit interleaved stereo input.
1155
+
input, // Pointer to floating point numbers. 32-bit interleaved stereo input.
1156
+
output, // Pointer to floating point numbers. 32-bit interleaved stereo output. Can point to the same location with input (in-place processing).
1157
+
128 // Number of frames to process. Recommendations for best performance: multiply of 4, minimum 64.
1158
+
);
1159
+
1160
+
// Destructor (to free up memory).
1161
+
compressor.destruct();
1162
+
</code></pre>
1163
+
1164
+
<h3>Compressor2</h3>
1165
+
1166
+
<p>Compressor with 0 latency, adjustable knee and optional sidechain input. It doesn't allocate any internal buffers and needs less than 1 kb of memory.</p>
1167
+
1168
+
<pre><codeclass="language-js">
1169
+
// Constructor. Enabled is false by default.
1170
+
let compressor = new Superpowered.Compressor2(
1171
+
44100 // The initial sample rate in Hz.
1172
+
);
1173
+
1174
+
// Do this when the sample rate changes.
1175
+
compressor.samplerate = 48000;
1176
+
1177
+
// Turns the effect on/off. False by default. The actual switch will happen on the next process() call for smooth, audio-artifact free operation.
1178
+
compressor.enabled = true;
1179
+
1180
+
compressor.attackSec = 0.01; // Attack in seconds (not milliseconds!). Limited between 0.00001 and 10. Default: 0.05 (50 ms).
1181
+
compressor.holdSec = 0; // Hold segment before release starts, useful to limit unwanted noise with fast rates. 0 to 1 second (not millisecond). Default: 0.005 (5 ms).
1182
+
compressor.releaseSec = 0.2; // Release in seconds (not milliseconds!). Limited between 0.00001 and 10. Default: 0.05 (50 ms).
1183
+
compressor.ratio = 5; // Ratio, 1 to 1000. Default: 4.
1184
+
compressor.thresholdDb = -16; // Threshold in decibels, limited between 0 and -60. Default: -6.
1185
+
compressor.softKneeDb = 3 // Width of soft knee in decibels, 0 to 12. Default: 6.
1186
+
compressor.outputGainDb = 3; // Output gain in decibels, limited between -24 and 24. Default: 0.
1187
+
compressor.automaticGain = false; // If true, gain is set relative to compressor output at 0dB. Useful in digital environments. Default: true.
1188
+
1189
+
// Returns the maximum gain reduction in decibels since the last getGainReductionDb() call.
1190
+
let gain_reduction_db = compressor.getGainReductionDb();
1191
+
1192
+
// Processes the audio. Always call it in the audio processing callback, regardless if the effect is enabled or not for smooth, audio-artifact free operation.
1193
+
// It's never blocking for real-time usage. You can change all properties and call getGainReductionDb() on any thread, concurrently with process().
1194
+
// If process() returns with true, the contents of output are replaced with the audio output. If process() returns with false, the contents of output are not changed.
1195
+
let changedOutput = compressor.process(
1196
+
input, // Pointer to floating point numbers. 32-bit interleaved stereo input.
1149
1197
output, // Pointer to floating point numbers. 32-bit interleaved stereo output. Can point to the same location with input (in-place processing).
1150
1198
128 // Number of frames to process. Recommendations for best performance: multiply of 4, minimum 64.
1151
1199
);
1152
1200
1201
+
// Processes the audio. Always call it in the audio processing callback, regardless if the effect is enabled or not for smooth, audio-artifact free operation.
1202
+
// It's never blocking for real-time usage. You can change all properties and call getGainReductionDb() on any thread, concurrently with process().
1203
+
// If process() returns with true, the contents of output are replaced with the audio output. If process() returns with false, the contents of output are not changed.
1204
+
let changedOutput = compressor.processWithSidechain(
1205
+
input, // Pointer to floating point numbers. 32-bit interleaved stereo input.
1206
+
sidechain, // Pointer to floating point numbers. 32-bit interleaved stereo sidechain input.
1207
+
output, // Pointer to floating point numbers. 32-bit interleaved stereo output. Can point to the same location with input (in-place processing).
1208
+
128 // Number of frames to process. Recommendations for best performance: multiply of 4, minimum 64.
0 commit comments