aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Tay <nick@windblume.net>2022-04-28 21:39:50 +1000
committerNicholas Tay <nick@windblume.net>2022-04-28 21:39:50 +1000
commit1783cfd9965c38d60cea3daff172c6657983719b (patch)
treef8c90dd4e13a1921065c78cda3cbaed022754244
downloadclak-1783cfd9965c38d60cea3daff172c6657983719b.tar.gz
clak-1783cfd9965c38d60cea3daff172c6657983719b.tar.bz2
clak-1783cfd9965c38d60cea3daff172c6657983719b.zip
Initial working Windows playsound
Diffstat (limited to '')
-rw-r--r--.gitignore4
-rw-r--r--Makefile29
-rw-r--r--board/mxblue/board_down.wavbin0 -> 15404 bytes
-rw-r--r--board/quack/board_down.wavbin0 -> 46008 bytes
-rw-r--r--clak.c17
5 files changed, 50 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..5529293
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+clak
+clak.exe
+board/boards.h
+board/*/board.h \ No newline at end of file
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..2635da2
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,29 @@
+NAME = clak
+PREFIX = $(HOME)/.local
+
+BOARDS = mxblue quack
+
+CC = gcc
+CFLAGS += -std=c99 -Wall -Wextra -Wshadow -Werror -pedantic
+LDLIBS = -lWinmm
+
+BOARD_FILES = $(addsuffix /board.h,$(addprefix board/,$(BOARDS)))
+
+default: $(NAME)
+
+$(NAME): $(NAME).c $(BOARD_FILES) board/boards.h
+ $(CC) $(CFLAGS) $(NAME).c $(LDLIBS) -o $(NAME)
+
+board/boards.h:
+ printf "#ifndef BOARD_DEFAULTS_H\n#define BOARD_DEFAULTS_H\n\n" > board/boards.h
+ for board in $(BOARDS); do echo "#include \"$$board/board.h\"" >> board/boards.h; done
+ printf "\n#endif /* BOARD_DEFAULTS_H */" >> board/boards.h
+
+$(BOARD_FILES): %.h: %_down.wav
+ xxd -i "$<" "$@"
+
+clean:
+ rm -f *.o
+ rm -f $(NAME)
+ rm -f board/boards.h
+ rm -f $(BOARD_FILES) \ No newline at end of file
diff --git a/board/mxblue/board_down.wav b/board/mxblue/board_down.wav
new file mode 100644
index 0000000..91699d9
--- /dev/null
+++ b/board/mxblue/board_down.wav
Binary files differ
diff --git a/board/quack/board_down.wav b/board/quack/board_down.wav
new file mode 100644
index 0000000..6a4d167
--- /dev/null
+++ b/board/quack/board_down.wav
Binary files differ
diff --git a/clak.c b/clak.c
new file mode 100644
index 0000000..3a0c5bf
--- /dev/null
+++ b/clak.c
@@ -0,0 +1,17 @@
+#include <stdio.h>
+
+#include <windows.h>
+
+#include "board/boards.h"
+
+int main(void)
+{
+ float volume = 0.05;
+ DWORD channel_volume = volume * 0xFFFF;
+ waveOutSetVolume(NULL, (channel_volume << 16) | channel_volume);
+ while (1) {
+ PlaySound((const char *) board_mxblue_board_down_wav, NULL, SND_MEMORY | SND_SYNC | SND_NODEFAULT);
+ Sleep(500);
+ }
+ return 0;
+} \ No newline at end of file