diff options
-rw-r--r-- | clak.c | 22 |
1 files changed, 17 insertions, 5 deletions
@@ -1,7 +1,10 @@ #include <stdio.h> +#include <unistd.h> #include <windows.h> +#define VOLUME 0.05 + #include "board/boards.h" #define BOARD(str, buf) { .name = str, .wav = buf }, @@ -15,16 +18,25 @@ Board boards[] = { }; int const boards_n = sizeof(boards) / sizeof(boards[0]); -int main(void) +void sound_init(void) { - float volume = 0.05; - DWORD channel_volume = volume * 0xFFFF; + DWORD channel_volume = VOLUME * 0xFFFF; waveOutSetVolume(NULL, (channel_volume << 16) | channel_volume); +} + +void sound_play(unsigned char* buffer) +{ + PlaySound((const char *) buffer, NULL, SND_MEMORY | SND_SYNC | SND_NODEFAULT); +} + +int main(void) +{ + sound_init(); for (int i = 0; i < boards_n; ++i) { printf("name: %s\n", boards[i].name); - PlaySound((const char *) boards[i].wav, NULL, SND_MEMORY | SND_SYNC | SND_NODEFAULT); - Sleep(500); + sound_play(boards[i].wav); + sleep(0.5); } return 0; |