SPB Git

Repository Public

tide_sonification.sonata 1.9 KB 57 lines

1// ORIX Sonata2// File: Examples/tide_sonification.sonata3// Description: Sonification of a tide table: water height becomes pitch on a vibraphone, the rate of change becomes loudness, and high water is marked by a bell.4//5// Author: Simon-Pierre Boucher6// Contact: contact@spboucher.ai7//8// expect: notes 399// expect: tracks 210// expect: duration 16.3636s11// expect: deterministic12// Water height in centimetres every hour for a day and a half (an illustrative series).13const heights = [120, 168, 221, 262, 280, 271, 236, 184, 131, 92, 76, 88, 126, 180, 237, 283, 305, 297, 262, 208, 150, 104, 82, 90, 124, 175, 230, 272, 291, 283, 248, 196, 142, 98, 78, 86]1415fn scaled(x: Number, lo: Number, hi: Number) -> Number {16    return (x - lo) / (hi - lo)17}1819composition "Tide Sonification" {20    tempo 132bpm21    key D mixolydian2223    let lo = min(heights)24    let hi = max(heights)25    let notes = scale_run(D3, mixolydian, 2)2627    instrument water: Vibraphone {28        gain -6dB29        // The whole day sweeps once across the stereo field.30        automate pan {31            0bars: -0.732            9bars: 0.733        }34        for i in 0..len(heights) {35            let t = scaled(heights[i], lo, hi)36            // Loudness follows how fast the water moves between two readings.37            let change = if i == 0 then 0 else abs(heights[i] - heights[i - 1]) / 6038            play notes[round(t * (len(notes) - 1))] duration 1/4 velocity clamp(0.35 + change * 0.6, 0.3, 1)39        }40        effects {41            reverb plate(mix: 0.25)42        }43    }4445    instrument high_water: TubularBells {46        gain -12dB47        for i in 1..len(heights) - 1 {48            // A local maximum of the series.49            if heights[i] > heights[i - 1] and heights[i] > heights[i + 1] {50                play D5 duration 1/451            } else {52                rest 1/453            }54        }55    }56}57
Files main
Menu

Theme