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.

ExSDK source-ownedC++Audio

Source

Example

1#include <oa/oa.h>
2
3OA_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();
9
10 auto mono = oa::FnAudio::toMono(audio);
11
12 auto normalized = oa::FnAudio::normalize(mono, -3.0F);
13
14 auto faded = oa::FnAudio::fade(normalized, 2400U, 2400U);
15
16 auto reverberated = oa::FnAudio::reverb(faded, 1.5F, 0.4F);
17
18 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 }
25
26 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;
35
36 oa::print("Saved reverberated audio (1.5 s tail): {}", output.cStr());
37
38 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

WAV

The unprocessed OA narration loaded by the example.

Duration
0:12.52
Signal
24 kHz · mono
Evidence
SHA-256 699cefa842202065d2d63ad43d3d06dc244bcae80664de58eeeacde2f57d3e21

Verified output

Processed

WAV

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 audio transport displaying a waveform overview

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.

Download capture
1920×720 · JPEGSHA-256 47707d082b578ac0OA Viewer documentation capture · 2026-08-31
OA Viewer audio transport displaying a green spectrogram

OA Viewer · Presented state

Spectrogram

The current Viewer linear-frequency inspection surface, sharing the waveform transport and playhead contract.

Download capture
1920×720 · JPEGSHA-256 9d9936afdfc13330OA Viewer documentation capture · 2026-08-31
OA Viewer audio transport displaying a warm mel spectrogram

OA Viewer · Presented state

Mel spectrogram

The current Viewer perceptual-frequency surface for speech and learned-audio inspection.

Download capture
1920×720 · JPEGSHA-256 c1600e22f58ab3f7OA Viewer documentation capture · 2026-08-31