<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width">
    <link rel="stylesheet" href="main.css">
    <title>decodeAudioData example</title>

    <link rel="stylesheet" href="">
    <!--[if lt IE 9]>
      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
  </head>
  <body>
    <div class="txt-content">
      <div class="play-txt1">
        <p class="s1">S</p>
        <p class="s2">u</p>
        <p class="s3">m</p>
        <p class="s4">m</p>
        <p class="s5">e</p>
        <p class="s6">r</p>
      </div>
      <div class="play-txt2">
        <p class="g1">s</p>
        <p class="g2">o</p>
        <p class="g3">n</p>
        <p class="g4">g</p>
        <p class="g5">s</p>
      </div>
      <!-- <p class="play-txt2">for good vibes</p> -->
    </div>
    <button type="button" class="play" name="button" style="display:none">►</button>
    <button type="button" class="full" name="button">
      <img class="full-img" src="img/full-screen.png" alt="full-screen">
    </button>
    <input class="volume" type="range" min="0" max="100" value="">
    <canvas></canvas>
    <div class="circle"></div>
    <button class="btnA btnW" type="button" name="button"></button>
    <button class="btnB btnW" type="button" name="button"></button>
    <button class="btnC btnW" type="button" name="button"></button>
      <img class="wall wallA" src="img/a.jpeg" alt="flower">
      <img class="wall wallB" src="img/b.jpeg" alt="flower">
      <img class="wall wallC" src="img/c.jpeg" alt="flower">
  </body>
  <script>

  var canvas = document.body.querySelector('canvas');
  var ctx = canvas.getContext('2d') // context 2d  ou webGl
  var context = new (window.AudioContext || window.webkitAudioContext)(); // Création de l'instance
  var analyser = context.createAnalyser();
  var frequencyData = new Uint8Array(this.analyser.frequencyBinCount);
  var frequencyDataLength = frequencyData.length-400;// - aigue
  var width, height, rectWidth = null;
  var soundBuffer = null;
  var url = "sound.mp3";
  var gainNode = context.createGain();

  //SUCCESS
  function onSuccess(buffer) {
    soundBuffer = buffer;

    var play = document.querySelector('.play');
    play.style.display = 'block';
    play.addEventListener('click', onPlayClick);
  }
  //ERROR
  function onError() {
    console.error('Une erreur est survenue lors du decodage du son');
  }
  //ONLOAD SOUND
  function onLoadSound(data) {
    console.log(data);
    context.decodeAudioData(data, onSuccess, onError);
  }
  //CONNEXION enceinte & analyser
  function onPlayClick() {
    var source = context.createBufferSource(); // creates a sound source
    var play = document.querySelector('.play');
    var txt = document.querySelector('.txt-content');
    source.buffer = soundBuffer; // source a jouer
    if(play.id == ""){
      source.connect(gainNode); //Connexion au enceinte
      gainNode.gain.value = 1;
      gainNode.connect(context.destination); //Connexion au enceinte
      play.id = "activated";
      play.innerHTML = "I I";
      txt.style.display = 'block';
    } else {
      gainNode.gain.value = 0;
      gainNode.disconnect(context.destination);//Deco
      play.id = "";
      play.innerHTML = "►";
    }
    source.connect(analyser); // relier a l'analyser sur une autre branche
    source.start(0);

    // VOLUME
    function volume() {
    var volume = document.querySelector('.volume').value;
    gainNode.gain.value = volume;
  };
    volume();
    update();
  }
  //LOAD SOUND
  function loadSound(url, callback) {
    var request = new XMLHttpRequest();
    request.open('GET', url, true);
    request.responseType = 'arraybuffer';

    request.onload = function() {
      callback(request.response)
    }
    request.send();
  }
  //TCHEQUE VAR RESIZE
  function handleResize() {
    width = window.innerWidth;
    height = window.innerHeight;
    canvas.width = width;
    canvas.height = height;
    rectWidth = width / frequencyDataLength;
  }
  //UPDATE
  function update() {
    analyser.getByteFrequencyData(frequencyData);
    draw()

    requestAnimationFrame(update);
  }

  // CREATION BARRE
  function draw() {
    ctx.clearRect(0, 0, width, height);//clear du canvas
    //var gradient = ctx.createLinearGradient(0,0,width,0); //LINEAR gradient
    var gradient = ctx.createRadialGradient(width/2,height/2,5,width/2,height/2,600); //LINEAR gradient
    gradient.addColorStop("0","transparent");
    gradient.addColorStop("0.244","transparent");
    gradient.addColorStop("0.245","cyan");
    gradient.addColorStop("0.5","blue");
    gradient.addColorStop("0.8","red");
    ctx.strokeStyle=gradient;
    // ctx.lineWidth=5;
    for (var i = 0; i < frequencyDataLength; i++) {
      var angle = (Math.PI * 2) / frequencyDataLength * i;
      var rayon =150;//2 taille rayon
      var farRayon = frequencyData[i] * 2.3;//3 taille farRayon
      //var tryr = farRayon + 500; // pointiller
      ctx.beginPath();
      // ctx.moveTo(width/2, height/2); //1 MIDLE
      // ctx.moveTo(rayon*Math.cos(angle),rayon*Math.sin(angle)); // angle
      ctx.moveTo(width/2+rayon*Math.cos(angle),height/2+rayon*Math.sin(angle))//midle + angle
      ctx.lineTo(width/2+farRayon*Math.cos(angle),height/2+farRayon*Math.sin(angle)); //
      ctx.stroke();
    }
  }

  window.addEventListener('resize', handleResize);
  handleResize();
  loadSound(url, onLoadSound);

  </script>
  <script type="text/javascript" src="fullScreen.js"></script>
  <script type="text/javascript" src="wall.js"></script>
</html> 
by

HTML Online Editor & Compiler

Write, Run & Share HTML code online using OneCompiler's HTML online Code editor for free. It's one of the robust, feature-rich online Code editor for HTML language, running on the latest version HTML5. Getting started with the OneCompiler's HTML compiler is simple and pretty fast. The editor shows sample boilerplate code when you choose language as HTML. You can also specify the stylesheet information in styles.css tab and scripts information in scripts.js tab and start coding.

About HTML

HTML(Hyper Text Markup language) is the standard markup language for Web pages, was created by Berners-Lee in the year 1991. Almost every web page over internet might be using HTML.

Syntax help

Fundamentals

  • Any HTML document must start with document declaration <!DOCTYPE html>
  • HTML documents begin with <html> and ends with </html>
  • Headings are defined with <h1> to <h6> where <h1> is the highest important heading and <h6> is the least important sub-heading.
  • Paragrahs are defined in <p>..</p> tag.
  • Links are defined in <a> tag.

    Example:

    <a href="https://onecompiler.com/html">HTML online compiler</a>
    
  • Images are defined in <img> tag, where src attribute consists of image name.
  • Buttons are defined in <button>..</button> tag
  • Lists are defined in <ul> for unordered/bullet list and <ol> for ordered/number list, and the list items are defined in <li>.

HTML Elements and Attributes

  • HTML element is everything present from start tag to end tag.
  • The text present between start and end tag is called HTML element content.
  • Anything can be a tagname but it's preferred to put the meaningful title to the content present as tag name.
  • Do not forget the end tag.
  • Elements with no content are called empty elements.
  • Elements can have attributes which provides additional information about the element.
  • In the below example, href is an attribute and a is the tag name.

    Example:

    <a href="https://onecompiler.com/html">HTML online compiler</a>
    

CSS

CSS(cascading style sheets) describes how HTML elements will look on the web page like color, font-style, font-size, background color etc.

Example:

Below is a sample style sheet which displays heading in green and in Candara font with padding space of 25px.

body{
  padding: 25px;
}
.title {
	color: #228B22;
	font-family: Candara;
}

HTML Tables

  • HTML Tables are defined in <table> tag.
  • Table row should be defined in <tr> tag
  • Table header should be defined in <th> tag
  • Table data should be defined in <td> tag
  • Table caption should be defined in <caption> tag

HTML-Javascript

  • Javascript is used in HTML pages to make them more interactive.
  • <script> is the tag used to write scripts in HTML
  • You can either reference a external script or write script code in this tag.

Example

<script src="script.js"></script>