@@ -6867,70 +6867,70 @@ gain = function () {
6867
6867
'use strict' ;
6868
6868
var p5sound = master ;
6869
6869
/**
6870
- * A gain node is usefull to set the relative volume of sound.
6871
- * It's typically used to build mixers.
6872
- *
6873
- * @class p5.Gain
6874
- * @constructor
6875
- * @example
6876
- * <div><code>
6877
- *
6878
- * // load two soundfile and crossfade beetween them
6879
- * var sound1,sound2;
6880
- * var gain1, gain2, gain3;
6881
- *
6882
- * function preload(){
6883
- * soundFormats('ogg', 'mp3');
6884
- * sound1 = loadSound('../_files/Damscray_-_Dancing_Tiger_01');
6885
- * sound2 = loadSound('../_files/beat.mp3');
6886
- * }
6887
- *
6888
- * function setup() {
6889
- * createCanvas(400,200);
6890
- *
6891
- * // create a 'master' gain to which we will connect both soundfiles
6892
- * gain3 = new p5.Gain();
6893
- * gain3.connect();
6894
- *
6895
- * // setup first sound for playing
6896
- * sound1.rate(1);
6897
- * sound1.loop();
6898
- * sound1.disconnect(); // diconnect from p5 output
6899
- *
6900
- * gain1 = new p5.Gain(); // setup a gain node
6901
- * gain1.connectSource (sound1); // connect the first sound to its input
6902
- * gain1.connect(gain3); // connect its output to the 'master'
6903
- *
6904
- * sound2.rate(1);
6905
- * sound2.disconnect();
6906
- * sound2.loop();
6907
- *
6908
- * gain2 = new p5.Gain();
6909
- * gain2.connectSource (sound2);
6910
- * gain2.connect(gain3);
6911
- *
6912
- * }
6913
- *
6914
- * function draw(){
6915
- * background(180);
6916
- *
6917
- * // calculate the horizontal distance beetween the mouse and the right of the screen
6918
- * var d = dist(mouseX,0,width,0);
6919
- *
6920
- * // map the horizontal position of the mouse to values useable for volume control of sound1
6921
- * var vol1 = map(mouseX,0,width,0,1);
6922
- * var vol2 = 1-vol1; // when sound1 is loud, sound2 is quiet and vice versa
6923
- *
6924
- * gain1.amp(vol1,0.5,0);
6925
- * gain2.amp(vol2,0.5,0);
6926
- *
6927
- * // map the vertical position of the mouse to values useable for 'master volume control'
6928
- * var vol3 = map(mouseY,0,height,0,1);
6929
- * gain3.amp(vol3,0.5,0);
6930
- * }
6931
- *</code></div>
6932
- *
6933
- */
6870
+ * A gain node is usefull to set the relative volume of sound.
6871
+ * It's typically used to build mixers.
6872
+ *
6873
+ * @class p5.Gain
6874
+ * @constructor
6875
+ * @example
6876
+ * <div><code>
6877
+ *
6878
+ * // load two soundfile and crossfade beetween them
6879
+ * var sound1,sound2;
6880
+ * var gain1, gain2, gain3;
6881
+ *
6882
+ * function preload(){
6883
+ * soundFormats('ogg', 'mp3');
6884
+ * sound1 = loadSound('../_files/Damscray_-_Dancing_Tiger_01');
6885
+ * sound2 = loadSound('../_files/beat.mp3');
6886
+ * }
6887
+ *
6888
+ * function setup() {
6889
+ * createCanvas(400,200);
6890
+ *
6891
+ * // create a 'master' gain to which we will connect both soundfiles
6892
+ * gain3 = new p5.Gain();
6893
+ * gain3.connect();
6894
+ *
6895
+ * // setup first sound for playing
6896
+ * sound1.rate(1);
6897
+ * sound1.loop();
6898
+ * sound1.disconnect(); // diconnect from p5 output
6899
+ *
6900
+ * gain1 = new p5.Gain(); // setup a gain node
6901
+ * gain1.setInput (sound1); // connect the first sound to its input
6902
+ * gain1.connect(gain3); // connect its output to the 'master'
6903
+ *
6904
+ * sound2.rate(1);
6905
+ * sound2.disconnect();
6906
+ * sound2.loop();
6907
+ *
6908
+ * gain2 = new p5.Gain();
6909
+ * gain2.setInput (sound2);
6910
+ * gain2.connect(gain3);
6911
+ *
6912
+ * }
6913
+ *
6914
+ * function draw(){
6915
+ * background(180);
6916
+ *
6917
+ * // calculate the horizontal distance beetween the mouse and the right of the screen
6918
+ * var d = dist(mouseX,0,width,0);
6919
+ *
6920
+ * // map the horizontal position of the mouse to values useable for volume control of sound1
6921
+ * var vol1 = map(mouseX,0,width,0,1);
6922
+ * var vol2 = 1-vol1; // when sound1 is loud, sound2 is quiet and vice versa
6923
+ *
6924
+ * gain1.amp(vol1,0.5,0);
6925
+ * gain2.amp(vol2,0.5,0);
6926
+ *
6927
+ * // map the vertical position of the mouse to values useable for 'master volume control'
6928
+ * var vol3 = map(mouseY,0,height,0,1);
6929
+ * gain3.amp(vol3,0.5,0);
6930
+ * }
6931
+ *</code></div>
6932
+ *
6933
+ */
6934
6934
p5 . Gain = function ( ) {
6935
6935
this . ac = p5sound . audiocontext ;
6936
6936
this . input = this . ac . createGain ( ) ;
@@ -6942,11 +6942,11 @@ gain = function () {
6942
6942
/**
6943
6943
* Connect a source to the gain node.
6944
6944
*
6945
- * @method connectSource
6945
+ * @method setInput
6946
6946
* @param {Object } src p5.sound / Web Audio object with a sound
6947
6947
* output.
6948
6948
*/
6949
- p5 . Gain . prototype . connectSource = function ( src ) {
6949
+ p5 . Gain . prototype . setInput = function ( src ) {
6950
6950
src . connect ( this . input ) ;
6951
6951
} ;
6952
6952
/**
@@ -6982,8 +6982,8 @@ gain = function () {
6982
6982
var now = p5sound . audiocontext . currentTime ;
6983
6983
var currentVol = this . output . gain . value ;
6984
6984
this . output . gain . cancelScheduledValues ( now ) ;
6985
- this . output . gain . linearRampToValueAtTime ( currentVol , now + tFromNow + 0.001 ) ;
6986
- this . output . gain . linearRampToValueAtTime ( vol , now + tFromNow + rampTime + 0.001 ) ;
6985
+ this . output . gain . linearRampToValueAtTime ( currentVol , now + tFromNow ) ;
6986
+ this . output . gain . linearRampToValueAtTime ( vol , now + tFromNow + rampTime ) ;
6987
6987
} ;
6988
6988
} ( master , sndcore ) ;
6989
6989
var src_app ;
0 commit comments