Giter Site home page Giter Site logo

html5bytebeat's Introduction

HTML5 Bytebeat

Bytebeat is the name of type of music made from math.

You provide a function who's only input is time t and from that write some code to generate a sound.

In this particular case t is an 8000hz timer that counts up. For example

sin(t) * 127 + 127

You can choose traditional bytebeat where the output of your function is expected to be 0 to 255 or you can choose floatbeat where the output is expected to be -1 to +1.

Functions are just plain JavaScript though sin, cos, tan, floor, ceil and int will automatically be converted to Math.sin, Math.cos, Math.tan, Math.floor, Math.ceil, and Math.floor respectively.

Click here to try your hand at Bytebeat.

Here are a few sample songs

Instructions

Modes

There 2 modes

  • bytebeat: Your expression is expected to generate byte values from 0 to 255
  • floatbeat: Your expression is expected to generate float values from -1.0 to 1.0

Expression Types

  • Infix: Standard expressions eg. "(t * 2) / 4"
  • Postfix(rpn): Reverse Polish Notation eg "t 2 * 4 /"
  • glitch: glitch format or glitch urls.

Infix is standard JavaScript so all Math functions are available. Most math functions you can drop the "Math." part. In other words

sin(t)

is the same as

Math.sin(t)

Postfix requires that each element have at least one space between it.

t2*    // BAD!
t 2 *  // Good!

Glitch is a format used by glitch machine for sharing. Examples

These can be prefixed with "glitch://". For example

There's a bunch more here. I have a feeling there's a bug or 2 left for full glitch support

Extra

Comments can be both // or /* */ style

There are several extra inputs available

The mouse position is available as mouseX and mouseY

sin(t * mouseX * 0.001) + cos(t * mouseY * 0.003)

The size of the window is available width and height

The orientation of a device may be available as tiltX and tiltY.

(sin(t * 0.1 * tiltX) + cos(t * tiltY * 0.07)) * 0.5

Also note, using the comma operator you can write fairly arbitrary code.

http://goo.gl/IZVBS

For more info

Check out http://canonical.org/~kragen/bytebeat/ and be sure follow the many links.

Special thanks to:

html5bytebeat's People

Contributors

greggman 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.