main
6f8fc97 · 1 month ago 10 commits

Audio Processing Flow

                    main()
                      │
                      ▼
      AudioProcessor(input, output)
                      │
                      ▼
      processWithCustomResampler()
                       │
      ┌────────────────┘
      │                                
      ▼                                
readRawAudioFile() ─▶ resample() ─▶  performAGC()
                                           │
                                           ▼
                                    Create AGC instance
                                           │
                                           ▼
                               GainController2 initialized
                                           │
                                           ▼
                              Process audio in 10 ms frames
                                          │                                                      
                                          ▼                                                      
                                 processFrame()                                             
      ┌───────────────────────────────────┘
      │                                
      ▼   
AGC::process(frame)  ─▶AudioBuffer::CopyFrom()  ─▶ GainController2::Process() ─▶AudioBuffer::CopyTo()
                                                                                          │
                                                                                          ▼
                                                                        Processed frame copied to output buffer
                                                                                          │
                                                                                          ▼
                                                                                  writeRawAudioFile()

GainController2 Internal Flow

Each 10 ms audio frame follows the pipeline below.

                  Input Audio Frame
                         │
                         ▼
                GainController2::Process()
                         │
                         ▼
          Is internal VAD enabled?
                 │              │
              Yes              No
                 │              │
                 ▼              ▼
      vad_->Analyze()     Caller must provide
                           speech_probability
                 │              │
                 └──────┬───────┘
                        ▼
          speech_probability available?
                        │
                        ▼
         SpeechLevelEstimator::Update()
                        │
                        ▼
        Adaptive Digital Gain Controller
                        │
                        ▼
             Apply gain to audio frame
                        │
                        ▼
                 Output Audio Frame