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

Commit

Permalink
Merge pull request #5 from skratchdot/skratchdot_extras
Browse files Browse the repository at this point in the history
adding 2 new extras: mp3_decode and soundfont
  • Loading branch information
mohayonao committed Aug 4, 2013
2 parents e7d9198 + 1ba5d7e commit 9558bf0
Show file tree
Hide file tree
Showing 20 changed files with 18,357 additions and 2 deletions.
14 changes: 14 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@ module.exports = function(grunt) {
all: {
options: { sourceMap: "timbre.js.map" },
files: { "timbre.js": ["timbre.dev.js"] }
},
extras: {
options: { preserveComments: 'some' },
files: {
"src/extras/min/audio-jsonp.min.js": ["src/extras/audio-jsonp.js"],
"src/extras/min/cosc.min.js": ["src/extras/cosc.js"],
"src/extras/min/keyboard.min.js": ["src/extras/keyboard.js"],
"src/extras/min/MoogFF.min.js": ["src/extras/MoogFF.js"],
"src/extras/min/mouse.min.js": ["src/extras/mouse.js"],
"src/extras/min/mp3_decode.min.js": ["src/extras/mp3_decode.js"],
"src/extras/min/pico-binder.min.js": ["src/extras/pico-binder.js"],
"src/extras/min/soundfont.min.js": ["src/extras/soundfont.js"],
"src/extras/min/webaudioapi.min.js": ["src/extras/webaudioapi.js"]
}
}
},
watch: {
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ T("sin", {freq:880, mul:0.5}).play();
MIT

## ChangeLog ##
**13.08.03** (361.93KB)
* Adding Extra: mp3_decode. See [mp3_decode](http://mohayonao.github.io/timbre.js/mp3_decode.html)
* Adding Extra: soundfont. See [soundfont](http://mohayonao.github.io/timbre.js/soundfont.html)

**13.05.03** (361.93KB)
* Bugfix: wav decoder. See [#3](https://github.com/mohayonao/timbre.js/issues/3)

Expand Down
49 changes: 49 additions & 0 deletions docs.md/X-mp3_decode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
mp3_decode
==========
Decode mp3s in the browser using jsmad

## Installation

Download 2 extra javascript files:

- [jsmad.js](/timbre.js/src/extras/jsmad.js)
- [mp3_decode.js](/timbre.js/src/extras/mp3_decode.js)


```html
<script src="timbre.js"></script>
<script src="jsmad.js"></script>
<script src="mp3_decode.js"></script>
```


## Description ##

(canvas canvas w:240 h:80)

You can now play mp3s in the browser the same way you would play a .wav file

```timbre
var src = window.getDraggedFile() || "/timbre.js/misc/audio/note.mp3";
T("audio").loadthis(src, function () {
this.plot({target:canvas}).play();
}).on("ended", function () {
this.pause();
});
```


## See Also ##

- [jsmad Source Code](https://github.com/audiocogs/jsmad/)


## Source ##

https://github.com/mohayonao/timbre.js/blob/master/src/extras/jsmad.js
https://github.com/mohayonao/timbre.js/blob/master/src/extras/mp3_decode.js


<script src="/timbre.js/src/extras/min/jsmad.min.js"></script>
<script src="/timbre.js/src/extras/min/mp3_decode.min.js"></script>
77 changes: 77 additions & 0 deletions docs.md/X-soundfont.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
soundfont
=========
Play soundfonts from a "soundfont url" such as [free-midi](https://code.google.com/p/free-midi/)


## Installation

Download 4 extra javascript files:

- [audio-jsonp.js](/timbre.js/src/extras/audio-jsonp.js)
- [jsmad.js](/timbre.js/src/extras/jsmad.js)
- [mp3_decode.js](/timbre.js/src/extras/mp3_decode.js)
- [soundfont.js](/timbre.js/src/extras/soundfont.js)


```html
<script src="timbre.js"></script>
<script src="audio-jsonp.js"></script>
<script src="jsmad.js"></script>
<script src="mp3_decode.js"></script>
<script src="soundfont.js"></script>
```


## Description ##

T.soundfont is a singleton object that caches various soundfont notes, and
allows you to play them.

```timbre
// play note 64 using the current instrument
// NOTE: this will change whenever someone calls T.soundfont.setInstrument();
T.soundfont.play(64);
```

```timbre
// set instrument to a "cello", and play note 64
T.soundfont.setInstrument(42);
T.soundfont.play(64);
```

```timbre
// only play if this note has already been cached
T.soundfont.play(70, false);
```

## Methods ##

- `T.soundfont.emptyCache();`
- `T.soundfont.setUrlTemplate(newUrlTemplate);`
- `T.soundfont.setName(newName);`
- `T.soundfont.setChannel(newChannel);`
- `T.soundfont.setInstrument(newInstrument);`
- `T.soundfont.setLength(newLength);`
- `T.soundfont.setJsonp(newJsonp);`
- `T.soundfont.preload(noteArray);`
- `T.soundfont.play(note, playOnLoad, options);`


## See Also ##

- [free-midi](https://code.google.com/p/free-midi/)


## Source ##

https://github.com/mohayonao/timbre.js/blob/master/src/extras/audio-jsonp.js
https://github.com/mohayonao/timbre.js/blob/master/src/extras/jsmad.js
https://github.com/mohayonao/timbre.js/blob/master/src/extras/mp3_decode.js
https://github.com/mohayonao/timbre.js/blob/master/src/extras/soundfont.js


<script src="/timbre.js/src/extras/audio-jsonp.js"></script>
<script src="/timbre.js/src/extras/jsmad.js"></script>
<script src="/timbre.js/src/extras/mp3_decode.js"></script>
<script src="/timbre.js/src/extras/soundfont.js"></script>

Binary file added misc/audio/note.mp3
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "timbre",
"version": "13.05.03",
"version": "13.08.03",
"description": "JavaScript library for objective sound programming",
"author": "nao yonamine <mohayonao@gmail.com>",
"repository": {
Expand Down
Loading

0 comments on commit 9558bf0

Please sign in to comment.