Skip to content

Supportive

Miika Alonen edited this page Oct 29, 2022 · 6 revisions

debug

Get informative debug messages. Example:

Ziffers.debug
zplay "0 1 2 3", store: true, swap: ->(i){i}

durations

Get list of parsed durations

melody = zparse "q 1 3 4 5 h 2 1"
print melody.durations

beats

Get list of parsed beats

melody = zparse "q 1 3 4 5 h 2 1"
print melody.beats

measures

Get list of measures

melody = zparse "1 2 3 | 2 3 4 | 3 4 5"
print melody.measures
print melody.measures[0].durations
print melody.measures[0].duration
print melody.measures[0].duration_in_beats

zlog

This logs in "~/.sonic-pi/log/ziffers.log" where the other Sonic Pi's logs usually are. Nice for debugging and exporting bigger stuff.

a = zparse 34567
zlog(a) # Logs json array

zarray

Parses integer degree arrays to hash arrays

print zarray [1,2]
# [{:key=>:c, :scale=>:major, :release=>1.0, :duration=>0.25, :pitch=>0.0, :amp=>1, :pan=>0, :amp_step=>0.5, :note_slide=>0.5, :control=>nil, :skip=>false, :pitch_slide=>0.25, :note=>60}, {:key=>:c, :scale=>:major, :release=>1.0, :duration=>0.25, :pitch=>0.0, :amp=>1, :pan=>0, :amp_step=>0.5, :note_slide=>0.5, :control=>nil, :skip=>false, :pitch_slide=>0.25, :note=>62}]

zgen

TODO: Write documentation

Using ziffers with Sonic Pi methods

Ziffers is meant to provide easy way to write and experiment with melodies. By zparams you can easily use ziffers with other Sonic Pi methods such as play_pattern_timed. When using standard methods, remember to combine pitch to notes by transposing the arrays.

Example of using Ziffers with default Sonic Pi methods:

use_synth :piano

ievanpolka = "[: q 0 e0 e0 0 1 | 2 0 0 2 <(1 -1 -1 1 | 2 0 h0) (q.4 e3 2 1 | 2 0 h0)> :]"\
  "[: 4 e4 e4 3 2 | 1 -1 -1 1 <(3 e3 e3 2 1 | 2 0 0 2) (3 e3 e3 2 1 | 2 0 h0)> :]"

n = zparse(ievanpolka,{key:"C", scale:"minor"})
notes = n.notes
durations = n.durations

play_pattern_timed notes, durations

Look under examples to see other ways to use zparse and other Sonic Pi projects, such as Markov chains.

Clone this wiki locally