I took the 108 basic beeps and assigns them to the 27 words in the English Latin alphabet with intervals of 3. Starting A at 30 and therefor Z is 105. I then made functions for each of the words and now if I want to hear, for example, “Hello World” I write it up like
[h, e, l, l, o]
sleep 0.5
[w, o, r, l, d]
Is there a closer way to writing it without the [ and commas? I would like to write it closer to how we write–this message as an example. Any ideas would be very much appreciated!
WOW!!! This is amazing! Thanks for the help. I am new to Sonic Pi and was wondering if you could somehow walk me through it… Is :beepit a predefined function that you are calling? I am not sure of how all the code is structured. Any links to references or definitions can help me out. Thank you so much for your time and help, really appreciate it
:beepit is not a pre-defined function. In Sonic Pi terms,
define :beepit do
[...]
end
is what defines such a function. It takes 1 argument, which is supposed to be a string like "hello", then it chops it up into an array of characters, converts each one to a number, and passes the resulting array to the built-in function play.
On a separate line, we take a string like "hello there" and split it into words using the built-in split method, and play each one of those using the function we just defined. Note that punctuation has not been taken into account.
Not claiming this is the epitome of computer science; obviously there are more elegant ways to structure this. Sonic Pi actually runs a Ruby interpreter, if you are familiar with that.
If you have any questions, please do not hesitate to ask!
Thank you so much for explaining it, I have been fidleing around with it for two days and very interesting explorations have come up… I duplicated the function with diferent input to create paragraphs.
At the moment I am figuring out how to change the “instrument”… I see scale is at the end of the play function, but cant seem to change it to sound less harmonious… more synth… eventhough I add synth filters in and out of the :beepit loop. Could you give me some light into this?
Can you explain what you mean by “less harmonious”? Would it be enough to change the synth used, which you can do by inserting a couple of lines, e.g.:
define :beepit do |s|
play s.chars.map {|c| c.upcase.ord-"A".ord+30+12 }
end
use_synth :piano
use_synth_defaults vel: 0.5, hard: 0.7
sss = "hello there Sonic Pi"
sss += " let us make the string longer"
sss.split.each { |s| beepit s; sleep 0.5 }
Or do you mean to change the scale used from a equally-tempered 12-tone scale to one that maximizes the perceived dissonance? That requires a bit of thought, but for some quick sourness you could change the definition of :beepit to something like
define :beepit do |s|
play s.chars.map {|c| c.upcase.ord-"A".ord+30+12+rrand(-0.5,0.5) }
end