exAudio.cpp
Add room reflections and save audio. Load the OA narration, convert it to mono, normalize it, render a native GPU reverberation tail, then save a checked WAV output.
Source
Example
1#include <oa/oa.h>23OA_MAIN_PREVIEW("ExampleAudio") {4 auto audioResult = oa::FnAudio::decodeFile(oa::Paths::asset("audio/oaNarration.wav"));5 if (not audioResult.isOk()) {6 return 1;7 }8 auto audio = oa::move(audioResult).getValue();910 auto mono = oa::FnAudio::toMono(audio);1112 auto normalized = oa::FnAudio::normalize(mono, -3.0F);1314 auto faded = oa::FnAudio::fade(normalized, 2400U, 2400U);1516 auto reverberated = oa::FnAudio::reverb(faded, 1.5F, 0.4F);1718 const oa::Path output = oa::Paths::var("example/audio/oaNarrationRoom.wav");19 if (not oa::Filesystem::createDirectories(output.parentPath()).isOk()) {20 return 1;21 }22 if (not oa::FnAudio::saveWavF32(output, reverberated).isOk()) {23 return 1;24 }2526 if (not reverberated.validate()) return 1;27 if (reverberated.sampleRate() != 24000U) return 1;28 if (reverberated.channels() != 1) return 1;29 if (reverberated.samples() != faded.samples()30 + static_cast<oa::I64>(reverberated.sampleRate())31 * 1500 / 1'000) {32 return 1;33 }34 if (not oa::Filesystem::isFile(output)) return 1;3536 oa::print("Saved reverberated audio (1.5 s tail): {}", output.cStr());3738 if (argc > 1 and oa::StringView(argv[1]) == "--preview") {39 oa::ViewerConfig previewConfig;40 previewConfig.mode = oa::ViewerMode::Audio;41 previewConfig.title = "OA audio · room reverb";42 previewConfig.width = 960U;43 previewConfig.height = 360U;44 if (not oa::Viewer::preview(engine, oa::Paths::var("example/audio/oaNarrationRoom.wav").string(),45 previewConfig).isOk()) {46 return 1;47 }48 }49 return 0;50}51
Output
Before / after. Play the authored narration beside the artifact produced by this exact SDK example. The processed WAV is copied byte-for-byte from var/example/audio/oaNarrationRoom.wav after a successful run.
Input asset
Source
The unprocessed OA narration loaded by the example.
- Duration
- 0:12.52
- Signal
- 24 kHz · mono
- Evidence
- SHA-256 699cefa842202065d2d63ad43d3d06dc244bcae80664de58eeeacde2f57d3e21
Verified output
Processed
Normalized, faded, and rendered through oa::FnAudio::reverb with a 1.5 second tail.
- Duration
- 0:14.02
- Signal
- 24 kHz · mono
- Evidence
- SHA-256 b99343671d0b8c829bf495f40385a6287a78ef38deca58d3ad775c3de42a196b
Present
The Output section above remains the exact artifact evidence. These captures document the current interactive Viewer surface used by the presentation path.

OA Viewer · Presented state
Waveform
The current Viewer waveform surface used by the optional --preview path. The processed WAV above remains the exact example artifact.

OA Viewer · Presented state
Spectrogram
The current Viewer linear-frequency inspection surface, sharing the waveform transport and playhead contract.

OA Viewer · Presented state
Mel spectrogram
The current Viewer perceptual-frequency surface for speech and learned-audio inspection.