Giter Club home page Giter Club logo

radio's Introduction

Web Radio - Visualizer

groupImg

A simple javascript web radio (visualizer).

Listen here.

About

This repo is a ongoing project that I've always wanted to do; some nice visualizations accompanied of good music. Growing up playing with computers I always loved demo scenes and this is nothing but a homage to that era.

Radios

BoxUK

Classic Rock Florida

Do you have a web radio? Join the project!

How to contribute an animation

Before submitting a animation, think about how it will look on many devices (mobile, desktop, tablet...) and account for it. If you need to make a multiplication or division, think about if you have to do it every frame or just one time; if just one time, do it on the constructor method, instead of doing it everytime on the show method.

There are a set of varibles pre defined to draw.

  • c - The canvas context where you will be drawing
  • radio.analyser.fftSize - Sets how much data you want from the audio
  • radio.data - Array that contains the audio's frequency (fft) to interact with
  • w - Screen's width
  • w2 - Half of screen's width - center of screen in the x axis
  • h - Screen's height
  • h2 - Half of screen's height - center of screen in the y axis

Update: since I added the WebGL support, you now have to define what kind of context your animation needs - 2d or webgl.

This is the template for a animation class, you must implement the show method. Feel free to create any other auxiliary methods.

class Animation {

  constructor(){
  
  }
  
  show(){
  
  }

}

Inside the constructor you should define the size of the radio.analyser.fftSize. The value must be a power of 2 and between 32 and 2048. This is how much data you want from the audio, to create your animation. The result of the analyse will be stored in the radio.data attribute. If you choose a fftSize of 32, result.data will have a lenght of 32. You can read more about it here.

So, you constructor now will look like this:

constructor() {
  this.context = '2d'; // or 'webgl' if you want to write a shader animation.
  radio.analyser.fftSize = 32;
  radio.update(); // very import to call update after altering a radio's attribue.
}

That's all you need to get the data you want to draw with. After that, just make your animation at the show method. Don't forget to clear the canvas right at the beggining of the method, otherwise it will draw on top of the last screen (you can use that to create cool effects, if you want).

show(){

  c.clearRect(0,0,w,h); /* clear the screen, from (0,0) to (w,h) */
  
  for(let i = 0; i < radio.data.length; i++){
    /* draw n boxes increment it's x position by 20 */
    /* with their height defined by the radio.data[i] */
    c.fillRect( 20 * i, h2 , 10, radio.data[i] );
  }
}

If you need to update any aspect of your animation, I suggest creating a update method in your Animation class and calling it at the end of your show method

update() {
  //update code goes here 
}

show() {
  //animation code goes here
  this.update();
}

If you take a look at the other Animations you'll see it's pretty simple to implement your own. After you submit your animation, I'll add it to the main script, where it will be called along with the others. Right now they each got a 7 seconds screen time before a new one is called.

To Do

Add more stations - I'll maybe add a option for anyone add their own stations ou audio - but the visualization part is the important one in this project

Add more visualizations - Like old school demo scenes, winamp plugins (rember those?)...

Add support to webgl - I don't know how to program shaders, but as soon as someone submit one, I'll add support to it. Each Animation class should have a context attribute, specifying the context it should be rendered.

Migrate it to its own server with its own domain

Thanks

Eric Andersson - https://github.com/andeeric
BigWings - https://www.shadertoy.com/view/MdfBRX

radio's People

Contributors

andeeric avatar erjanmx avatar ewired avatar trn1ty avatar victorqribeiro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.