6 background = activeBorder;
18 this, caption = "Play", position = { 200, 168 };
20 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
30 if(sound.Load("sweep.wav"))
34 freq = sound.frequency; //44100;
35 bits = sound.bits; //16;
36 channels = sound.channels; //2;
37 samples = AUDIO_BUFFER_SIZE;
38 callback = AudioCallback;
40 windowHandle = systemHandle;
45 if(OpenAudio(wantedSpec, spec) < 0)
47 MessageBox { contents = "OpenAudio epic fail" }.Modal();
53 MessageBox { contents = "sweep.wav not found" }.Modal();
62 void AudioCallback(byte *stream, int len)
64 static byte buffer[AUDIO_BUFFER_SIZE];
65 int s = Min(sound.length * (sound.bits == 16 ? 2 : 1) - pos, len);
66 memcpy(buffer, sound.data + pos, s);
74 byte value = sound.data[pos-1];
76 for(c = s; c < len; c++)
78 if(value < 128) value++; else if(value > 128) value--; else break;
83 memset(buffer + s, 128, len - s);
86 memset(buffer + s, 0, len - s);
88 memcpy(stream, buffer, len);