summaryrefslogtreecommitdiff
path: root/examples/micscope/test
diff options
context:
space:
mode:
Diffstat (limited to 'examples/micscope/test')
-rw-r--r--examples/micscope/test/README.md22
-rw-r--r--examples/micscope/test/profile.script167
-rw-r--r--examples/micscope/test/record.script23
-rw-r--r--examples/micscope/test/reference.flacbin0 -> 3841704 bytes
-rw-r--r--examples/micscope/test/render.script18
-rw-r--r--examples/micscope/test/sweep.wavbin0 -> 192044 bytes
-rw-r--r--examples/micscope/test/tones.wavbin0 -> 480044 bytes
-rw-r--r--examples/micscope/test/transport.script90
-rw-r--r--examples/micscope/test/tuner.script31
9 files changed, 351 insertions, 0 deletions
diff --git a/examples/micscope/test/README.md b/examples/micscope/test/README.md
new file mode 100644
index 0000000..6f4b833
--- /dev/null
+++ b/examples/micscope/test/README.md
@@ -0,0 +1,22 @@
+# Test material
+
+- `sweep.wav`: a 2 s log sweep (40 Hz to 16 kHz) over a quiet 440 Hz tone,
+ 48 kHz mono, generated for these tests.
+- `tones.wav`: five 1 s notes for the tuner, generated for these tests
+ (harmonics with a little noise, 48 kHz mono): E1 with its 2nd harmonic
+ loudest, E2 with a weak fundamental, A4 12 cents sharp, D4 with no
+ fundamental at all, and C7.
+- `reference.flac`: the rendering reference, all on one screen. 15 s of a
+ loudly mastered electronic track (sub-bass kicks, hats, a full mix), then
+ 15 s of a Berlin street (traffic, a close vehicle pass, broadband noise),
+ then `sweep.wav`; 48 kHz stereo, joined with short crossfades.
+
+ - Square Punch, "Thundercat" (Plasma Pumper EP, 2011), from 3:36:
+ [Wikimedia Commons](https://commons.wikimedia.org/wiki/File:Square_Punch_-_Thundercat.flac),
+ CC BY-SA 3.0.
+ - LG, "traffic karl-liebknechtstrasse 111223", from 1:18:
+ [Wikimedia Commons](https://commons.wikimedia.org/wiki/File:141977_lg_traffic-karl-liebknechtstrasse-111223.wav),
+ from [Freesound](http://freesound.org/people/LG/sounds/141977/),
+ CC BY-SA 3.0.
+
+ The excerpt is licensed CC BY-SA 3.0 like its sources.
diff --git a/examples/micscope/test/profile.script b/examples/micscope/test/profile.script
new file mode 100644
index 0000000..aa56b3e
--- /dev/null
+++ b/examples/micscope/test/profile.script
@@ -0,0 +1,167 @@
+# Zooms in and out one ctrl+wheel step per frame on the reference take, so
+# waveform and spectrogram are recomputed every frame: run by
+# `zig build profile` with --profile-gpu, which prints GPU time per command.
+console open test/reference.flac
+frames 3
+key right
+hold left_ctrl
+wheel 470 150 0.15
+frames 1
+wheel 470 150 0.15
+frames 1
+wheel 470 150 0.15
+frames 1
+wheel 470 150 0.15
+frames 1
+wheel 470 150 0.15
+frames 1
+wheel 470 150 0.15
+frames 1
+wheel 470 150 0.15
+frames 1
+wheel 470 150 0.15
+frames 1
+wheel 470 150 0.15
+frames 1
+wheel 470 150 0.15
+frames 1
+wheel 470 150 0.15
+frames 1
+wheel 470 150 0.15
+frames 1
+wheel 470 150 0.15
+frames 1
+wheel 470 150 0.15
+frames 1
+wheel 470 150 0.15
+frames 1
+wheel 470 150 0.15
+frames 1
+wheel 470 150 0.15
+frames 1
+wheel 470 150 0.15
+frames 1
+wheel 470 150 0.15
+frames 1
+wheel 470 150 0.15
+frames 1
+wheel 470 150 0.15
+frames 1
+wheel 470 150 0.15
+frames 1
+wheel 470 150 0.15
+frames 1
+wheel 470 150 0.15
+frames 1
+wheel 470 150 0.15
+frames 1
+wheel 470 150 0.15
+frames 1
+wheel 470 150 0.15
+frames 1
+wheel 470 150 0.15
+frames 1
+wheel 470 150 0.15
+frames 1
+wheel 470 150 0.15
+frames 1
+wheel 470 150 0.15
+frames 1
+wheel 470 150 0.15
+frames 1
+wheel 470 150 0.15
+frames 1
+wheel 470 150 0.15
+frames 1
+wheel 470 150 0.15
+frames 1
+wheel 470 150 0.15
+frames 1
+wheel 470 150 0.15
+frames 1
+wheel 470 150 0.15
+frames 1
+wheel 470 150 0.15
+frames 1
+wheel 470 150 0.15
+frames 1
+wheel 470 150 -0.15
+frames 1
+wheel 470 150 -0.15
+frames 1
+wheel 470 150 -0.15
+frames 1
+wheel 470 150 -0.15
+frames 1
+wheel 470 150 -0.15
+frames 1
+wheel 470 150 -0.15
+frames 1
+wheel 470 150 -0.15
+frames 1
+wheel 470 150 -0.15
+frames 1
+wheel 470 150 -0.15
+frames 1
+wheel 470 150 -0.15
+frames 1
+wheel 470 150 -0.15
+frames 1
+wheel 470 150 -0.15
+frames 1
+wheel 470 150 -0.15
+frames 1
+wheel 470 150 -0.15
+frames 1
+wheel 470 150 -0.15
+frames 1
+wheel 470 150 -0.15
+frames 1
+wheel 470 150 -0.15
+frames 1
+wheel 470 150 -0.15
+frames 1
+wheel 470 150 -0.15
+frames 1
+wheel 470 150 -0.15
+frames 1
+wheel 470 150 -0.15
+frames 1
+wheel 470 150 -0.15
+frames 1
+wheel 470 150 -0.15
+frames 1
+wheel 470 150 -0.15
+frames 1
+wheel 470 150 -0.15
+frames 1
+wheel 470 150 -0.15
+frames 1
+wheel 470 150 -0.15
+frames 1
+wheel 470 150 -0.15
+frames 1
+wheel 470 150 -0.15
+frames 1
+wheel 470 150 -0.15
+frames 1
+wheel 470 150 -0.15
+frames 1
+wheel 470 150 -0.15
+frames 1
+wheel 470 150 -0.15
+frames 1
+wheel 470 150 -0.15
+frames 1
+wheel 470 150 -0.15
+frames 1
+wheel 470 150 -0.15
+frames 1
+wheel 470 150 -0.15
+frames 1
+wheel 470 150 -0.15
+frames 1
+wheel 470 150 -0.15
+frames 1
+wheel 470 150 -0.15
+frames 1
diff --git a/examples/micscope/test/record.script b/examples/micscope/test/record.script
new file mode 100644
index 0000000..2750a18
--- /dev/null
+++ b/examples/micscope/test/record.script
@@ -0,0 +1,23 @@
+# Records (from whatever microphone the host gives a headless run) into a
+# new take, stops, and plays it back.
+expect takes 0
+key r
+expect transport.value recording
+expect takes 1
+frames 60
+screenshot .zig-cache/micscope/recording.png
+key r
+expect transport.value stopped
+key space
+expect transport.value forward
+frames 10
+# Each recording is another take; opening a file while recording ends it.
+key r
+expect takes 2
+expect selected 1
+console open test/sweep.wav
+expect transport.value stopped
+expect takes 3
+frames 2
+expect takes 3
+screenshot .zig-cache/micscope/strip.png
diff --git a/examples/micscope/test/reference.flac b/examples/micscope/test/reference.flac
new file mode 100644
index 0000000..7ad1c63
--- /dev/null
+++ b/examples/micscope/test/reference.flac
Binary files differ
diff --git a/examples/micscope/test/render.script b/examples/micscope/test/render.script
new file mode 100644
index 0000000..71b50c7
--- /dev/null
+++ b/examples/micscope/test/render.script
@@ -0,0 +1,18 @@
+# The rendering reference (see README.md): song, street and sweep in one
+# take. Screenshots land in .zig-cache/micscope/ for review.
+console open test/reference.flac
+expect transport.value stopped
+frames 3
+screenshot .zig-cache/micscope/reference.png
+# Playing: the playhead across waveform and spectrogram, the spectrum.
+key right
+frames 90
+expect-audio 1
+screenshot .zig-cache/micscope/reference-playing.png
+# Zoomed into the street: the low end's hum lines and the noise floor.
+key space
+hold left_ctrl
+wheel 660 150 4
+release left_ctrl
+frames 3
+screenshot .zig-cache/micscope/reference-street.png
diff --git a/examples/micscope/test/sweep.wav b/examples/micscope/test/sweep.wav
new file mode 100644
index 0000000..1f131e3
--- /dev/null
+++ b/examples/micscope/test/sweep.wav
Binary files differ
diff --git a/examples/micscope/test/tones.wav b/examples/micscope/test/tones.wav
new file mode 100644
index 0000000..b2cf3ea
--- /dev/null
+++ b/examples/micscope/test/tones.wav
Binary files differ
diff --git a/examples/micscope/test/transport.script b/examples/micscope/test/transport.script
new file mode 100644
index 0000000..f821a03
--- /dev/null
+++ b/examples/micscope/test/transport.script
@@ -0,0 +1,90 @@
+# Opens a file as a take and plays it both ways: a 2 s log sweep (40 Hz to
+# 16 kHz) over a quiet 440 Hz tone.
+console open test/sweep.wav
+frames 2
+expect takes 1
+expect selected 0
+expect transport.value stopped
+key right
+expect transport.value forward
+frames 30
+expect-audio 1
+screenshot .zig-cache/micscope/forward.png
+key left
+expect transport.value backward
+expect backward true
+frames 20
+key space
+expect transport.value stopped
+# Space resumes the way it last went.
+key space
+expect transport.value backward
+key space
+# Seeking: keys, and a click on the take's timeline.
+key end
+expect seek.value 1
+click 400 150
+expect seek.serial 2
+# Ctrl+wheel (or a pinch) on a take's timeline zooms its time around the
+# pointer; Z zooms back out.
+hold left_ctrl
+wheel 400 150 3
+release left_ctrl
+key z
+key right
+frames 30
+screenshot .zig-cache/micscope/played.png
+# A second take goes under the first and is selected; up is older.
+console open test/sweep.wav
+expect takes 2
+expect selected 1
+key up
+expect selected 0
+key down
+expect selected 1
+# A click on the first take selects it.
+click 400 150
+expect selected 0
+frames 2
+screenshot .zig-cache/micscope/two-takes.png
+# Deleting it leaves the second.
+key delete
+expect takes 1
+expect selected 0
+# State that miscounts the takes is told by draw.
+console set takes 0
+frames 2
+expect takes 1
+# More takes than fit: the camera follows the bottom until the wheel pans
+# it, then 0 shows the whole strip.
+console open test/sweep.wav
+console open test/sweep.wav
+console open test/sweep.wav
+expect follow true
+wheel 400 400 2
+expect follow false
+frames 2
+screenshot .zig-cache/micscope/panned.png
+key 0
+expect follow true
+frames 2
+screenshot .zig-cache/micscope/overview.png
+# Ctrl+wheel off the timelines zooms the view.
+hold left_ctrl
+wheel 1150 400 1
+release left_ctrl
+frames 2
+screenshot .zig-cache/micscope/zoomed-view.png
+# The buttons on top do what the keys do, for touch screens.
+click 832 18
+expect transport.value recording
+click 832 18
+expect transport.value stopped
+click 890 18
+expect transport.value forward
+click 890 18
+expect transport.value stopped
+click 1238 18
+expect a4 441
+frames 2
+screenshot .zig-cache/micscope/buttons.png
diff --git a/examples/micscope/test/tuner.script b/examples/micscope/test/tuner.script
new file mode 100644
index 0000000..4e0e480
--- /dev/null
+++ b/examples/micscope/test/tuner.script
@@ -0,0 +1,31 @@
+# The tuner on a take, at its playhead: five notes where the strongest FFT
+# peak is not (or not only) the note. Expected, by screenshot:
+# E1 0 cents (41.2 Hz) bass, 2nd harmonic loudest
+# E2 0 cents (82.4 Hz) guitar, weak fundamental
+# A4 +12 cents (443.1 Hz) sharp
+# D4 0 cents (293.7 Hz) fundamental missing
+# C7 0 cents (2093 Hz) piccolo
+console open test/tones.wav
+click 107 150
+frames 20
+screenshot .zig-cache/micscope/tuner-e1.png
+click 290 150
+frames 20
+screenshot .zig-cache/micscope/tuner-e2.png
+click 472 150
+frames 20
+screenshot .zig-cache/micscope/tuner-a4.png
+click 654 150
+frames 20
+screenshot .zig-cache/micscope/tuner-d4.png
+click 837 150
+frames 20
+screenshot .zig-cache/micscope/tuner-c7.png
+# Another reference pitch: A4 = 443 makes the sharp A4 in tune.
+click 472 150
+key right_bracket
+key right_bracket
+key right_bracket
+expect a4 443
+frames 20
+screenshot .zig-cache/micscope/tuner-a443.png