Visual grids, images and video
Lay out inline visuals in rows and add still images or silent video to a score.
Requires 1.9.0. Save a score, enable Inline visuals in the toolbar, and press Play after entering the example. The first example uses only built-in sounds.
Arrange inline visuals
With Inline visuals enabled, end a pipeline with viz_grid(2) to put two visuals side by side. Give one count for each row: viz_grid(2, 3) puts the first two visuals in the top row and the next three beneath them, in pipe order.
let bass = [C2 _ G2 Eb2] |> saw |> lowpass(850, 0.26)
play bass
|> waveform() |> amplitude()
|> spectrogram() |> pitch_ribbon() |> cymatics()
|> viz_grid(2, 3)Use positive whole numbers whose sum matches the number of local visuals in the group. Each row fills the editor width, with equal space for each cell in that row. Collapse folds the whole grid. Count only the local visuals written on this pipeline before the grid call. Visuals on a reused definition keep their original location, and global visuals keep their overlay. With inline visuals switched off, each local visual appears separately in the Visualizations panel.
Try swapping the row counts to viz_grid(3, 2) and evaluate. The spectrogram moves from the start of the second row to the end of the first. The bass keeps the same sound.
Images and silent video
Place artwork or a looping clip beside your music. A standalone call creates an
inline visual at that line. You can also attach media to a track or the master
mix, combine it with other views using viz_grid, or use global: true for the
overlay below the toolbar.
For this example, create an art folder beside the score and put your own cover.png and night-loop.mp4 inside it.
image("./art/cover.png")
video("./art/night-loop.mp4", global: true)
play [C2 _ G2 _] |> saw |> gain(0.2) |> waveform() |> image("./art/cover.png") |> viz_grid(2)Relative paths start in the folder containing the .sanic file. Save the score
first, or supply an absolute local path. PNG and JPEG work for stills. H.264
MP4 is a good choice for video on macOS.
The default fit: "cover" fills the view by cropping the edges. Use
fit: "contain" to keep the whole frame at its original proportions. Set
fill: true to stretch the whole frame to the width and height of the view.
This overrides fit for both images and videos. Set opacity from 0 to 1 to
blend the media with the content underneath, for example
video("./art/night-loop.mp4", global: true, opacity: 0.4).
Videos loop during playback and pause with the transport. Use loop: false to play
once and hold the final frame. Embedded audio stays silent, including in audio
exports. Missing media displays an error in its view while the score plays.