Self-modifying algorithms

I think the issue is a bit overblown. When @Eli posted that the piece presented sounded ‘soulless’ to him, he didn’t want to offend any person. He talked about his impressions regrading a piece of code and that’s ok for me. Also, he contributed his version of the piece to demostrate what could be improved.

I can also understand that our latest attempts to explore the limits in the sky for Sonic Pi is interesting to some but not to all of the members (like turning math formulas into sound or make a Git repo playing piano). And the feedback from people having their roots in solid deep/hardcore/… house is always valuable because this makes you reflect about what you are doing.

Last but not least @Eli also expressed his respect for the people doing this hard-to-understand-stuff, see e.g. this post.

So, my proposal is to continue our very enriching discussion, accept critical remarks as long as they are not adressed to the people but pieces of music offered for discussion in the forum.

Finally, I think for many people being a member in such a lovely forum as this one and being a creative SPi musician helps to cope with problems in live outside. We should not easily use the flag mechanism or even kick people out.

2 Likes

To be really clear here - nobody has been kicked out and the flag mechanism is very important for people to share their concerns about specific posts and it’s important to me that people feel they can do just that.

All I have attempted to do is to communicate that in this case it was possible that the intention of the post could have been misinterpreted with a hope that this can be avoided in the future.

I agree that everyone’s voice is important but we should also strive to be positive and constructive wherever possible and that is something I will continue to seek to emphasise.

I do really hope that some point in the future @Eli will choose to return. He is most definitely a valued member of these forums and I have enjoyed his contributions.

4 Likes

I was not offended and did not flag this or any post. To me soulless means absolute, as I mentioned before. I live to disagree and music does not have to be ‘melodius’ and things should not be taken so seriously :man_shrugging:

2 Likes

I don’t mean to interject, but after listening, I don’t think anyone is in the wrong. I’ll add that I’m okay with what @Eli said if @Nechoj and @amiika are okay (which they are) since it wasn’t a critique of my work. A critique of my work wouldn’t warrant a flag from me unless it were exceptionally mean-spirited. Thankfully the culture here is really positive.

If how to be kind were rigorous, then typing this wouldn’t have taken an hour ><

Anyways, I hope that @Eli’s doing okay. :frowning:

2 Likes

Thanks for extending this idea. Here’s a few suggestions to the implementation. If you use map and join instead of each and append you don’t have to struggle with those spaces:

use_debug false
rules = {
  /(0)+/ => ->{[0, 0, 1].choose.to_s},
  "1" => "2",
  "2" => "4 5 6",
  /([4-7])/ => "8",
  "8" => "9",
  /(9)+/ => ->{["0", "x", "x"].choose},
  /(x)+/ => "0",
}

melody = "0"

def rewrite(axiom, rules)
  axiom.gsub(Regexp.union(rules.keys)) do |m|
    v = rules.to_a.detect{|k, v| Regexp.union(k) =~ m}[1] # Hack for regexp keys
    v.respond_to?(:call) ? v.call : v # Hack for lambda calls
  end
end

define :modify do |mel, slice, i|
  puts mel
  mel = mel.split(" ")
  l = mel.length
  i = i%l
  
  left = i;
  right = [i + slice - 1, l - 1].min;
  
  axiom = mel[left..right].map {|m| m }.join(" ")
  
  result = rewrite(axiom, rules)
  puts axiom+" => "+result
  
  melc = result.split(" ")
  if right+1 < l
    res = left > 0 ? mel[0..left-1] : []
    res += melc
    res += mel[right+1..-1]
  else
    res = left > 0 ? mel[0..left-1] : []
    res += melc
  end
  
  return res.join(" ")
end

use_synth :pluck
use_synth_defaults release: 2.5, coef: 0.3
sca = scale :D3, :melodic_minor_asc, num_octaves: 3

with_fx :reverb, mix: 0.4 do
  with_fx :flanger, wave: 3, depth: 7, decay: 2 do
    live_loop :lindenmayer do
      melody.split(" ").each do |s|
        play sca[s.to_i] unless s == "x"
        sleep 0.25
      end
      melody = modify(melody, 2, 2*tick)
      puts melody
    end
  end
end

Also added debug printing which shows wtf is going on with the slices :slight_smile:

1 Like

Great! I wasn’t aware there is a join function in ruby. One thing that’s a bit strange in this modify function is the line i = i%l. Because the function changes the length of the melody string, on the next iteration you might get a quite unexpected index i. This caused me some headaches, but no idea whether this can be improved or compensated for. In effect, this can result in repeating the string replacement on the same slice again.

Hmm, right. You could do something like this instead:

use_debug false
rules = {
  /(0)+/ => ->{[0, 0, 1].choose.to_s},
  "1" => "2",
  "2" => "4 5 6",
  /([4-7])/ => "8",
  "8" => "9",
  /(9)+/ => ->{["0", "x", "x"].choose},
  /(x)+/ => "0",
}

melody = "0"

def rewrite(axiom, rules)
  axiom.gsub(Regexp.union(rules.keys)) do |m|
    v = rules.to_a.detect{|k, v| Regexp.union(k) =~ m}[1] # Hack for regexp keys
    v.respond_to?(:call) ? v.call : v # Hack for lambda calls
  end
end

use_synth :pluck
use_synth_defaults release: 2.5, coef: 0.3
sca = scale :D3, :melodic_minor_asc, num_octaves: 3

with_fx :reverb, mix: 0.4 do
  with_fx :flanger, wave: 3, depth: 7, decay: 2 do
    live_loop :lindenmayer do
      slices = []
      melody.chars.each_slice(3) do |slice|
        result = rewrite(slice.join(""),rules)
        puts slice.join("") +" => "+result
        result.split(" ").each do |s|
          play sca[s.to_i] unless s == "x"
          sleep 0.25
        end
        slices.push(result)
      end
      melody = slices.join("")
      puts melody
    end
  end
end

But isn’t those small inconsisties just what makes the piece unique? :slight_smile:

1 Like

Btw, here’s a list of ideas and variations on L-systems (quite lengthy masters thesis but many cool ideas). Using bracketed syntax you create some polytonal melodies or use another ruleset to change the original ruleset (which would be quite a :exploding_head:)

1 Like

Wow, this field seems to have attracted quite some researchers already. I like this image on the compositional environment very much

You’re right. It just makes me a bit nervous when the system does those unplanned things :roll_eyes: Controlling the chaos is better …

this threat is awesome ! i mean, we find here everything, about everything in our everyday´s life of “synthetic” music experiment :wink: i am aware of all of this, because we are on internet, and things can appears weird, but mates, this is what we are, researcher, experimenters… far from classical music industry or education… and this is why we do live coding, i suppose :clock9:
thanks to all of you, who share, teach, and create… this is awesome ! Love

have a great day
uriel

Hi @amiika , this sounds very interesting, but the link is down. Could you please send a new link so I could have a look at this? Thanks and cheers!

You can find the thesis also from here: Musical L-systems | Stelios Manousakis (modularbrains.net)

L-system is also implemented in Ziffers: Rules · amiika/ziffers Wiki (github.com). In combination with the generative syntax it can be used to do all that and much more.

1 Like