Skip to content

Instantly share code, notes, and snippets.

@Dillie-O
Created March 15, 2016 23:14
Show Gist options
  • Save Dillie-O/a5b1e9a38739341c3d76 to your computer and use it in GitHub Desktop.
Save Dillie-O/a5b1e9a38739341c3d76 to your computer and use it in GitHub Desktop.
Sonic Pi Octal Conversion
# Strip . from Pi
piValue = "3141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306647093844609550582231725359408128481117450284102701938521105559644622948954930381964428810975665933446128475648233786783165271201909145648566923460348610454326648213393607260249141273724587006606315588174881520920962829254091715364367892590360011330530548820466521384146951941511609"
piOctal = piValue.to_i(10).to_s(8)
piArrayRaw = piOctal.to_s.split(//)
piDigits = piArrayRaw.size
print "PI: " << piValue << "\n"
print "PI Octal: " << String(piOctal) << "\n"
print "PI Digit Count: " << String(piDigits) << "\n"
# Configure scale
notes = (scale :Bb3, :minor, num_octaves: 1)
#Play pi
use_synth :sine
i = 0
piDigits.times do
play notes[Integer(piArrayRaw[i])]
sleep 0.33
i = i + 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment