Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.42 KB | None | 0 0
  1. <html>
  2. <head>
  3. <script src="lib/flocking/dist/flocking-all.js"></script>
  4. <style>
  5. body{
  6. padding: 0;
  7. margin: 0;
  8. }
  9. #meter{
  10. box-sizing: border-box;
  11. position: fixed;
  12. bottom: 0;
  13. left: 0;
  14. border: 3px solid grey;
  15. border-radius: 15px;
  16. width: 100%; //fallback
  17. width: 100vw;
  18. height: 75px;
  19. }
  20. </style>
  21. </head>
  22. <body>
  23. <input type="checkbox" id="starter" name="starter"><span >start audio</span>
  24. <script>
  25. document.getElementById('starter').onclick= function(){
  26. if (this.checked){
  27. flock.webAudio.audioSystem.audioContextSingleton.resume();
  28. }else{
  29. flock.enviro.shared.stop();
  30. }
  31. };
  32. </script>
  33.  
  34. <canvas id="meter"></canvas>
  35.  
  36. <script>
  37. var basssynth = flock.synth.polyphonic({
  38. synthDef: {
  39. ugen: "flock.ugen.distortion.tarrabiaDeJong",
  40. id: "disto",
  41. mul: {
  42. id: "env",
  43. ugen: "flock.ugen.asr",
  44. attack: 0.1,
  45. release: 1,
  46. gate: 0,
  47. mul: 0.35
  48. },
  49. amount: .2,
  50. source: {
  51. ugen: "flock.ugen.saw",
  52. freq: {
  53. id: "mod",
  54. ugen: "flock.ugen.square",
  55. mul: {
  56. ugen: "flock.ugen.sin",
  57. mul: 30,
  58. freq: 4
  59. },
  60. add: 100
  61. }
  62. }
  63. }
  64. });
  65.  
  66. var mpe = flock.midi.connection({
  67. openImmediately: true,
  68. ports: {
  69. input: {
  70. name: "Seaboard BLOCK"
  71. }
  72. },
  73. listeners: {
  74. noteOn: function(msg){
  75. basssynth.noteOn(msg.channel, {
  76. "disto.amount": (msg.velocity/127),
  77. "mod.add": flock.midiFreq(msg.note),
  78. "env.mul": Math.pow(10,((msg.velocity/12.7)-11)/20)
  79. });
  80. },
  81. noteOff: function(msg){
  82. basssynth.noteOff(msg.channel);
  83. },
  84. control: function(msg){
  85. if( basssynth.voiceAllocator.activeVoices[msg.channel] !== undefined)
  86. basssynth.voiceAllocator.activeVoices[msg.channel].set("mod.mul.freq", msg.value-60);
  87. },
  88. aftertouch: function(msg){
  89. if( basssynth.voiceAllocator.activeVoices[msg.channel] !== undefined)
  90. basssynth.voiceAllocator.activeVoices[msg.channel].set( "env.mul", Math.pow(10,((msg.pressure/12.7)-11)/20) );
  91. },
  92. }
  93. });
  94. </script>
  95.  
  96. <script>
  97. flock.enviro.shared.play();
  98. </script>
  99. </body>
  100. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement