leomaster

Happy Birthday Music JS

Jul 23rd, 2021
1,384
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!--                                    ^^^^
  2.                                         ||
  3.                                         ||
  4.  Click the run button above ============++
  5. -->
  6. <!DOCTYPE html>
  7. <html>
  8.   <head>
  9.     <meta charset="utf-8">
  10.     <meta name="viewport" content="width=device-width">
  11.     <title>repl.it</title>
  12.   </head>
  13.   <body>
  14.     <button id="playBtn" style="font-size: 100px">Preview</button>
  15.     <script>
  16.       function play() {
  17.         // Code to send: -----------------
  18.         ((c=new AudioContext(),n=[...'畋畋畍甯畋甯畐甯畏甯甯甯畋畋畍甯畋甯畒甯畐甯甯甯畋畋畗甯畔甯畐畐畏甯畍甯甯甯畕畕畔甯畐甯畒甯畐甯甸甼甿町甽甿町甽甿甸甼甿甸甿畂甸甽畁畄町甿畃甼甿畄'].map(a=>a.charCodeAt(0)-30000),z=c.currentTime,t=(f,b,o=c.createOscillator(),g=c.createGain(),l=0.5)=>(o.frequency.value=f,o.connect(g),g.connect(c.destination),g.gain.setValueAtTime(0.5,z+b),g.gain.linearRampToValueAtTime(0,z+b+l),o.start(z+b),o.stop(z+b+l)))=>n.forEach((c,i)=>~c&&t(220*2**((c)/12),(i>=47?(i-47)*2:i+(i%2)/6)/4)))()
  19.        // -------------------------------
  20.      }
  21.      playBtn.onclick=play
  22.    </script>
  23.  </body>
  24. </html>
RAW Paste Data