Skip to content

Commit

Permalink
Releasing version 1.0.0
Browse files Browse the repository at this point in the history
 - No long need to call `finish()` on each instrument.
 - `BandJS.end()` has been renamed to `BandJS.finish()` and it now returns an instiated Player class.
 - Numerous bug fixes and performance improvements.
 - Coverted library into Browserify structure. Should now be more friendly when using with NodeJS.
 - Updated examples and added a new JSON Load example.
  • Loading branch information
Cody Lundquist committed Jul 14, 2014
1 parent 995c4bc commit f14d56b
Show file tree
Hide file tree
Showing 22 changed files with 2,548 additions and 951 deletions.
20 changes: 16 additions & 4 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,33 @@ module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
browserify: {
options: {
bundleOptions: {
standalone: '<%= pkg.name %>'
}
},
build: {
src: 'src/main.js',
dest: 'dist/band.js'
}
},
uglify: {
options: {
compress: true,
banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
build: {
src: 'src/**/*.js',
dest: 'build/<%= pkg.name %>.min.js'
src: 'dist/band.js',
dest: 'dist/band.min.js'
}
}
});

// Load the plugin that provides the "uglify" task.
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-browserify');

// Default task(s).
grunt.registerTask('default', ['uglify']);
};
grunt.registerTask('default', ['browserify', 'uglify']);
};
122 changes: 67 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Band.js - Music Composer
#### Get Started

1. Include `band.min.js` in the head of your document.
2. Create an new instance: `var music = new BandJS();`
3. Give it a Time Signature: `music.setTimeSignature(4,4);`
4. Set the tempo: `music.setTempo(120);`
5. Create an instrument: `var piano = music.createInstrument();`
2. Create an new instance: `var conductor = new BandJS();`
3. Give it a Time Signature: `conductor.setTimeSignature(4,4);`
4. Set the tempo: `conductor.setTempo(120);`
5. Create an instrument: `var piano = conductor.createInstrument();`
6. Start adding notes:

```javascript
Expand All @@ -18,9 +18,8 @@ Band.js - Music Composer
piano.note('quarter', 'F4');
```

7. Mark the `piano` instrument as finished: `piano.finish();`
8. Tell the `music` everything is done: `music.end();`
9. Start playing the music: `music.play()`
7. Tell the `conductor` everything is done: `var player = conductor.finish();`. It will return you the player instance to use for playing, pausing, muting, stopping, and seeking.
8. Start playing the music: `player.play()`

#### Examples

Expand All @@ -31,7 +30,7 @@ Band.js - Music Composer

#### API

##### BandJS Class
##### Conductor Class
<table>
<tr>
<th width="20%">Method</th>
Expand Down Expand Up @@ -62,51 +61,16 @@ as it's default rhythm notation.</td>
<td>Set the master volume of the music. From 0 to 100</td>
</tr>
<tr>
<td><code>pause()</code></td>
<td>n/a</td>
<td>Pause the music.</td>
</tr>
<tr>
<td><code>stop(fadeOut)</code></td>
<td><code>fadeOut: true</code></td>
<td>Stop the music with a slight fade out. If you don't want the fade, pass in false.</td>
</tr>
<tr>
<td><code>destroy()</code></td>
<td>n/a</td>
<td>Stop the music and destroy all the instruments and notes.</td>
</tr>
<tr>
<td><code>play()</code></td>
<td>n/a</td>
<td>Play the music.</td>
</tr>
<tr>
<td><code>end()</code></td>
<td>n/a</td>
<td>Collects all of the notes of each finished instrument and creates the oscillators in preperation to play.</td>
</tr>
<tr>
<td><code>mute(callback)</code></td>
<td><code>finish()</code></td>
<td>n/a</td>
<td>Mutes the music. You can pass in a function as a callback when the music completely faded.</td>
</tr>
<tr>
<td><code>unmute(callback)</code></td>
<td>n/a</td>
<td>Unmute the music. You can pass in a function as a callback when the music is completely faded up.</td>
<td>Totals up the duration of the song and returns the Player Class.</td>
</tr>
<tr>
<td><code>onFinished(callback)</code></td>
<td>n/a</td>
<td>Pass in a function that will be called when the music has completed</td>
</tr>
<tr>
<td><code>loop(loop)</code></td>
<td><code>loop: false</code></td>
<td>Pass in true if you want the music to keep looping forever.</td>
</tr>
<tr>
<td><code>createInstrument(name, pack)</code></td>
<td>
<code>name: 'sine'</code><br>
Expand All @@ -119,7 +83,7 @@ instrument pack if one is not specified.</td>
<tr>
<td valign="top"><code>load(json)</code></td>
<td valign="top"><code>json: JSON</code></td>
<td>Load a song into Band.js using JSON. Format is:<br>
<td>Load a song into Band.js using JSON. Format is: (**This will erase your current song and overwrite it with this new one**)<br>
<pre>{
timeSignature: [4, 4],
tempo: 100,
Expand Down Expand Up @@ -153,6 +117,15 @@ instrument pack if one is not specified.</td>
}</pre>
</td>
</tr>
</table>

##### Conductor Class Static Methods
<table>
<tr>
<th width="20%">Method</th>
<th width="10%">Params</th>
<th width="70%">Description</th>
</tr>
<tr>
<td valign="top"><code>loadPack(type, name, data)</code></td>
<td valign="top">
Expand All @@ -167,7 +140,7 @@ instrument pack if one is not specified.</td>
frequency as the value (i.e. {'A4': 440.00, 'A#4': 466.16})<br>And lastly, the instrument pack type. This needs
to be a function which takes 2 arguments, <code>name</code> and <code>audioContext</code>,
that returns an object with at least one method called <code>createSound(destination, frequency)</code>.
When an instrument is created using <code>BandJS::createInstrument(name, pack)</code> the library will use those two
When an instrument is created using <code>BandJS.createInstrument(name, pack)</code> the library will use those two
parameters to search the instrument packs and get a specific instrument. Once found,
it will call it's function and pass in the name of the sound and the Audio Context. When the library
wants the instrument to create a note, it will call the <code>createSound(destination,
Expand All @@ -179,12 +152,56 @@ instrument pack if one is not specified.</td>
</tr>
</table>

##### Instrument Class - Created by using the `BandJS:createInstrument()` method.
##### Player Class - Returned from the Conductor Class when calling `Conductor.finish()`
<table>
<tr>
<th width="20%">Method</th>
<th width="10%">Params</th>
<th width="70%">Description</th>
</tr>
<tr>
<td><code>play()</code></td>
<td>n/a</td>
<td>Play the music.</td>
</tr>
<tr>
<td><code>pause()</code></td>
<td>n/a</td>
<td>Pause the music.</td>
</tr>
<tr>
<td><code>stop(fadeOut)</code></td>
<td><code>fadeOut: true</code></td>
<td>Stop the music with a slight fade out. If you don't want the fade, pass in false.</td>
</tr>
<tr>
<td><code>mute(callback)</code></td>
<td>n/a</td>
<td>Mutes the music. You can pass in a function as a callback when the music completely faded.</td>
</tr>
<tr>
<td><code>unmute(callback)</code></td>
<td>n/a</td>
<td>Unmute the music. You can pass in a function as a callback when the music is completely faded up.</td>
</tr>
<tr>
<td><code>loop(loop)</code></td>
<td><code>loop: false</code></td>
<td>Pass in true if you want the music to keep looping forever.</td>
</tr>
<tr>
<td><code>setTime(seconds)</code></td>
<td><code>seconds: 0</code></td>
<td>You can set the specific time a song should start playing at. This is handy for seeking time.</td>
</tr>
</table>

##### Instrument Class - Created by using the `Conductor.createInstrument()` method.
<table>
<tr>
<th width="20%">Method</th>
<th width="15%">Params</th>
<th width="65%">Description</th>
<th width="10%">Params</th>
<th width="70%">Description</th>
</tr>
<tr>
<td valign="top"><code>note(rhythm, pitch, tie)</code></td>
Expand Down Expand Up @@ -232,11 +249,6 @@ instrument pack if one is not specified.</td>
<td><code>times: 1</code></td>
<td>Used in conjunction with <code>repeatStart()</code>. Pass in how many times the section should be repeated. If no <code>repeatStart()</code> is set, it goes from the beginning.</td>
</tr>
<tr>
<td><code>finish()</code></td>
<td>n/a</td>
<td>This will mark the instrument as complete and add it's notes to the master list. If this is missing, the instrument will not be played.</td>
</tr>
</table>

### License
Expand Down
6 changes: 3 additions & 3 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "band.js",
"version": "0.3.1",
"main": "build/band.min.js",
"name": "BandJS",
"version": "1.0.0",
"main": "dist/band.min.js",
"ignore": [
"**/.*",
"node_modules",
Expand Down
2 changes: 0 additions & 2 deletions build/band.min.js

This file was deleted.

0 comments on commit f14d56b

Please sign in to comment.