diff options
author | Nicholas Tay <nick@windblume.net> | 2022-04-28 22:02:25 +1000 |
---|---|---|
committer | Nicholas Tay <nick@windblume.net> | 2022-04-28 22:02:25 +1000 |
commit | 10f3f56692cee2a071792baad26fba6c78b665b6 (patch) | |
tree | 6cf6a5bd2e4551fe7e181424cdc7b695aeba6854 | |
parent | 30547ed47ab653586073ae87d0c986c14ddaf241 (diff) | |
download | clak-10f3f56692cee2a071792baad26fba6c78b665b6.tar.gz clak-10f3f56692cee2a071792baad26fba6c78b665b6.tar.bz2 clak-10f3f56692cee2a071792baad26fba6c78b665b6.zip |
Split out sound logic (for xplatform)
Diffstat (limited to '')
-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; |