sfxmix 1.0.2 → 1.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 +187 -75
- package/index.js +77 -12
- package/package.json +9 -1
package/README.md
CHANGED
|
@@ -44,21 +44,21 @@ npm install sfxmix
|
|
|
44
44
|
```javascript
|
|
45
45
|
const SfxMix = require('sfxmix');
|
|
46
46
|
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
47
|
+
const sfx = new SfxMix();
|
|
48
|
+
|
|
49
|
+
sfx
|
|
50
|
+
.add('intro.mp3')
|
|
51
|
+
.silence(2000) // 2 seconds of silence
|
|
52
|
+
.add('main.mp3')
|
|
53
|
+
.filter('normalize', { i: -14, tp: -2.0, lra: 7.0 })
|
|
54
|
+
.mix('background.mp3', { duration: 'first' })
|
|
55
|
+
.save('final_output.mp3')
|
|
56
|
+
.then(() => {
|
|
57
|
+
console.log('Audio exported to final_output.mp3 🎉');
|
|
58
|
+
})
|
|
59
|
+
.catch((err) => {
|
|
60
|
+
console.error('Error during audio processing:', err);
|
|
61
|
+
});
|
|
62
62
|
```
|
|
63
63
|
---
|
|
64
64
|
|
|
@@ -67,53 +67,53 @@ processor
|
|
|
67
67
|
### 1. Concatenate and Mix with Background Music
|
|
68
68
|
|
|
69
69
|
```javascript
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
70
|
+
sfx
|
|
71
|
+
.add('intro.mp3')
|
|
72
|
+
.add('chapter1.mp3')
|
|
73
|
+
.add('chapter2.mp3')
|
|
74
|
+
.mix('background_music.mp3', { duration: 'first' })
|
|
75
|
+
.save('audiobook_with_music.mp3');
|
|
76
76
|
```
|
|
77
77
|
|
|
78
78
|
### 2. Apply Multiple Filters
|
|
79
79
|
|
|
80
80
|
```javascript
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
81
|
+
sfx
|
|
82
|
+
.add('voiceover.mp3')
|
|
83
|
+
.filter('normalize', { i: -14 })
|
|
84
|
+
.filter('equalizer', { frequency: 3000, width: 1000, gain: 5 })
|
|
85
|
+
.save('processed_voiceover.mp3');
|
|
86
86
|
```
|
|
87
87
|
|
|
88
88
|
### 3. Insert Silence Between Tracks
|
|
89
89
|
|
|
90
90
|
```javascript
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
91
|
+
sfx
|
|
92
|
+
.add('track1.mp3')
|
|
93
|
+
.silence(2000)
|
|
94
|
+
.add('track2.mp3')
|
|
95
|
+
.silence(2000)
|
|
96
|
+
.add('track3.mp3')
|
|
97
|
+
.save('album_with_silence.mp3');
|
|
98
98
|
```
|
|
99
99
|
|
|
100
100
|
### 4. Apply Telephone Effect
|
|
101
101
|
|
|
102
102
|
```javascript
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
103
|
+
sfx
|
|
104
|
+
.add('dialogue.mp3')
|
|
105
|
+
.filter('telephone')
|
|
106
|
+
.save('telephone_effect.mp3');
|
|
107
107
|
```
|
|
108
108
|
|
|
109
109
|
### 5. Adjust Volume and Add Echo
|
|
110
110
|
|
|
111
111
|
```javascript
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
112
|
+
sfx
|
|
113
|
+
.add('announcement.mp3')
|
|
114
|
+
.filter('volume', { volume: 1.5 })
|
|
115
|
+
.filter('echo', { delay: 750, decay: 0.7 })
|
|
116
|
+
.save('enhanced_announcement.mp3');
|
|
117
117
|
```
|
|
118
118
|
|
|
119
119
|
---
|
|
@@ -134,7 +134,7 @@ processor
|
|
|
134
134
|
|
|
135
135
|
### `add(input)`
|
|
136
136
|
|
|
137
|
-
Adds an audio file to the
|
|
137
|
+
Adds an audio file to the sfx for concatenation.
|
|
138
138
|
|
|
139
139
|
- **Parameters:**
|
|
140
140
|
- `input` (string): Path to the audio file.
|
|
@@ -143,7 +143,7 @@ Adds an audio file to the processor for concatenation.
|
|
|
143
143
|
**Example:**
|
|
144
144
|
|
|
145
145
|
```javascript
|
|
146
|
-
|
|
146
|
+
sfx.add('part1.mp3').add('part2.mp3');
|
|
147
147
|
```
|
|
148
148
|
|
|
149
149
|
---
|
|
@@ -161,7 +161,7 @@ Mixes an audio file with the current audio.
|
|
|
161
161
|
**Example:**
|
|
162
162
|
|
|
163
163
|
```javascript
|
|
164
|
-
|
|
164
|
+
sfx.mix('sound_effect.wav', { duration: 'first' });
|
|
165
165
|
```
|
|
166
166
|
|
|
167
167
|
---
|
|
@@ -177,7 +177,7 @@ Inserts silence into the audio sequence.
|
|
|
177
177
|
**Example:**
|
|
178
178
|
|
|
179
179
|
```javascript
|
|
180
|
-
|
|
180
|
+
sfx.silence(3000); // Inserts 3 seconds of silence
|
|
181
181
|
```
|
|
182
182
|
|
|
183
183
|
---
|
|
@@ -193,14 +193,19 @@ Applies an audio filter to the current audio.
|
|
|
193
193
|
|
|
194
194
|
**Supported Filters:**
|
|
195
195
|
|
|
196
|
-
- [`normalize`](#
|
|
197
|
-
- [`telephone`](#
|
|
198
|
-
- [`echo`](#
|
|
199
|
-
- [`reverb`](#
|
|
200
|
-
- [`highpass`](#
|
|
201
|
-
- [`lowpass`](#
|
|
202
|
-
- [`volume`](#
|
|
203
|
-
- [`equalizer`](#
|
|
196
|
+
- [`normalize`](#filter-normalize)
|
|
197
|
+
- [`telephone`](#filter-telephone)
|
|
198
|
+
- [`echo`](#filter-echo)
|
|
199
|
+
- [`reverb`](#filter-reverb)
|
|
200
|
+
- [`highpass`](#filter-highpass)
|
|
201
|
+
- [`lowpass`](#filter-lowpass)
|
|
202
|
+
- [`volume`](#filter-volume)
|
|
203
|
+
- [`equalizer`](#filter-equalizer)
|
|
204
|
+
- [`compressor`](#filter-compressor)
|
|
205
|
+
- [`flanger`](#filter-flanger)
|
|
206
|
+
- [`pitch`](#filter-pitch)
|
|
207
|
+
- [`tremolo`](#filter-tremolo)
|
|
208
|
+
- [`phaser`](#filter-phaser)
|
|
204
209
|
|
|
205
210
|
---
|
|
206
211
|
|
|
@@ -215,7 +220,7 @@ Processes the audio according to the specified actions and saves the result.
|
|
|
215
220
|
**Example:**
|
|
216
221
|
|
|
217
222
|
```javascript
|
|
218
|
-
|
|
223
|
+
sfx.save('output.mp3');
|
|
219
224
|
```
|
|
220
225
|
|
|
221
226
|
---
|
|
@@ -227,14 +232,14 @@ processor.save('output.mp3');
|
|
|
227
232
|
Normalizes audio loudness to a specified target using the EBU R128 standard.
|
|
228
233
|
|
|
229
234
|
- **Options:**
|
|
230
|
-
- `tp` (number): Maximum true peak level in dBTP (default: `-
|
|
235
|
+
- `tp` (number): Maximum true peak level in dBTP (default: `-3`).
|
|
231
236
|
- `i` (number): Target integrated loudness in LUFS (default: `-16`).
|
|
232
237
|
- `lra` (number): Loudness range in LU (default: `11`).
|
|
233
238
|
|
|
234
239
|
**Example:**
|
|
235
240
|
|
|
236
241
|
```javascript
|
|
237
|
-
|
|
242
|
+
sfx.filter('normalize', { i: -14, tp: -2.0, lra: 7.0 });
|
|
238
243
|
```
|
|
239
244
|
|
|
240
245
|
---
|
|
@@ -245,12 +250,12 @@ Applies a telephone effect by applying high-pass and low-pass filters.
|
|
|
245
250
|
|
|
246
251
|
- **Options:**
|
|
247
252
|
- `lowFreq` (number): High-pass filter cutoff frequency in Hz (default: `300`).
|
|
248
|
-
- `highFreq` (number): Low-pass filter cutoff frequency in Hz (default: `
|
|
253
|
+
- `highFreq` (number): Low-pass filter cutoff frequency in Hz (default: `3000`).
|
|
249
254
|
|
|
250
255
|
**Example:**
|
|
251
256
|
|
|
252
257
|
```javascript
|
|
253
|
-
|
|
258
|
+
sfx.filter('telephone', { lowFreq: 400, highFreq: 3000 });
|
|
254
259
|
```
|
|
255
260
|
|
|
256
261
|
---
|
|
@@ -266,7 +271,7 @@ Adds an echo effect to the audio.
|
|
|
266
271
|
**Example:**
|
|
267
272
|
|
|
268
273
|
```javascript
|
|
269
|
-
|
|
274
|
+
sfx.filter('echo', { delay: 1000, decay: 0.6 });
|
|
270
275
|
```
|
|
271
276
|
|
|
272
277
|
---
|
|
@@ -275,12 +280,20 @@ processor.filter('echo', { delay: 1000, decay: 0.6 });
|
|
|
275
280
|
|
|
276
281
|
Applies a reverb effect to the audio.
|
|
277
282
|
|
|
278
|
-
- **Options:**
|
|
283
|
+
- **Options:**
|
|
284
|
+
- `room_size` (number): Size of the room (default: `50`).
|
|
285
|
+
- `reverberance` (number): Amount of reverberation (default: `50`).
|
|
286
|
+
- `damping` (number): Damping factor (default: `50`).
|
|
287
|
+
- `hf_damping` (number): High-frequency damping (default: `50`).
|
|
288
|
+
- `stereo_depth` (number): Stereo depth (default: `0`).
|
|
289
|
+
- `pre_delay` (number): Pre-delay time in milliseconds (default: `0`).
|
|
290
|
+
- `wet_gain` (number): Gain of the wet signal (default: `0`).
|
|
291
|
+
- `wet_only` (number): If set to `1`, only the wet signal is output (default: `0`).
|
|
279
292
|
|
|
280
293
|
**Example:**
|
|
281
294
|
|
|
282
295
|
```javascript
|
|
283
|
-
|
|
296
|
+
sfx.filter('reverb');
|
|
284
297
|
```
|
|
285
298
|
|
|
286
299
|
---
|
|
@@ -295,7 +308,7 @@ Applies a high-pass filter to remove frequencies below the cutoff.
|
|
|
295
308
|
**Example:**
|
|
296
309
|
|
|
297
310
|
```javascript
|
|
298
|
-
|
|
311
|
+
sfx.filter('highpass', { frequency: 1000 });
|
|
299
312
|
```
|
|
300
313
|
|
|
301
314
|
---
|
|
@@ -310,7 +323,7 @@ Applies a low-pass filter to remove frequencies above the cutoff.
|
|
|
310
323
|
**Example:**
|
|
311
324
|
|
|
312
325
|
```javascript
|
|
313
|
-
|
|
326
|
+
sfx.filter('lowpass', { frequency: 2000 });
|
|
314
327
|
```
|
|
315
328
|
|
|
316
329
|
---
|
|
@@ -325,7 +338,7 @@ Adjusts the audio volume.
|
|
|
325
338
|
**Example:**
|
|
326
339
|
|
|
327
340
|
```javascript
|
|
328
|
-
|
|
341
|
+
sfx.filter('volume', { volume: 0.8 });
|
|
329
342
|
```
|
|
330
343
|
|
|
331
344
|
---
|
|
@@ -342,29 +355,108 @@ Applies an equalizer effect to adjust specific frequencies.
|
|
|
342
355
|
**Example:**
|
|
343
356
|
|
|
344
357
|
```javascript
|
|
345
|
-
|
|
358
|
+
sfx.filter('equalizer', { frequency: 1000, width: 200, gain: -10 });
|
|
346
359
|
```
|
|
347
360
|
|
|
348
361
|
---
|
|
349
362
|
|
|
350
|
-
|
|
363
|
+
### Filter: `compressor`
|
|
351
364
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
- **
|
|
355
|
-
-
|
|
365
|
+
Applies a dynamic range compressor to the audio.
|
|
366
|
+
|
|
367
|
+
- **Options:**
|
|
368
|
+
- `threshold` (number): Threshold level in dB (default: `-18`).
|
|
369
|
+
- `ratio` (number): Compression ratio (default: `2`).
|
|
370
|
+
- `attack` (number): Attack time in milliseconds (default: `20`).
|
|
371
|
+
- `release` (number): Release time in milliseconds (default: `250`).
|
|
372
|
+
|
|
373
|
+
**Example:**
|
|
374
|
+
|
|
375
|
+
```javascript
|
|
376
|
+
sfx.filter('compressor', { threshold: -20, ratio: 4, attack: 15, release: 300 });
|
|
377
|
+
```
|
|
356
378
|
|
|
357
379
|
---
|
|
358
380
|
|
|
359
|
-
|
|
381
|
+
### Filter: `flanger`
|
|
382
|
+
|
|
383
|
+
Applies a flanger effect to the audio.
|
|
384
|
+
|
|
385
|
+
- **Options:**
|
|
386
|
+
- `delay` (number): Base delay in milliseconds (default: `0`).
|
|
387
|
+
- `depth` (number): Oscillation depth (default: `2`).
|
|
388
|
+
- `regen` (number): Regeneration (feedback) (default: `0`).
|
|
389
|
+
- `width` (number): Percentage of delayed signal mixed (default: `71`).
|
|
390
|
+
- `speed` (number): Oscillation speed in Hz (default: `0.5`).
|
|
391
|
+
- `shape` (string): Oscillator wave shape (`'sine'` or `'triangular'`) (default: `'sine'`).
|
|
392
|
+
- `phase` (number): Percentage of offset for second delayed signal (default: `25`).
|
|
393
|
+
- `interp` (string): Delay line interpolation (`'linear'` or `'quadratic'`) (default: `'linear'`).
|
|
394
|
+
|
|
395
|
+
**Example:**
|
|
396
|
+
|
|
397
|
+
```javascript
|
|
398
|
+
sfx.filter('flanger', { delay: 5, depth: 3, speed: 0.8 });
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
---
|
|
402
|
+
|
|
403
|
+
### Filter: `pitch`
|
|
404
|
+
|
|
405
|
+
Shifts the pitch of the audio.
|
|
406
|
+
|
|
407
|
+
- **Options:**
|
|
408
|
+
- `pitch` (number): Pitch shift in semitones (positive or negative).
|
|
409
|
+
|
|
410
|
+
**Example:**
|
|
411
|
+
|
|
412
|
+
```javascript
|
|
413
|
+
sfx.filter('pitch', { pitch: 2 }); // Shift pitch up by 2 semitones
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
---
|
|
417
|
+
|
|
418
|
+
### Filter: `tremolo`
|
|
360
419
|
|
|
361
|
-
|
|
420
|
+
Applies a tremolo effect to the audio.
|
|
421
|
+
|
|
422
|
+
- **Options:**
|
|
423
|
+
- `speed` (number): Modulation frequency in Hz (default: `5`).
|
|
424
|
+
- `depth` (number): Modulation depth (0-1) (default: `0.5`).
|
|
425
|
+
|
|
426
|
+
**Example:**
|
|
427
|
+
|
|
428
|
+
```javascript
|
|
429
|
+
sfx.filter('tremolo', { speed: 6, depth: 0.7 });
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
---
|
|
433
|
+
|
|
434
|
+
### Filter: `phaser`
|
|
435
|
+
|
|
436
|
+
Applies a phaser effect to the audio.
|
|
437
|
+
|
|
438
|
+
- **Options:**
|
|
439
|
+
- `in_gain` (number): Input gain (default: `0.4`).
|
|
440
|
+
- `out_gain` (number): Output gain (default: `0.74`).
|
|
441
|
+
- `delay` (number): Delay in milliseconds (default: `3`).
|
|
442
|
+
- `decay` (number): Decay (default: `0.4`).
|
|
443
|
+
- `speed` (number): Modulation speed in Hz (default: `0.5`).
|
|
444
|
+
- `type` (number): Modulation type (0-1) (default: `0`).
|
|
445
|
+
|
|
446
|
+
**Example:**
|
|
447
|
+
|
|
448
|
+
```javascript
|
|
449
|
+
sfx.filter('phaser', { delay: 4, decay: 0.5, speed: 0.8 });
|
|
450
|
+
```
|
|
362
451
|
|
|
363
452
|
---
|
|
364
453
|
|
|
365
|
-
##
|
|
454
|
+
## ⚠️ Important Notes
|
|
366
455
|
|
|
367
|
-
|
|
456
|
+
- **FFmpeg Installation:** Ensure FFmpeg is installed and accessible in your system's PATH.
|
|
457
|
+
- **File Permissions:** The module creates and deletes temporary files during processing. Ensure the application has the necessary permissions.
|
|
458
|
+
- **Audio Formats:** The module assumes input files are in MP3 format. For other formats, adjust codec and format settings accordingly.
|
|
459
|
+
- **Error Handling:** Always handle rejections from the `save()` method to catch any processing errors.
|
|
368
460
|
|
|
369
461
|
---
|
|
370
462
|
|
|
@@ -388,4 +480,24 @@ If you encounter any issues or have questions, please open an issue on the [GitH
|
|
|
388
480
|
|
|
389
481
|
---
|
|
390
482
|
|
|
483
|
+
## 🤝 Contributing
|
|
484
|
+
|
|
485
|
+
Contributions are welcome! If you find any issues or have suggestions for improvement, please open an issue or submit a pull request on the [GitHub repository](https://github.com/clasen/ModelMix).
|
|
486
|
+
|
|
487
|
+
---
|
|
488
|
+
|
|
489
|
+
## 📄 License
|
|
490
|
+
|
|
491
|
+
The MIT License (MIT)
|
|
492
|
+
|
|
493
|
+
Copyright (c) Martin Clasen
|
|
494
|
+
|
|
495
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
496
|
+
|
|
497
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
498
|
+
|
|
499
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
500
|
+
|
|
501
|
+
---
|
|
502
|
+
|
|
391
503
|
Enjoy processing your audio with **SfxMix**! 🎶✨
|
package/index.js
CHANGED
|
@@ -209,55 +209,120 @@ function getFilterChain(filterName, options) {
|
|
|
209
209
|
switch (filterName) {
|
|
210
210
|
case 'normalize':
|
|
211
211
|
// Normalize audio using loudnorm filter with parameters
|
|
212
|
-
|
|
212
|
+
const tp = options.tp || -3;
|
|
213
213
|
const i = options.i || -16;
|
|
214
|
-
const tp = options.tp || -1.5;
|
|
215
214
|
const lra = options.lra || 11;
|
|
216
215
|
return `loudnorm=I=${i}:TP=${tp}:LRA=${lra}:print_format=none`;
|
|
216
|
+
|
|
217
217
|
case 'telephone':
|
|
218
218
|
// Telephone effect with parameters
|
|
219
|
-
// Options: lowFreq (default 300), highFreq (default 3400)
|
|
220
219
|
const lowFreq = options.lowFreq || 300;
|
|
221
|
-
const highFreq = options.highFreq ||
|
|
220
|
+
const highFreq = options.highFreq || 3000;
|
|
222
221
|
return `highpass=f=${lowFreq}, lowpass=f=${highFreq}`;
|
|
222
|
+
|
|
223
223
|
case 'echo':
|
|
224
|
-
//
|
|
224
|
+
// Echo effect with parameters
|
|
225
225
|
const echoDelay = options.delay || 500;
|
|
226
226
|
const echoDecay = options.decay || 0.5;
|
|
227
227
|
return `aecho=0.8:0.88:${echoDelay}:${echoDecay}`;
|
|
228
|
+
|
|
228
229
|
case 'reverb':
|
|
229
|
-
//
|
|
230
|
-
|
|
230
|
+
// Reverb effect with parameters
|
|
231
|
+
// Options: room_size, reverberance, damping, hf_damping, stereo_depth, pre_delay, wet_gain, wet_only
|
|
232
|
+
const room_size = options.room_size !== undefined ? options.room_size : 50;
|
|
233
|
+
const reverberance = options.reverberance !== undefined ? options.reverberance : 50;
|
|
234
|
+
const damping = options.damping !== undefined ? options.damping : 50;
|
|
235
|
+
const hf_damping = options.hf_damping !== undefined ? options.hf_damping : 50;
|
|
236
|
+
const stereo_depth = options.stereo_depth !== undefined ? options.stereo_depth : 0;
|
|
237
|
+
const pre_delay = options.pre_delay !== undefined ? options.pre_delay : 0;
|
|
238
|
+
const wet_gain = options.wet_gain !== undefined ? options.wet_gain : 0;
|
|
239
|
+
const wet_only = options.wet_only !== undefined ? options.wet_only : 0;
|
|
240
|
+
return `areverb=room_size=${room_size}:reverberance=${reverberance}:damping=${damping}:hf_damping=${hf_damping}:stereo_depth=${stereo_depth}:pre_delay=${pre_delay}:wet_gain=${wet_gain}:wet_only=${wet_only}`;
|
|
241
|
+
|
|
231
242
|
case 'highpass':
|
|
232
|
-
// High-pass filter
|
|
243
|
+
// High-pass filter
|
|
233
244
|
if (options.frequency) {
|
|
234
245
|
return `highpass=f=${options.frequency}`;
|
|
235
246
|
} else {
|
|
236
247
|
throw new Error('High-pass filter requires "frequency" option.');
|
|
237
248
|
}
|
|
249
|
+
|
|
238
250
|
case 'lowpass':
|
|
239
|
-
// Low-pass filter
|
|
251
|
+
// Low-pass filter
|
|
240
252
|
if (options.frequency) {
|
|
241
253
|
return `lowpass=f=${options.frequency}`;
|
|
242
254
|
} else {
|
|
243
255
|
throw new Error('Low-pass filter requires "frequency" option.');
|
|
244
256
|
}
|
|
257
|
+
|
|
245
258
|
case 'volume':
|
|
246
|
-
// Volume adjustment
|
|
259
|
+
// Volume adjustment
|
|
247
260
|
if (options.volume !== undefined) {
|
|
248
261
|
return `volume=${options.volume}`;
|
|
249
262
|
} else {
|
|
250
263
|
throw new Error('Volume filter requires "volume" option.');
|
|
251
264
|
}
|
|
265
|
+
|
|
252
266
|
case 'equalizer':
|
|
253
|
-
// Equalizer filter
|
|
267
|
+
// Equalizer filter
|
|
254
268
|
if (options.frequency && options.width && options.gain !== undefined) {
|
|
255
269
|
return `equalizer=f=${options.frequency}:width_type=h:width=${options.width}:g=${options.gain}`;
|
|
256
270
|
} else {
|
|
257
271
|
throw new Error('Equalizer filter requires "frequency", "width", and "gain" options.');
|
|
258
272
|
}
|
|
273
|
+
|
|
274
|
+
case 'compressor':
|
|
275
|
+
// Compressor effect
|
|
276
|
+
// Options: threshold, ratio, attack, release
|
|
277
|
+
const threshold = options.threshold !== undefined ? options.threshold : -18;
|
|
278
|
+
const ratio = options.ratio !== undefined ? options.ratio : 2;
|
|
279
|
+
const attack = options.attack !== undefined ? options.attack : 20;
|
|
280
|
+
const release = options.release !== undefined ? options.release : 250;
|
|
281
|
+
return `acompressor=threshold=${threshold}:ratio=${ratio}:attack=${attack}:release=${release}`;
|
|
282
|
+
|
|
283
|
+
case 'flanger':
|
|
284
|
+
// Flanger effect
|
|
285
|
+
// Options: delay, depth, regen, width, speed, shape, phase, interp
|
|
286
|
+
const flangerDelay = options.delay !== undefined ? options.delay : 0;
|
|
287
|
+
const depth = options.depth !== undefined ? options.depth : 2;
|
|
288
|
+
const regen = options.regen !== undefined ? options.regen : 0;
|
|
289
|
+
const width = options.width !== undefined ? options.width : 71;
|
|
290
|
+
const speed = options.speed !== undefined ? options.speed : 0.5;
|
|
291
|
+
const shape = options.shape !== undefined ? options.shape : 'sine';
|
|
292
|
+
const phase = options.phase !== undefined ? options.phase : 25;
|
|
293
|
+
const interp = options.interp !== undefined ? options.interp : 'linear';
|
|
294
|
+
return `flanger=delay=${flangerDelay}:depth=${depth}:regen=${regen}:width=${width}:speed=${speed}:shape=${shape}:phase=${phase}:interp=${interp}`;
|
|
295
|
+
|
|
296
|
+
case 'pitch':
|
|
297
|
+
// Pitch shift effect
|
|
298
|
+
// Options: pitch (in semitones)
|
|
299
|
+
if (options.pitch !== undefined) {
|
|
300
|
+
const pitch = options.pitch;
|
|
301
|
+
return `asetrate=44100*${Math.pow(2, pitch / 12)},aresample=44100`;
|
|
302
|
+
} else {
|
|
303
|
+
throw new Error('Pitch filter requires "pitch" option.');
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
case 'tremolo':
|
|
307
|
+
// Tremolo effect
|
|
308
|
+
// Options: speed, depth
|
|
309
|
+
const tremoloSpeed = options.speed !== undefined ? options.speed : 5;
|
|
310
|
+
const tremoloDepth = options.depth !== undefined ? options.depth : 0.5;
|
|
311
|
+
return `tremolo=f=${tremoloSpeed}:d=${tremoloDepth}`;
|
|
312
|
+
|
|
313
|
+
case 'phaser':
|
|
314
|
+
// Phaser effect
|
|
315
|
+
// Options: in_gain, out_gain, delay, decay, speed, type
|
|
316
|
+
const in_gain = options.in_gain !== undefined ? options.in_gain : 0.4;
|
|
317
|
+
const out_gain = options.out_gain !== undefined ? options.out_gain : 0.74;
|
|
318
|
+
const delay = options.delay !== undefined ? options.delay : 3;
|
|
319
|
+
const decay = options.decay !== undefined ? options.decay : 0.4;
|
|
320
|
+
const speed_ph = options.speed !== undefined ? options.speed : 0.5;
|
|
321
|
+
const type = options.type !== undefined ? options.type : 0;
|
|
322
|
+
return `aphaser=in_gain=${in_gain}:out_gain=${out_gain}:delay=${delay}:decay=${decay}:speed=${speed_ph}:type=${type}`;
|
|
323
|
+
|
|
259
324
|
default:
|
|
260
|
-
|
|
325
|
+
throw new Error(`Unknown filter: ${filterName}`);
|
|
261
326
|
}
|
|
262
327
|
}
|
|
263
328
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sfxmix",
|
|
3
3
|
"description": "🎧 SfxMix - powerful and easy-to-use module for processing audio",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.6",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"fluent-ffmpeg": "^2.1.3",
|
|
@@ -22,6 +22,14 @@
|
|
|
22
22
|
"wav",
|
|
23
23
|
"echo",
|
|
24
24
|
"delay",
|
|
25
|
+
"tremolo",
|
|
26
|
+
"pitch",
|
|
27
|
+
"phaser",
|
|
28
|
+
"compressor",
|
|
29
|
+
"flanger",
|
|
30
|
+
"reverb",
|
|
31
|
+
"highpass",
|
|
32
|
+
"lowpass",
|
|
25
33
|
"telephone",
|
|
26
34
|
"equalizer",
|
|
27
35
|
"volume",
|