summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2011-12-24 03:04:45 +0100
committerDaniel Friesel <derf@finalrewind.org>2011-12-24 03:04:45 +0100
commitef06f59cb716f494dfd7348e01ffa8fd698967a0 (patch)
treeb81f647a1d57c4cf3bf7b7922c96dc225e3f4dff
parent2c71143fd27ab876d7165df3f643bcad2664ccb0 (diff)
Add wiiplay (wiiskpr wrapper with automatic conversion)
-rwxr-xr-xwiiplay36
-rw-r--r--wiispkr.c4
2 files changed, 38 insertions, 2 deletions
diff --git a/wiiplay b/wiiplay
new file mode 100755
index 0000000..b3ee3aa
--- /dev/null
+++ b/wiiplay
@@ -0,0 +1,36 @@
+#!/usr/bin/env zsh
+## Copyright © 2011 by Daniel Friesel <derf@finalrewind.org>
+## License: WTFPL:
+## 0. You just DO WHAT THE FUCK YOU WANT TO
+
+setopt err_exit
+
+if [[ -z $1 || -z $2 ]]; then
+ echo "Usage: $0 <file>" >&2
+ exit 1
+fi
+
+if [[ ${2:e} == ogg ]]; then
+
+ oggdec -o /tmp/wiiplay.wav ${2}
+
+elif [[ ${2:e} == mp3 ]]; then
+
+ mpg321 -w /tmp/wiiplay.wav ${2}
+
+elif [[ ${2:e} == wav ]]; then
+
+ cp ${2} /tmp/wiiplay.wav
+
+else
+
+ echo "${2:e}: unsupported format" >&2
+ exit 1
+
+fi
+
+sox --norm /tmp/wiiplay.wav -b 8 /tmp/wiiplay.raw channels 1 rate 1500
+
+rm /tmp/wiiplay.wav
+
+./wiispkr ${1} < /tmp/wiiplay.raw
diff --git a/wiispkr.c b/wiispkr.c
index 1ee5370..ae783b6 100644
--- a/wiispkr.c
+++ b/wiispkr.c
@@ -80,11 +80,11 @@ int main(int argc, char **argv)
t = (tv.tv_sec * 1000000 + tv.tv_usec) / 100;
if (t > timeout) {
- printf("play second %f pos %d\n", (double)(t - start) / 10000, fpos);
+ printf("\r\033[2Kplay second %f pos %d", (double)(t - start) / 10000, fpos);
+ fflush(stdout);
if ((readbytes = read(0, &sample, sizeof(sample))) == -1)
return 0;
fpos += readbytes;
- print_sample(sample, sizeof(sample));
wiimote_speaker_play(&wiimote, sample, sizeof(sample));
timeout = t + 130;
}