From cab6c2c429922ff55f6de775264545479a363074 Mon Sep 17 00:00:00 2001 From: Laar3 Date: Fri, 30 Dec 2022 22:41:52 +1030 Subject: [PATCH] added script to convert wav files for use in firmware. --- README.md | 8 ++++++++ convert.sh | 26 ++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100755 convert.sh diff --git a/README.md b/README.md index 19874da..ec6993c 100644 --- a/README.md +++ b/README.md @@ -65,3 +65,11 @@ bestool write-image out/open_source/open_source.bin --port /dev/ttyACM1 - Hold : Previous track - Triple tap : Volume Up - Quad tap : Volume Down + +## Changing audio alerts +The audio alerts are stored in: + +`config/_default_cfg_src_/res/en/` + +You can convert these .txt files to .wav files by using the script `convert.sh` with the -T flag, the resulting file will be named `output.wav`. +If you want to change the alert to a custom sound use the -W flag on your wav file and then move the resulting `SOUND.txt` file to the place you want to replace (eg. `config/_default_cfg_src_/res/en/SOUND_POWER_ON.txt`) diff --git a/convert.sh b/convert.sh new file mode 100755 index 0000000..571b1d9 --- /dev/null +++ b/convert.sh @@ -0,0 +1,26 @@ +#!/bin/sh +txt_to_wav() { + xxd -r -p $args > out.raw + ffmpeg -f sbc -ac 1 -i ./out.raw output.wav + rm ./out.raw +} + +wav_to_txt() { + ffmpeg -i $args -f sbc -ac 16000 -ac 1 -map_metadata -1 out.raw + xxd -i ./out.raw | head -n -2 \ + | tail -n +2 | sed 's/ //g' \ + | tr --delete '\n' \ + | sed 's/,/\,\n/16; P; D' > SOUND.txt + rm ./out.raw +} + +[ ${1} = "-T" ] || [ ${1} = "--txt-to-wav" ] && shift 1 && args=$@ && txt_to_wav && exit +[ ${1} = "-W" ] || [ ${1} = "--wav-to-txt" ] && shift 1 && args=$@ && wav_to_txt && exit +echo " +Sound format converter: +Usage: + ./convert.sh [option] [input-file] +Options: +-T or --txt-to-wav Converts the text file to a wav audio file (output.wav) +-W or --wav-to-txt Converts a wav file to a file readable by the pinebuds firmware (SOUND.txt) +"