neume.js
v0.8.0 audio interactive music sound web audio web audio api
neume.js
What is?
Neume (/ˈnjuːm/; ja: ニューム) is a Web Audio API library for developing browser music. The architecture of neume.js provides a very simple interface for creating web-based audio application and generates optimized audio-graph for Web Audio API.
Examples
- 8bit-sequencer
- simple sequencer
- mml-piano
- toy piano with Music Macro Language
- sine-storm
- sine wave drone
- buffer-work
- sliced audio buffer rhythm machine
- other weird demonstrations
Installation
Bower
$ bower install neume.js
Downloads
You'll also need a Promise polyfill for older browsers.
Here is boilerplate html in order to play a sine wave metronome in neume.js. → sample
<!DOCTYPE html>
<html>
<head>
<title>neume.js metronome</title>
<script src="/path/to/neume.min.js"></script>
</head>
<body>
<button id="start">start</button>
<script>
var neu = neume(new AudioContext());
function Sine($, freq, dur) {
return $("sin", { freq: freq })
.$("xline", { dur: dur }).on("end", $.stop);
}
var timer = null;
function start() {
if (timer) {
timer.stop();
timer = null;
} else {
timer = neu.Interval("4n", function(e) {
var freq = [ 880, 440, 440, 440 ][e.count % 4];
var dur = [ 0.5, 0.125, 0.125, 0.125 ][e.count % 4];
neu.Synth(Sine, freq, dur).start(e.playbackTime);
}).start();
}
}
document.getElementById("start").onclick = start;
</script>
</body>
</html>
How do work?
This example makes a modulated 880(±20) Hz sine wave with an exponential decay of about one second.
// initialize neume interface with AudioContext
var neu = neume(new AudioContext());
// define synth and play it
neu.Synth(function($) {
return $("sin", { freq: $("sin", { freq: 8 }).mul(20).add(880) })
.$("xline", { start: 0.25, end: 0.001, dur: 1 }).on("end", $.stop);
}).start();
Above code generates an audio-graph like a below. Graphs are optimized flexibly by neume.js.
+-------------------+
| OscillatorNode |
| - type : sine |
| - frequency: 8 |
| - detune : 0 |
+-------------------+
+-------------------+ |
| OscillatorNode | +------------+
| - type : sine | | GainNode |
| - frequency: 880 <---| - gain: 20 |
| - detune : 0 | +------------+
+-------------------+
|
+-----------------------+
| GainNode |
| - gain: 0.25 -> 0.001 |
+-----------------------+
|
+-----------+
| GainNode | * This node is used to
| - gain: 1 | fade volume for a synth instance.
+-----------+
|
In SuperCollider
{
SinOsc.ar(SinOsc.kr(8) * 20 + 880) *
XLine.kr(0.25, 0.001, 1, doneAction:2)
}.play;
In MAX patch
Tools
Documents
- Reference ( :construction_worker: work in progress )
License
Neume.js is available under the The MIT License.