From 18311afcfe3e8774d4b9f9b59fa142fd51e14274 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Fri, 4 Dec 2015 10:10:10 -0500 Subject: [PATCH] core/tests: Write a script to generate empty albums gen_tracks.sh will read a specially configured file and create a directory containing empty tracks to use for testing. Signed-off-by: Anna Schumaker --- tests/.gitignore | 1 + tests/Music/Hyrule_Symphony.album | 16 +++++++++++++++ tests/Music/Sconscript | 7 +++++++ tests/Music/gen_tracks.sh | 34 +++++++++++++++++++++++++++++++ tests/Sconscript | 3 +++ 5 files changed, 61 insertions(+) create mode 100644 tests/Music/Hyrule_Symphony.album create mode 100644 tests/Music/Sconscript create mode 100644 tests/Music/gen_tracks.sh diff --git a/tests/.gitignore b/tests/.gitignore index f1169409..d4307fbc 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -1,3 +1,4 @@ *-core *-lib sanity +*.ogg diff --git a/tests/Music/Hyrule_Symphony.album b/tests/Music/Hyrule_Symphony.album new file mode 100644 index 00000000..5ad2d556 --- /dev/null +++ b/tests/Music/Hyrule_Symphony.album @@ -0,0 +1,16 @@ +Koji Kondo +1998 Hyrule Symphony +Game +243 Title Theme +130 Kokiri Forest +227 Hyrule Field +130 Hyrule Castle +206 Lon Lon Ranch +186 Kakariko Village +178 Death Mountain +221 Zora's Domain +273 Gerudo Valley +66 Ganondorf +185 Princess Zelda +232 Ocarina Medley +288 The Legend of Zelda Medley diff --git a/tests/Music/Sconscript b/tests/Music/Sconscript new file mode 100644 index 00000000..a82bd8e7 --- /dev/null +++ b/tests/Music/Sconscript @@ -0,0 +1,7 @@ +#!/usr/bin/python +import subprocess + +albums = [ "Hyrule_Symphony.album" ] + +for album in albums: + subprocess.call(["sh", "gen_tracks.sh", album]) diff --git a/tests/Music/gen_tracks.sh b/tests/Music/gen_tracks.sh new file mode 100644 index 00000000..d2b36ea2 --- /dev/null +++ b/tests/Music/gen_tracks.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +TRACK=1 +FFMPEG="ffmpeg -hide_banner -nostdin -f s16le -i /dev/zero -codec libvorbis -loglevel warning" + +while read -r line; do + if [ -z "$ARTIST" ]; then + ARTIST="$line" + elif [ -z "$ALBUM" ]; then + YEAR=$(echo "$line" | cut -f 1 -d ' ') + ALBUM=$(echo "$line" | cut -f 1 -d ' ' --complement) + mkdir -p "$ALBUM" + elif [ -z "$GENRE" ]; then + GENRE="$line" + else + LENGTH=$(echo "$line" | cut -f 1 -d ' ') + TITLE=$(echo "$line" | cut -f -1 -d ' ' --complement) + NUMBER=$(printf "%02d" $TRACK) + FILE="$ALBUM/$NUMBER - $TITLE.ogg" + + if [ ! -f "$FILE" ]; then + echo "$FILE" + $FFMPEG -t "$LENGTH" "$FILE" + vorbiscomment -w "$FILE" -t "TITLE=$TITLE" \ + -t "ARTIST=$ARTIST" \ + -t "ALBUM=$ALBUM" \ + -t "GENRE=$GENRE" \ + -t "DATE=$YEAR" \ + -t "TRACKNUMBER=$NUMBER" + fi + + let TRACK=$TRACK+1 + fi +done < $1 diff --git a/tests/Sconscript b/tests/Sconscript index 056804f9..89bd0e99 100644 --- a/tests/Sconscript +++ b/tests/Sconscript @@ -26,6 +26,9 @@ def UnitTest(test, sources): return run Export("UnitTest") +#Generate empty audio files +SConscript("Music/Sconscript") + res = SConscript("core/Sconscript") if check_sanity == True: res = [ UnitTest("sanity", [ "sanity.c" ]) ] + res