Skip to content
This repository has been archived by the owner on Jun 9, 2019. It is now read-only.

Commit

Permalink
update README
Browse files Browse the repository at this point in the history
  • Loading branch information
mohayonao committed Aug 30, 2014
1 parent 32051f1 commit b871a08
Showing 1 changed file with 108 additions and 0 deletions.
108 changes: 108 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,109 @@
# web-audio-mock
[![NPM Version](http://img.shields.io/npm/v/web-audio-mock.svg?style=flat)](https://www.npmjs.org/package/web-audio-mock)
[![Build Status](http://img.shields.io/travis/mohayonao/web-audio-mock.svg?style=flat)](https://travis-ci.org/mohayonao/web-audio-mock)
[![Coverage Status](http://img.shields.io/coveralls/mohayonao/web-audio-mock.svg?style=flat)](https://coveralls.io/r/mohayonao/web-audio-mock?branch=master)
[![Dependency Status](http://img.shields.io/david/mohayonao/web-audio-mock.svg?style=flat)](https://david-dm.org/mohayonao/web-audio-mock)
[![devDependency Status](http://img.shields.io/david/dev/mohayonao/web-audio-mock.svg?style=flat)](https://david-dm.org/mohayonao/web-audio-mock)

> Web Audio API mock library for node.js
## Installing

##### node.js

```sh
% npm install web-audio-mock
```

## Usage

##### Module Routing

```javascript
require("./web-audio-mock");

var ctx = new AudioContext();
var osc = ctx.createOscillator();
var amp = ctx.createGain();

osc.type = "sawtooth";
osc.frequency.value = 220;

osc.connect(amp);
amp.connect(ctx.destination);

ctx.toJSON();

{
"name": "AudioDestinationNode",
"inputs": [
{
"name": "GainNode",
"gain": {
"name": "gain",
"value": 1,
"inputs": []
},
"inputs": [
{
"name": "OscillatorNode",
"type": "sawtooth",
"frequency": {
"name": "frequency",
"value": 220,
"inputs": []
},
"detune": {
"name": "detune",
"value": 0,
"inputs": []
},
"inputs": []
}
]
}
]
}
```

##### DecodeAudioData

```javascript
var ctx = new AudioContext();

it("AudioContext#decodeAudioData", function(done) {

// ctx.DECODE_AUDIO_DATA_FAILED = true;

ctx.decodeAudioData(buffer, function(e) {
done();
}, function() {
// failed
});

});
```

##### ScriptProcessing

```javascript
var ctx = new AudioContext();

it("ScriptProcessorNode#onaudioprocess", function(done) {
var scp = ctx.createScriptProcessor(1024, 2, 2);
var count = 0;

scp.onaudioprocess = function(e) {
count += 1;
if (count === 5) {
done();
}
};

ctx.process(0.5); // process 0.5sec
});
```

## License

web-audio-mock is available under the The MIT License.

0 comments on commit b871a08

Please sign in to comment.