Code Monkey home page Code Monkey logo

minipiano's Introduction

UPDATED VERSION HERE: https://github.com/curtastic/p1

Forked from tiny js from vertfromage forked from xem.

Less than 0.8KB minified!

Try the demo https://curtastic.com/miniPiano/demo.html

FULL EXAMPLE:

<html>
	<body>
		<script src="miniPiano.js"></script>
		<button onclick="piano.play([28,,28,,-28,,,,28,,28,,-28,,,,28,,31,,24,,,26,-28,,,,,])">
			Jingle Bells ▶
		</button>
	</body>
</html>

Numbers are note pitch. Leave gaps to make silence. Loops forever.

That's it! There's only 1 function, piano.play()

TO STOP:

piano.play([])

FAST TEMPO EXAMPLE:

piano.play([7,9,,9,10,12], 100)

ALL NOTES ARE TWICE AS SHORT EXAMPLE:

piano.play([7,9,,9,10,12], 100, .5)

Longest noteLen allowed is 1 (default)

SOME NOTES ARE LONGER EXAMPLE:

piano.play([7,-9,,9,10,-12,,])

Use negative numbers to make a note twice as long. This won't make it take up 2 slots in your array.

SOME NOTES ARE SHORTER EXAMPLE:

piano.play([.11,,.11,,-11,,,,.09,,.09,,-9,,])

Use a dot to make a note half as long. To play a 9 (lower A) short, use .09 not .9

minipiano's People

Contributors

curtastic avatar vertfromage avatar xem avatar

Stargazers

Matt Hayes 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.