Skip to content

Instantly share code, notes, and snippets.

View Wassimulator's full-sized avatar

Wassim Alhajomar Wassimulator

View GitHub Profile
@Wassimulator
Wassimulator / audio.cpp
Last active April 2, 2025 19:47
Simple WASAPI example (copied over from a little game engine project, uses an external library for loading WAV files, not included, but the main concepts of using WASAPI are here)
/*
# example 1: 1 second of sound at 48000 Hz stereo 16 bit integer:
| ////////////////////////////// 1 Second = 48000 frames = 48k Hz ////////////////////////////////// |
| 48k * 4 bytes = 192k bytes per second = 1536 kbps bitrate |
| ///////////// FRAME ///////////// | ///////////// FRAME ///////////// | FRAME | FRAME | | | | |
| 4 bytes = 32 bits | 4 bytes = 32 bits | ... | ... | | | | |
| //// SAMPLE L//// | //// SAMPLE R//// | //// SAMPLE L//// | //// SAMPLE R//// | ... | ... | | | | |
| u16 = 2 bytes | u16 = 2 bytes | u16 = 2 bytes | u16 = 2 bytes | ... | ... | | | | |