Last active
December 13, 2022 06:03
-
-
Save nischalshrestha/08df0c6b635e78a5bf16eb320d9d74f3 to your computer and use it in GitHub Desktop.
Sonic Pi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################## | |
# THX logo sound # | |
################## | |
# THX revealed their sound logo here: https://twitter.com/THX/status/1000077588415447040/photo/1 | |
# beginning random notes in the 200-400Hz | |
# you can play around with how many intervels you want in the | |
# 200 to 400hz range, I found 20 to be nice | |
interval = 10 | |
# hz_to_midi() conveniently converts hz to midi notes | |
# so you can make a range() and pick a random Hz to convert to midi | |
random_notes = [ | |
hz_to_midi(range(200, 400, steps: interval).choose), | |
hz_to_midi(range(200, 400, steps: interval).choose), | |
hz_to_midi(range(200, 400, steps: interval).choose), | |
hz_to_midi(range(200, 400, steps: interval).choose), | |
hz_to_midi(range(200, 400, steps: interval).choose), | |
hz_to_midi(range(200, 400, steps: interval).choose), | |
hz_to_midi(range(200, 400, steps: interval).choose), | |
hz_to_midi(range(200, 400, steps: interval).choose), | |
hz_to_midi(range(200, 400, steps: interval).choose), | |
hz_to_midi(range(200, 400, steps: interval).choose), | |
hz_to_midi(range(200, 400, steps: interval).choose) | |
] | |
# these are the target notes for the final chord | |
thx_chords = [:d1, :d2, :a2, :d3, :a3, :d4, :a4, :d5, :a5, :d6, :fs6] | |
# you can play with how long you want notes to sustain | |
# overlapping decaying notes can sound very cool! | |
sustain_amt = 8 | |
# storing a synth allows us to play it and control its parameters | |
# we are trying to control the note_slide because this will transform | |
# the intial random notes to the target THX sound notes | |
thx = synth :saw, amp: 1.5, notes: random_notes, note_slide: sustain_amt, | |
sustain: sustain_amt + 4, cutoff: 40, cutoff_slide: sustain_amt, | |
attack: 0.05, release: sustain_amt / 2 | |
# finally use control to map the notes from thx (random initial notes) to the thx_chords (final destination) | |
# move cutoff from 40-120 as well so we ease in | |
control thx, notes: thx_chords, cutoff: 120 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment