generate.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. this.clickEventMethod = function() {
  2. this.synth.triggerAttackRelease(['C4'], ['8n'], 0.3);
  3. }
  4. this.doButtonTriggerdownAction = function(buttonID){
  5. let transportNode = this.find('//' + 'globalTransport')[0];
  6. if(this.playButton.displayName == "playButton"){
  7. //this.transportLine.playing
  8. this.globalBeat = this.globalBeat? false : true;
  9. if(this.globalBeat){
  10. this.playButton.baseColor = 'red';
  11. this.playButton.textNode.value = 'Stop'
  12. if(!transportNode.playing)
  13. transportNode.play()
  14. } else {
  15. this.playButton.baseColor = 'green';
  16. this.playButton.textNode.value = 'Play'
  17. }
  18. }
  19. }
  20. this.initialize = function(){
  21. this.playButton.init();
  22. }
  23. this.onGlobalBeat = function (obj) {
  24. //dispatch the beat example send OSC
  25. let transportNode = this.find('//' + obj.name)[0];
  26. let rate = transportNode.animationRate; // 1 by default
  27. let drumSeq = this.seq;
  28. // [
  29. // { beat: 0, msg: "C0" },
  30. // { beat: 15, msg: "C0" }];
  31. drumSeq.forEach(el => {
  32. if (el.beat / rate == obj.beat) {
  33. this.synth.triggerAttackRelease([el.msg], ['16n']);
  34. }
  35. })
  36. }