-
Notifications
You must be signed in to change notification settings - Fork 5
Enumerables
Enumberables are something that can be calculated and played on the fly (which is more fun). Ziffers has some built in methods for calculating sequences such as continued fractions of Pi or triangular sums.
You can also create your own number sequences, so if you happen to know a mathematic formula for creating the perfect melody it is relatively easy to try it out :)
Number sequences are any number of numbers that creates a finite or infinite sequence.
Consider a number 369420. This number can be played sequantially as a melody or concurrently as a chord. It can also be played in any key or scale and added some rhythmic variation based on taste or some mathematical relations between the numbers.
Then consider a sequence of numbers 6 18 54 162 486 1458 4374. These numbers again could be played in different ways. These sets of numbers can also be transformed, added, divided, etc. and the base of the numbers can be changed for example from 10 to 6. Number sequences can also be considered as a string that can be modified with rules.
Examples of combining rhythm with the number sequences:
zplay pi, rhythm: "|: eeqq :| h q q |: q e e q q:|"
zplay reverse_sum(589865754), groups: false, lengths: {0=>"q", 1=>"e",2=>"e",3=>"q",4=>"e",5=>"q",6=>"q", 7=>"q",8=>"e",9=>"q"}
Custom enumerables can be created using Ruby's enumerations.
There couple of ways of creating enumerations. Using ranges and lazy enumerations:
# To infinity and beyond!
sums = (1..Float::INFINITY).lazy.collect {|x| (x*x)}
zplay sums, groups: false, sleep: 0.125
Or by creating enumerations using Enumeration class:
def awesomeness(n=6,variance=3)
mem = [rrand_i(0,7)]
Enumerator.new do |y|
until mem.length>=n do
mem = mem.zip(mem.map{|n| n+rrand_i(-variance, variance)}).flatten
y << mem.join(" ")
end
print "Reached the end of enum!"
end
end
# Loop cycles the finite enumerations
z1 awesomeness, rhythm: "|: h q q :|: h h :|", synth: :dark_ambience
There are many beautiful and intrigue integer sequences with musical properties out there. Best place to search for them is OEIS encyclopedia using hear keyword.
Here is a list of sequences as easy to use enumerations:
Sequence in OEIS: A000045
# Play fibonacci numbers as chords
zplay fibonacci, sleep: 0.25
Sequence in OEIS: A000040
# Play primes as chords until 500
zplay primes(500), sleep: 0.25
# Play primes as chords until memory runs out
zplay primes, sleep: 0.25
# Play recaman sequence as chords
zplay recaman, sleep: 0.25
Sequence in OEIS: A005185
zplay hoffQ, sleep: 0.25, groups: false, scale: :minor, rhythm: "|: eeq :| q q |: q ee :|"
Sequence in OEIS: A002487
zplay sterns, sleep: 0.25, scale: :harmonic_minor
Sequence in OEIS: A001316
zplay dress, synth: :chipbass, key: :d3, scale: :minor_pentatonic, rhythm: "eeqh"
Sequence in OEIS: A000265
zplay frac2, sleep: 0.25
Sequence in OEIS: A030101
Optional parameter base, default=2.
zplay binrev, sleep: 0.25
Reverse sum of some numbers creates symmetric patterns. Idea from MathPages.
Optional parameter base, default=10
zplay reverse_sum(313), synth: :fm, groups: false, rhythm: "q q h"
Collatz conjecture will create a number sequence that will eventually lead to 1.
zplay (collatz 987654321), groups: false, rhythm: "qqeeee"
Sequence in OEIS: A000217
# Plays chords from triangular number sequence
zplay triangular, sleep: 0.25
# Play values of y as chords
z1 quadratic(1,100,1,-10,20), sleep: 0.2
Create your own Arithemitc progression.
zplay aprog(1,4,5), sleep: 0.25
print "Done!"
# This one goes forever
zplay aprog(1,4), sleep: 0.25
Create your own Geometric progression.
zplay gprog(3,4,5), sleep: 0.25
print "Done!"
# This one goes forever
zplay gprog(3,4), sleep: 0.25
Infinite Continued fraction is a number sequence like pi or square root of 2. Continued fractions can be calculated using for example general infinite continued fraction algorithm, which was used for enumerables pi, phi and euler.
Everybody loves π. Now you can listen to it forever (or until your computer crashes).
Sequence in OEIS: A000796
zplay pi, rhythm: [0.125,0.125,0.25]
Sequence in OEIS: A001622
zplay phi, rhythm: "|: q q e e q :| h q q |: h q ee :|"
Sequence in OEIS: A001113
zplay euler, sleep: 0.25
------------------------------------ See more stuff from the menu --------------------------------------->