|
Line 0
Link Here
|
|
|
1 |
--- examples/audio_sine.cc.orig 2017-06-28 19:39:10 UTC |
| 2 |
+++ examples/audio_sine.cc |
| 3 |
@@ -33,15 +33,15 @@ using namespace SDL2pp; |
| 4 |
int main(int, char*[]) try { |
| 5 |
SDL sdl(SDL_INIT_AUDIO); |
| 6 |
|
| 7 |
- const int samplerate = 48000; |
| 8 |
- float frequency = 2093.00f; // C7 tone |
| 9 |
+ constexpr int samplerate = 48000; |
| 10 |
+ constexpr float frequency = 2093.00f; // C7 tone |
| 11 |
int64_t nsample = 0; |
| 12 |
|
| 13 |
// Setup audio device, and provide callback which plays sine wave with specified frequency |
| 14 |
AudioSpec spec(samplerate, AUDIO_S16SYS, 1, 4096); |
| 15 |
|
| 16 |
// Open audio device |
| 17 |
- AudioDevice dev(NullOpt, 0, spec, [&nsample, frequency, samplerate](Uint8* stream, int len) { |
| 18 |
+ AudioDevice dev(NullOpt, 0, spec, [&nsample](Uint8* stream, int len) { |
| 19 |
// fill provided buffer with sine wave |
| 20 |
for (Uint8* ptr = stream; ptr < stream + len; ptr += 2) |
| 21 |
*(Uint16*)ptr = (Uint16)(32766.0f * sin(nsample++ / (float)samplerate * frequency)); |