mirror of
https://github.com/libSDL2pp/libSDL2pp.git
synced 2025-08-03 19:05:59 -04:00
Fix build for ms compiler
This commit is contained in:
parent
913b219256
commit
41c96ba25b
@ -33,15 +33,17 @@ using namespace SDL2pp;
|
||||
int main(int, char*[]) try {
|
||||
SDL sdl(SDL_INIT_AUDIO);
|
||||
|
||||
constexpr int samplerate = 48000;
|
||||
constexpr float frequency = 2093.00f; // C7 tone
|
||||
// XXX: these should be constexpr and not captured in lambda
|
||||
// below, but that fails on microsoft crapiler
|
||||
int samplerate = 48000;
|
||||
float frequency = 2093.00f; // C7 tone
|
||||
int64_t nsample = 0;
|
||||
|
||||
// Setup audio device, and provide callback which plays sine wave with specified frequency
|
||||
AudioSpec spec(samplerate, AUDIO_S16SYS, 1, 4096);
|
||||
|
||||
// Open audio device
|
||||
AudioDevice dev(NullOpt, 0, spec, [&nsample](Uint8* stream, int len) {
|
||||
AudioDevice dev(NullOpt, 0, spec, [&nsample, samplerate, frequency](Uint8* stream, int len) {
|
||||
// fill provided buffer with sine wave
|
||||
for (Uint8* ptr = stream; ptr < stream + len; ptr += 2)
|
||||
*(Uint16*)ptr = (Uint16)(32766.0f * sin(nsample++ / (float)samplerate * frequency));
|
||||
|
@ -33,6 +33,8 @@ int main(int, char*[]) try {
|
||||
SDL sdl(SDL_INIT_AUDIO);
|
||||
Mixer mixer(MIX_DEFAULT_FREQUENCY, AUDIO_S16SYS, 1, 4096);
|
||||
|
||||
// XXX: this should be constexpr and not captured in lambda
|
||||
// below, but that fails on microsoft crapiler
|
||||
float frequency = 2093.00f; // C7 tone
|
||||
int64_t nsample = 0;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user