Repository Public
1// ORIX Sonata2// File: Examples/rh_metric_modulation.sonata3// Description: A metric modulation: the triplet eighth of the old tempo becomes the eighth of the new one (90 to 135 bpm), then the dotted quarter becomes the quarter on the way back.4//5// Author: Simon-Pierre Boucher6// Contact: contact@spboucher.ai7//8// category: Rhythm9// title: Metric Modulation10// teaches: tempo changes inside a track, tuplets, exact tempo ratios11//12// expect: notes 12013// expect: tracks 214// expect: duration 26.2222s15// expect: deterministic16composition "Metric Modulation" {17 tempo 90bpm18 key A minor1920 instrument marimba: Marimba {21 gain -4dB22 // Straight eighths at 90.23 repeat 2 {24 for n in [A3, C4, E4, A4, G4, E4, C4, B3] {25 play n duration 1/826 }27 }28 // Triplets prepare the new pulse: three in the time of two.29 repeat 2 {30 tuplet 3 in 2 {31 for n in [A3, C4, E4, A4, G4, E4, C4, B3, A3, C4, E4, A4] {32 play n duration 1/833 }34 }35 }36 // The triplet eighth becomes the eighth: 90 x 3/2 = 135.37 tempo 135bpm38 repeat 2 {39 for n in [A3, C4, E4, A4, G4, E4, C4, B3] {40 play n duration 1/841 }42 }43 // Groups of three eighths prepare the return: 135 x 2/3 = 90.44 repeat 2 {45 for n in [A3, E4, C4, G4, E4, B3, A3, E4, C4, G4, E4, B3] {46 play n duration 1/8 velocity if n == A3 or n == G4 then 0.9 else 0.547 }48 }49 tempo 90bpm50 for n in [A3, C4, E4, A4, G4, E4, C4, B3] {51 play n duration 1/852 }53 play [A2, A3] duration 1/154 }5556 instrument click: ClosedHat {57 gain -16dB58 // The click keeps the quarter note of whatever tempo is in effect.59 repeat 8 {60 play F#2 duration 1/461 }62 tempo 135bpm63 repeat 14 {64 play F#2 duration 1/465 }66 tempo 90bpm67 repeat 8 {68 play F#2 duration 1/469 }70 }71}72