-
Notifications
You must be signed in to change notification settings - Fork 3
/
aecho.js
118 lines (108 loc) · 2.65 KB
/
aecho.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
const addFilter = require('./utils').addFilter;
const registerFilter = require('./utils').registerFilter;
/**
* Augment FfmpegCommand with the aecho function.
*
*
* @example
* ffmpeg().aecho()
* ... // call filter configuration functions
* .build() // end filter configuration
* ...
* .applyFilters() // called once all filters have been configured
*
* @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor.
* @return {FfmpegCommand} The ffmpegCommand augmented with the aecho function.
*/
function aecho(ffmpegCommand) {
registerFilter(ffmpegCommand, 'aecho', function() {
return new AechoFilter(this);
});
return ffmpegCommand;
}
/**
* Class exposing methods to configure the vstack filter in a builder pattern way.
*
* See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description
* of each configuration option.
*/
class AechoFilter {
/**
* @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor.
*/
constructor (ffmpeg) {
this.ffmpeg = ffmpeg;
AechoFilter.prototype.withIn_gain = this.in_gain;
AechoFilter.prototype.withOut_gain = this.out_gain;
AechoFilter.prototype.withDelays = this.delays;
AechoFilter.prototype.withDecays = this.decays;
}
/**
* Set input gain of reflected signal. Default is 0.6.
*
*
* @param val
*/
in_gain(val) {
this._in_gain = val;
return this;
}
/**
* Set output gain of reflected signal. Default is 0.3.
*
*
* @param val
*/
out_gain(val) {
this._out_gain = val;
return this;
}
/**
* Set list of time intervals in milliseconds between original signal and reflections
* separated by ’|’. Allowed range for each delay is (0 - 90000.0].
* Default is 1000.
*
*
* @param val
*/
delays(val) {
this._delays = val;
return this;
}
/**
* Set list of loudnesses of reflected signals separated by ’|’.
* Allowed range for each decay is (0 - 1.0].
* Default is 0.5.
*
* @param val
*/
decays(val) {
this._decays = val;
return this;
}
/**
* Creates this filter configuration and registers it in the ffmpeg instance.
* @return {ffmpegCommand} The ffmpeg instance.
*/
build() {
let opt = {};
if (this._in_gain) {
opt['in_gain'] = this._in_gain;
}
if (this._out_gain) {
opt['out_gain'] = this._out_gain;
}
if (this._delays) {
opt['delays'] = this._delays;
}
if (this._decays) {
opt['decays'] = this._decays;
}
addFilter(this.ffmpeg, {
filter: 'aecho',
options: opt
});
return this.ffmpeg;
}
}
module.exports.aecho = aecho;