chenlh
2026-03-20 f761b6198e2e98f02adb84c83dbf59529e51b2ef
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
 
#include "reverb.h"
#include "compressor.h"
#include "reverb_gate.h"
 
int main(void)
{
    Reverb<float> rvb;
    rvb.prepare(48000);
    rvb.setRoomSize(1.0);
    rvb.setDecay(1.0);
    rvb.setCutoff(5000);
    rvb.setMix(1.0);
 
    Compressor<float> comp; 
    comp.prepare(48000);
    comp.setThreshold(-20.0);
    comp.setRatio(5.0);
    comp.setAttack(0.001);
    comp.setRelease(0.1);
    comp.setGain(1.0);
 
 
    std::string output_file = "output.wav";
    Wave w;
    w.read_wav("E:\\music\\Voice_print\\GaoWeiDong.wav");
    w.init_channels_maxmin();
    w.update_channel_maxmin();
    float gate_gain;
 
    for (int i = 0; i < w.num_channels; ++i)
    {
        for (int j = 0; j < w.num_samples; ++j) {
            gate_gain = comp.processSample(w.samples[i][j]);
            w.samples[i][j] = rvb.processSample(w.samples[i][j]) * gate_gain;
        }
    }
 
 
 
    // normalizing to db 
    LOG_INFO("normalized_volume : " << db_to_vol(-1.5f));
    LOG_INFO("normalized_volume_db: " << -1.5f);
    w.update_channel_maxmin();
    w.normalize(-db_to_vol(-1.5f), db_to_vol(-1.5f));
    w.write_wav(output_file);
    LOG_INFO("output_file : " << output_file);
    w.info_summary();
 
    return 0;
}