Guest User

Untitled

a guest
Apr 24th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. //create a synth and connect it to the master output (your speakers)
  2. var synth = new Tone.Synth().toMaster();
  3.  
  4. //Thank you W3.org
  5.  
  6. function dotin(note, time, when) {
  7. return synth.triggerAttackRelease(note, time, when);
  8. }
  9.  
  10. function rythm(beat, repeat) {
  11. count = 0;
  12. num = 7;
  13. tune = "" + num + "n";
  14.  
  15. if(beat == null){
  16. bits = 1;
  17. }
  18.  
  19. do{
  20. dotin("G4", tune, 1.2 + count * beat);
  21. dotin("C3", tune, 2 + count * beat);
  22. dotin("A3", tune, 2.3 + count * beat);
  23. dotin("G3", tune, 3 + count * beat);
  24. count = count + 1;
  25. } while (count < repeat);
  26. }
  27.  
  28.  
  29. // rythm();
  30.  
  31. // beat repeats a note, rythme, or sound a number of times.
  32.  
  33. function beat(beats, beat) {
  34. bit = 1;
  35. do {
  36. bit = bit + bit;
  37. rythm(beats, beat);
  38. }
  39. while (bit < beats);
  40. }
  41.  
  42. beat(3, 5);
Add Comment
Please, Sign In to add comment