-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschroeder_reverb.cpp
More file actions
76 lines (61 loc) · 2.4 KB
/
schroeder_reverb.cpp
File metadata and controls
76 lines (61 loc) · 2.4 KB
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
/* Copyright (C) 2020 Alexandros I. Metsai
* alexmetsai@gmail.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
// Implemented the more sophisticated reverb algorithm proposed by Manfred Schroeder.
// This approach makes used of Comb and All-Pass filters.
AudioFile<double> combFilter(AudioFile<double> audioFile, double delayMilliseconds = 0.3, double decay = 0.5f);
void allPassFilter();
AudioFile<double> schroeder_reverb(AudioFile<double> audioFile);
int main(){
char *input = NULL;
int c;
double mix = 0.5;
if (argc <= 2){
std::cout << "You have to specify the wav file that will be processed." << std::endl;
return -1;
}
while((c = getopt(argc, argv, "i:")) != -1)
switch (c){
case 'i':
input = optarg;
break;
case '?':
fprintf(stderr, "Unknown argument -%c .\n", optopt);
return 1;
default:
abort();
}
// Load wav file
AudioFile<double> audioFile, effect;
audioFile.load(input);
// Apply reverb
// TODO
return 0;
}
AudioFile<double> combFilter(AudioFile<double> audioFile, double delayMilliseconds, double decay){
// Calculate the number of delay samples and the number of channels.
int delaySamples = int(delayMilliseconds * (audioFile.getSampleRate()/1000));
int numChannels = audioFile.getNumChannels();
int channel;
// See if you need a separate copy of 'audioFile'.
// temp = pseudocopy audioFile;
for (int i = 0; i < audioFile.getNumSamplesPerChannel() - delaySamples; i++{
for (channel = 0; channel < numChannels; channel ++){
audioFile.samples[channel][i+delaySamples] += (double)((double)audioFile.samples[channel][i] * decay);
}
}
return audioFile;
}