Skip to content

Commit

Permalink
Merge pull request #162 from therewasaguy/dev
Browse files Browse the repository at this point in the history
add grunt tasks, v0.3.3
  • Loading branch information
therewasaguy authored Jan 28, 2017
2 parents 2ec3be2 + eca34cc commit 55fda82
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 58 deletions.
58 changes: 31 additions & 27 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,34 +34,10 @@ module.exports = function(grunt) {
// p5 dist
main: {
files: ['src/**/*.js'],
tasks: ['jshint', 'requirejs'],
tasks: ['requirejs'],
options: { livereload: true }
},
// reference
reference_build: {
files: ['docs/yuidoc-p5-theme/**/*'],
tasks: ['yuidoc'],
options: { livereload: true, interrupt: true }
},
// scripts for yuidoc/reference theme
yuidoc_theme_build: {
files: ['docs/yuidoc-p5-theme-src/scripts/**/*'],
tasks: ['requirejs:yuidoc_theme']
}
},
mocha: {
test: {
src: ['test/*.html'],
// src: ['test/**/*.html'],
options: {
// reporter: 'test/reporter/simple.js',
reporter: 'Nyan',
run: true,
log: true,
logErrors: true
}
},
},
requirejs: {
unmin: {
options: {
Expand Down Expand Up @@ -167,15 +143,43 @@ module.exports = function(grunt) {
}
}
},
},
open: {
testChrome: {
path: 'http://localhost:8000/test',
app: 'Chrome'
},
testFirefox : {
path: 'http://localhost:8000/test',
app: 'Firefox'
},
testSafari : {
path: 'http://localhost:8000/test',
app: 'Safari'
}
},
connect: {
server: {
options: {
port: 8000,
hostname: '*'
}
}
}
});


grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.loadNpmTasks('grunt-contrib-yuidoc');
grunt.registerTask('yui', ['yuidoc']);
// grunt.loadNpmTasks('grunt-mocha');

grunt.registerTask('default', ['requirejs']);
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-open');

grunt.registerTask('default', ['requirejs']);
grunt.registerTask('dev', ['connect','requirejs', 'watch']);
grunt.registerTask('serve', 'connect:server:keepalive');
grunt.registerTask('run-tests', ['serve', 'open']);
};
36 changes: 20 additions & 16 deletions lib/p5.sound.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! p5.sound.js v0.3.2 2017-01-18 */
/*! p5.sound.js v0.3.3 2017-01-28 */
(function (root, factory) {
if (typeof define === 'function' && define.amd)
define('p5.sound', ['p5'], function (p5) { (factory(p5));});
Expand Down Expand Up @@ -4523,7 +4523,7 @@ oscillator = function () {
}
// var detune = this.oscillator.frequency.value;
this.oscillator = p5sound.audiocontext.createOscillator();
this.oscillator.frequency.exponentialRampToValueAtTime(Math.abs(freq), p5sound.audiocontext.currentTime);
this.oscillator.frequency.value = Math.abs(freq);
this.oscillator.type = type;
// this.oscillator.detune.value = detune;
this.oscillator.connect(this.output);
Expand Down Expand Up @@ -4577,9 +4577,6 @@ oscillator = function () {
var rampTime = rampTime || 0;
var tFromNow = tFromNow || 0;
var now = p5sound.audiocontext.currentTime;
var currentVol = this.output.gain.value;
this.output.gain.cancelScheduledValues(now);
this.output.gain.linearRampToValueAtTime(currentVol, now + tFromNow);
this.output.gain.linearRampToValueAtTime(vol, now + tFromNow + rampTime);
} else if (vol) {
vol.connect(self.output.gain);
Expand Down Expand Up @@ -7026,10 +7023,11 @@ delay = function () {
* Delay is an echo effect. It processes an existing sound source,
* and outputs a delayed version of that sound. The p5.Delay can
* produce different effects depending on the delayTime, feedback,
* filter, and type. In the example below, a feedback of 0.5 will
* produce a looping delay that decreases in volume by
* 50% each repeat. A filter will cut out the high frequencies so
* that the delay does not sound as piercing as the original source.
* filter, and type. In the example below, a feedback of 0.5 (the
* defaul value) will produce a looping delay that decreases in
* volume by 50% each repeat. A filter will cut out the high
* frequencies so that the delay does not sound as piercing as the
* original source.
*
* @class p5.Delay
* @constructor
Expand Down Expand Up @@ -7117,6 +7115,8 @@ delay = function () {
// default routing
this.setType(0);
this._maxDelay = this.leftDelay.delayTime.maxValue;
// set initial feedback to 0.5
this.feedback(0.5);
// add this p5.SoundFile to the soundArray
p5sound.soundArray.push(this);
};
Expand Down Expand Up @@ -7148,8 +7148,8 @@ delay = function () {
src.connect(this.input);
this.leftDelay.delayTime.setValueAtTime(delayTime, this.ac.currentTime);
this.rightDelay.delayTime.setValueAtTime(delayTime, this.ac.currentTime);
this._leftGain.gain.setValueAtTime(feedback, this.ac.currentTime);
this._rightGain.gain.setValueAtTime(feedback, this.ac.currentTime);
this._leftGain.gain.value = feedback;
this._rightGain.gain.value = feedback;
if (_filter) {
this._leftFilter.freq(_filter);
this._rightFilter.freq(_filter);
Expand Down Expand Up @@ -7179,24 +7179,28 @@ delay = function () {
* in a loop. The feedback amount determines how much signal to send each
* time through the loop. A feedback greater than 1.0 is not desirable because
* it will increase the overall output each time through the loop,
* creating an infinite feedback loop.
* creating an infinite feedback loop. The default value is 0.5
*
* @method feedback
* @param {Number|Object} feedback 0.0 to 1.0, or an object such as an
* Oscillator that can be used to
* modulate this param
* @returns {Number} Feedback value
*
*/
p5.Delay.prototype.feedback = function (f) {
// if f is an audio node...
if (typeof f !== 'number') {
if (f && typeof f !== 'number') {
f.connect(this._leftGain.gain);
f.connect(this._rightGain.gain);
} else if (f >= 1) {
throw new Error('Feedback value will force a positive feedback loop.');
} else {
this._leftGain.gain.exponentialRampToValueAtTime(f, this.ac.currentTime);
this._rightGain.gain.exponentialRampToValueAtTime(f, this.ac.currentTime);
} else if (typeof f === 'number') {
this._leftGain.gain.value = f;
this._rightGain.gain.value = f;
}
// return value of feedback
return this._leftGain.gain.value;
};
/**
* Set a lowpass filter frequency for the delay. A lowpass filter
Expand Down
8 changes: 4 additions & 4 deletions lib/p5.sound.min.js

Large diffs are not rendered by default.

17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,22 @@
"type": "git",
"url": "https://github.com/processing/p5.js-sound.git"
},
"version": "0.3.2",
"version": "0.3.3",
"license": "MIT",
"devDependencies": {
"almond": "~0.2.7",
"amdclean": "~2.0",
"grunt": "~0.4.2",
"grunt-contrib-connect": "^1.0.2",
"grunt-contrib-jshint": "~0.6.3",
"grunt-contrib-nodeunit": "~0.2.0",
"grunt-contrib-watch": "~0.5.3",
"grunt-mocha": "~0.4.6",
"phantomjs": "~1.9.2-4",
"grunt-lib-phantomjs": "~0.4.0",
"grunt-contrib-requirejs": "~0.4.1",
"grunt-contrib-sass": "~0.7.2",
"grunt-contrib-watch": "~0.5.3",
"grunt-contrib-yuidoc": "0.5.2",
"almond": "~0.2.7",
"amdclean": "~2.0",
"grunt-contrib-sass": "~0.7.2"
"grunt-mocha": "~0.4.6",
"grunt-open": "^0.2.3",
"phantomjs": "~1.9.2-4"
},
"dependencies": {
"tone": "therewasaguy/tone.js#p5-dev"
Expand Down
3 changes: 0 additions & 3 deletions src/oscillator.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,6 @@ define(function (require) {
var rampTime = rampTime || 0;
var tFromNow = tFromNow || 0;
var now = p5sound.audiocontext.currentTime;
var currentVol = this.output.gain.value;
this.output.gain.cancelScheduledValues(now);
this.output.gain.linearRampToValueAtTime(currentVol, now + tFromNow);
this.output.gain.linearRampToValueAtTime(vol, now + tFromNow + rampTime);
}

Expand Down

0 comments on commit 55fda82

Please sign in to comment.