Skip to content

Commit 41d6d1d

Browse files
committed
p5.Gain connectSource --> setInput
1 parent 5ffff52 commit 41d6d1d

File tree

3 files changed

+98
-98
lines changed

3 files changed

+98
-98
lines changed

lib/p5.sound.js

Lines changed: 68 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -6867,70 +6867,70 @@ gain = function () {
68676867
'use strict';
68686868
var p5sound = master;
68696869
/**
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+
*/
69346934
p5.Gain = function () {
69356935
this.ac = p5sound.audiocontext;
69366936
this.input = this.ac.createGain();
@@ -6942,11 +6942,11 @@ gain = function () {
69426942
/**
69436943
* Connect a source to the gain node.
69446944
*
6945-
* @method connectSource
6945+
* @method setInput
69466946
* @param {Object} src p5.sound / Web Audio object with a sound
69476947
* output.
69486948
*/
6949-
p5.Gain.prototype.connectSource = function (src) {
6949+
p5.Gain.prototype.setInput = function (src) {
69506950
src.connect(this.input);
69516951
};
69526952
/**
@@ -6982,8 +6982,8 @@ gain = function () {
69826982
var now = p5sound.audiocontext.currentTime;
69836983
var currentVol = this.output.gain.value;
69846984
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);
69876987
};
69886988
}(master, sndcore);
69896989
var src_app;

0 commit comments

Comments
 (0)