Barnard-PL-Labs / SequencerLiveCoding

Live Coding for the Novation Circuit
19 stars 5 forks source link

add reorganize button #15

Open santolucito opened 2 years ago

santolucito commented 2 years ago

It can get difficult to keep track of all the tracks one is controlling at the same time. It would be nice to have a "reorganize" button that rearranged the code so that all lines of code that affected a particular track number were next to each other. For example

turn this code:

function genBeat(b, s, currentTimestep){

  b.track1vol = pattern((val,i) => 1 - (i % 2));
  //b.track1vol.splice(3,13,...Array(13).fill(0));
  b.track1dur = pattern((val,i) => 1);
  b.track6vol = pattern((val,i) => 1 % (2 - (i % 4)));
  //b.track6vol.splice(9,7,...Array(7).fill(0));

  b.track4dur[2] = 4;
  b.track3dur[6] = 3;
  b.track3vol = pattern((val,i) => 1 % (6 % (i - 2)));
  b.track3vol.splice(10,6,...Array(6).fill(0));
  b.track6dur = pattern((val,i) => (i+4) % 3);
  s.track6_thumb = 1 //currentTimestep/16;

  s.track4_thumb = Math.random()*0.3 + 0.7;
  return {beat:b, sliders:s};
};

into this code

function genBeat(b, s, currentTimestep){

  b.track1vol = pattern((val,i) => 1 - (i % 2));
  //b.track1vol.splice(3,13,...Array(13).fill(0));
  b.track1dur = pattern((val,i) => 1);

  b.track3dur[6] = 3;
  b.track3vol = pattern((val,i) => 1 % (6 % (i - 2)));
  b.track3vol.splice(10,6,...Array(6).fill(0));

  b.track4dur[2] = 4;
  s.track4_thumb = Math.random()*0.3 + 0.7;

  b.track6dur = pattern((val,i) => (i+4) % 3);
  s.track6_thumb = 1 //currentTimestep/16;
  b.track6vol = pattern((val,i) => 1 % (2 - (i % 4)));
  //b.track6vol.splice(9,7,...Array(7).fill(0));

  return {beat:b, sliders:s};
};
santolucito commented 2 years ago

probably this string manipulation should go here:

https://github.com/Barnard-PL-Labs/SequencerLiveCoding/blob/dda548599351d484b8ba0af15fb7432fc328a21d/serverSide/synthesizer.js#L129

santolucito commented 2 years ago

i think someone was working on this, but I don't remember who...