aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--clak.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/clak.c b/clak.c
index 5e947e9..d6ad034 100644
--- a/clak.c
+++ b/clak.c
@@ -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;