# Sonification of Euler's number e 2.7183

Inspierd by the thread on sonifying sorting routines I played this afternoon with a sonification of Euler’s number e. This irrational numbercan be worked out with increasing precision using Ruby’s BigMath routines. I increase the precision from 1 up to 60 and use the resulting number string as an index into a two octave minor-pentatonic scale. I read the string from each end to produce two notes which are chosen by a spread function, and also some additional rhythm is added using the density fucntion. The whole is played over a layered base drone, which is constantly refreshed, and slowly builds as the not strings get longer.

The result can be hear dbelow

code:

``````#sonification generated by the number E with steadily increasing precision
#from 1 to 60, written by Robin Newman, Dec 2023
#The number is generated by BigMath.E(precision)
#I use each digit as a lookup index into a minor pentatonic scale
#I read the digits from each end of the current number, and play
#one of the two resulting notes, selected by a density funtion and a spread function
#which gives a bit of rhythm.
#These notes are underpinned by a base drone, which is layered as it has a longer
#release time and is generated increasingly as the base E string gets longer

#The idea for this was sparked from an interesting StackOverflow question
#https://stackoverflow.com/questions/28222394/how-to-get-the-nth-place-of-pi-using-ruby-bigmath

use_debug false
use_synth_defaults amp: 0.3
require "bigdecimal/math"
define :e do |prec|
return "2" if prec==1
return BigMath.E(prec).to_s[2..-3]
end

define :pent do |offset|
return scale(:e3,:minor_pentatonic,num_octaves: 2)[offset.to_i]
end

with_fx :reverb, room: 0.6,mix: 0.6 do
k=0
for i in (1..60) do
base=[0,-5,7].choose
if e(i).length >k #only play if length increased
k=e(i).length
puts "E digits: (#{i}) #{e(i)}"
k.times do |x| #iterate through notes from pent lookup of E string
#play layered drone which will build in volume
synth :bass_foundation,note: pent(7)-36+base,release: (k-1)*0.1,amp: 0.2
#use density and sporead for some rhythm
density dice(2) do
tick
#play notes starting at different ends of current E string
synth :tb303,note:  base+pent(e(i).reverse[x]),release: 0.2,pan: -0.5,cutoff: rrand_i(80,110) if spread(5,8).look
synth :tb303,note: base-12+ pent(e(i)[x].to_i),release: 0.2,pan: 0.5,cutoff: rrand_i(80,110) if !spread(5,8).look
sleep 0.2
end
end
end
sleep 0.2
end
end#reverb
``````
5 Likes