transportLine.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. this.initialize = function(){
  2. //this.run();
  3. }
  4. this.fromhitstartEventMethod = function(value){
  5. let synth = this.parent.synth;
  6. let scene = this.getScene();
  7. let notes = value.map(el=>{
  8. let node = scene.findNodeByID(el);
  9. node.synth = synth.id;
  10. //let note = Tone.Frequency(node.worldPosition().y*150).toNote();
  11. //node.note.note = note;
  12. return {
  13. freq: node.note.note,
  14. velocity: node.radius,
  15. duration: node.height//node.note.duration,
  16. }
  17. })
  18. if(notes.length == 1){
  19. let note = notes[0];
  20. //synth.triggerAttack(note.freq, note.velocity);
  21. synth.triggerAttackRelease([note.freq], [note.duration], note.velocity);
  22. } else if (notes.length > 0){
  23. let chord = notes.map(el=>{
  24. return el.freq
  25. })
  26. let durations = notes.map(el=>{
  27. return el.duration
  28. })
  29. let velocity = notes[0].velocity;
  30. synth.triggerAttackRelease(chord, durations, velocity);
  31. // synth.triggerAttack(chord, velocity); //, durations
  32. }
  33. }
  34. this.fromhitendEventMethod = function(value){
  35. //console.log(value)
  36. }
  37. // this.stop = function(){
  38. // this.animationLoop = false;
  39. // this.position = [0,1.5,0];
  40. // }
  41. // this.play = function(){
  42. // this.animationLoop = true;
  43. // this.translateBy([5,0,0],1);
  44. // }
  45. // this.run = function(){
  46. // if(this.playing){
  47. // this.translateTo([this.end, 0, 0],this.delta - 0.1);
  48. // this.future(this.delta).position = [0,1.5,0];
  49. // }
  50. // this.future(this.delta).run();
  51. // }