Code Monkey home page Code Monkey logo

inward's Introduction

cover

Inward is a weekend hack project inspired by 'Trif', built in a day or so. It uses the web audio API to analyse an incoming audio stream (coming from SoundCloud), to toggle the visibility of some trippy gifs. There's also a hidden feature..somewhere..

What is this?

Inward is a SoundCloud visualisation project. The app takes in a stream (from SoundCloud), analyses it in real-time, and uses frequency data to flash between different preselected gifs.

How does it work?

The best way to see how this is running, is to start digging through the code (all of the best stuff is in app.js), but here's a quick rundown:

First, we create a new Audio object using the Web Audio API, and connect up to SoundCloud. SoundCloud is the only major streaming service that works, as we need to have access to the underlying stream in order to pull data from it. (Note that this step could also be achieved by just placing an <audio> tag on the DOM).

We can then wrap this Audio object, in an AudioContext object, which will allow us to create different nodes that give us data about our stream. For example, we can use createAnalyser which will give us back information about the frequency, or createGain(), to control the volume. createAnalyser is the main method that we will be using for both the waveform, and the main gif flashing effect.

Now that we have exposed this data, we can start to create visualisations with it. The main flashing gif effect is relatively simple. We first create a new Uint8Array, passing in the number of value places that we will require later. We can then fill this array, by using getByteTimeDomainData, which returns the current time domain information of the stream at that moment in time. This is then iterated over, and added to a running total, which we can then find an average from.

We then end up with a figure (for example 127.4). Based on some trial and error, the time domain average of a techno mix comes out at around 128. It's then a case of flicking between different images if this value goes over a predefined max (in this case, 128.6).

Note: This was my first time using the Web Audio API. If any of the above is incorrect, please feel free to create an issue, or even better a PR!

Running locally

  • npm install
  • npm run start, which will kickstart webpack-dev-server
  • It should now be up and running at localhost:8080

Credits

  • All of the gifs in this project are sourced from Giphy.
  • The mixes are linked at the bottom of each page.
  • And of course, Trif for the original idea.

โš ๏ธ This project contains rapidly flickering images.

inward's People

Contributors

alexpate 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

Watchers

 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.