tidalcycles / strudel

Web-based environment for live coding algorithmic patterns, incorporating a faithful port of TidalCycles to JavaScript
https://strudel.cc/
GNU Affero General Public License v3.0
579 stars 105 forks source link

hmap #1087

Open felixroos opened 1 month ago

felixroos commented 1 month ago

maybe useful: https://strudel.cc/?uk6-NJt-PwEY

Pattern.prototype.hmap = function(fn, pat){
  return this.arpWith(haps => stack(...haps.map((h,i) => h.withValue((v) => fn(v,i,haps)))))
}

let colors = ['cyan','magenta','yellow']

note("c,e,<g a bb a>")
  .hmap((v,i,h) => ({...v, color: colors[i] }))
  ._pianoroll()