watilde / beeplay

Write a song in JavaScript
http://watilde.github.io/beeplay
MIT License
1.04k stars 54 forks source link

Better Chaining: play should return a reference to itself. #6

Open JAStanton opened 10 years ago

JAStanton commented 10 years ago

Something like this http://codepen.io/JAStanton/pen/inoBb

var intro = beeplay({bpm: 120}).play(null, 2)('D#5', 1/4)('E5', 1/4);
JAStanton commented 10 years ago

Actually looking at your source I see what you're doing and why. Maybe make an alias function called p or something that calls into play?

beeplay(...).p(...)(...);

or

beeplay(...)(...)(...);

Though I understand this might be a bit limiting

watilde commented 10 years ago

Hello :smiley_cat: I play to change like this:

var obj = [['C4', 1/4], ['D4', 1/4], ['E4', 1/4]];
var obj2 = [['E4', 1/4], ['F#4', 1/4], ['G4', 1/4]];

var b = beeplay({key: 'C', bpm: 120})
  .play(obj)
  .set({'key': 'Em', bpm: 80})
  .play(obj2);

Writing play chain will a way to do debug.