Zoomable page¶
One self-contained offline page that zooms from a whole session to a single action.
One self-contained page that zooms from a whole session down to a single action.
The stated aim for this toolbox's dance corpus included "the ability to zoom from the whole session down to a single action, and preparation for manual annotation". What existed was three printed scales over a thirteen-level pyramid that could have supported any scale. This closes that gap, and it is the only interactive thing in the toolbox.
Self-contained, or it is not a deliverable. The page has to work from a folder somebody was emailed, with no server and no network. So the videogram is embedded as an image and the motion envelope and the annotations as numbers, and the page reads nothing at runtime.
How much to embed is a decision with a right answer. Too little and the page cannot
resolve the gestures it exists to show; too much and it will not open. embed_budget makes
that trade explicit and the page states the resolution it actually achieved, so nobody
mistakes a smooth curve for a still moment.
Min and max per bucket, never a mean. The same rule as every other figure here: a brief motion is what an overview exists to find, and a mean is what removes it.
decimate_minmax_pairs ¶
decimate_minmax_pairs(x, n_buckets)
The lowest and highest value in each of n_buckets equal slices.
Both extremes, because a single brief spike is exactly what a zoomed-out view must not lose, and any average removes it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
The series. |
required | |
n_buckets
|
int
|
How many buckets to reduce it to. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
(lows, highs). A series shorter than |
|
|
both, since asking for more detail than exists must not invent any. |
Source code in musicalgestures/_zoomview.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | |
embed_budget ¶
embed_budget(duration_s, max_points=8000)
How many points to embed, and what resolution that buys.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
duration_s
|
float
|
Length of the recording. |
required |
max_points
|
int
|
Ceiling on embedded points. Defaults to 8000, which is a few hundred kilobytes of JSON and about 1.2 s per point on a two-hour recording. |
8000
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
|
state |
dict
|
a viewer who zooms past it is looking at interpolation, not data. |
Source code in musicalgestures/_zoomview.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 | |
zoomable_page ¶
zoomable_page(analysis_dir, duration_s, out, hierarchy=None, max_points=8000, videogram_width=3000, title='session', which='videogram_v', video=None, audio=None, player=None, start_s=0.0)
Write a self-contained HTML page that zooms from the whole session to one action.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
analysis_dir
|
Directory holding the cached pyramid and |
required | |
duration_s
|
float
|
Length of the recording. |
required |
out
|
Path to write. Everything is embedded; nothing else is needed beside it. |
required | |
hierarchy
|
A |
None
|
|
max_points
|
int
|
Ceiling on embedded envelope points. |
8000
|
videogram_width
|
int
|
Width in pixels of the embedded strips. |
3000
|
title
|
str
|
Shown on the page. |
'session'
|
which
|
str
|
Which pyramid to embed when |
'videogram_v'
|
video
|
dict
|
Named video strips, label to a (rows, time) array --- for example a videogram and a motiongram --- embedded in order, with the page offering a switch when there is more than one. None keeps the cached pyramid as the single strip. |
None
|
audio
|
optional
|
Path to an audio (or video) file. When given, the page gains an audio band that switches between a waveform and a log-mel spectrogram, on the same clock as everything else. |
None
|
start_s
|
float
|
Where in the session the page begins, in seconds. The page
then covers |
0.0
|
player
|
str
|
RELATIVE name of a video file to play above the strips --- for example the proxy that ships in the same folder as the page. Clicking the timeline seeks the video, and a playhead runs across every band during playback. A relative name on purpose: the page stays serverless and needs only the folder it ships in, and it degrades to the strips alone when the file is not beside it. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Path |
The file written. |
Source code in musicalgestures/_zoomview.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | |
mg_zoompage ¶
mg_zoompage(self, target_name=None, overwrite=True, max_points=8000, which='videogram_v')
The zoomable page for this recording, in one call, as a method.
Everything derives from the video itself. The motion track and gram come from
extract_tracks, computed on first call and cached beside the video like every
other analysis; the audio band comes from the video's own soundtrack when it has
one; and the player is the video, referenced by its bare name, so the page works
from the folder the two share and needs no server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target_name
|
str
|
Output path. Defaults to "_zoom.html" beside the video. |
None
|
overwrite
|
bool
|
Overwrite or auto-increment. Defaults to True. |
True
|
max_points
|
int
|
Ceiling on embedded envelope points. |
8000
|
which
|
str
|
Which cached gram to embed as the strip. |
'videogram_v'
|
Returns:
| Name | Type | Description |
|---|---|---|
Path |
The file written. |
Source code in musicalgestures/_zoomview.py
446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 | |