diff --git a/src/analysis/FFT.js b/src/analysis/FFT.js index 1a0abdc..dbd63cc 100644 --- a/src/analysis/FFT.js +++ b/src/analysis/FFT.js @@ -85,6 +85,48 @@ class FFT extends p5soundNode { * @method analyze * @for FFT * @returns {Array} Array of amplitude values from 0 to 1. + * @example + *
+ * let soundfile, fft;
+ *
+ * async function setup() {
+ * createCanvas(100, 100);
+ * soundfile = await loadSound('assets/chime.mp3');
+ * textAlign(CENTER);
+ * textSize(10);
+ *
+ * fft = new p5.FFT();
+ * soundfile.connect(fft);
+ * soundfile.loop();
+ * }
+ *
+ * function mousePressed() {
+ * if(!soundfile.isPlaying()) {
+ * soundfile.play();
+ * }
+ * else {
+ * soundfile.stop();
+ * }
+ * }
+ *
+ * function draw() {
+ * background(220);
+ *
+ * text('tap to play', width/2, height/2 - 20);
+ * let spectrum = fft.analyze();
+ *
+ * noStroke();
+ * fill(0);
+ *
+ * for (let i = 0; i < spectrum.length; i++) {
+ * let x = map(i, 0, spectrum.length, 0, width);
+ * let h = -height + map(spectrum[i], 0, 0.1, height, 0);
+ * rect(x, height, width / spectrum.length, h * 4)
+ * }
+ * }
+ *
+ *
+ * let soundfile, fft;
+ * async function setup() {
+ * createCanvas(100, 100);
+ * soundfile = await loadSound('assets/chime.mp3');
+ * textAlign(CENTER);
+ * textSize(10);
+ *
+ * fft = new p5.FFT();
+ * soundfile.connect(fft);
+ * soundfile.loop();
+ * }
+ *
+ * function mousePressed() {
+ * if(!soundfile.isPlaying()) {
+ * soundfile.play();
+ * }
+ * else {
+ * soundfile.stop();
+ * }
+ * }
+ *
+ * function draw() {
+ * background(220);
+ *
+ * text('tap to play', width/2, height/2 - 20);
+ * let waveform = fft.waveform();
+ * noFill();
+ * beginShape();
+ * stroke(20);
+ * for (let i = 0; i < waveform.length; i++){
+ * let x = map(i, 0, waveform.length, 0, width);
+ * let y = map( waveform[i], -1, 1, 0, height);
+ * vertex(x,y);
+ * }
+ * endShape();
+ * }
+ *
+ *
+ * let delay, osc;
+ *
+ * function setup() {
+ * createCanvas(100, 100);
+ * textAlign(CENTER);
+ * text('tap to play', width/2, height/2);
+ *
+ * osc = new p5.Oscillator('sine');
+ * osc.disconnect();
+ * delay = new p5.Delay();
+ * //use the delay effect to process the oscillator with a delay time of 0.240 seconds and a feedback amount of 0.7
+ * delay.process(osc, 0.240, 0.7);
+ * }
+ *
+ * function mousePressed() {
+ * osc.start();
+ * }
+ *
+ * function mouseReleased() {
+ * osc.stop();
+ * }
+ *
+ * function draw() {
+ * background(220)
+ * let dtime = map(mouseX, 0, width, 0.1, 0.5);
+ * delay.delayTime(dtime);
+ * let feedback = map(mouseY, 0, height, 0.1, 0.99);
+ * delay.feedback(feedback);
+ * if(!osc.started) {
+ * text('tap to play', width/2, height/2);
+ * }
+ * else {
+ * text('delay time: ' + dtime.toFixed(2), width/2, height/2);
+ * text('feedback: ' + feedback.toFixed(2), width/2, height/2 + 20);
+ * }
+ * }
+ *
- * let cnv, pitchShifter;
+ * let pitchShifter;
*
* async function setup() {
* describe('a sketch that pitches the microphone input up an octave');
@@ -53,7 +53,7 @@ class PitchShifter extends p5soundNode {
* @example
*
*
- * let cnv, pitchShifter;
+ * let pitchShifter;
*
* async function setup() {
* describe('a sketch that pitches the microphone input up an octave');
diff --git a/src/sources/AudioIn.js b/src/sources/AudioIn.js
index 566c63b..66ee8aa 100644
--- a/src/sources/AudioIn.js
+++ b/src/sources/AudioIn.js
@@ -56,7 +56,7 @@ class AudioIn extends p5soundSource {
this.node = new ToneUserMedia().connect(this.output);
}
/**
- * Start the audio input.
+ * Start the audio input device.
* @method start
* @for AudioIn
* @example
@@ -108,7 +108,7 @@ class AudioIn extends p5soundSource {
});
}
/**
- * Stop the audio input.
+ * Stop the audio input device.
* @method stop
* @for AudioIn
* @example
diff --git a/src/sources/Noise.js b/src/sources/Noise.js
index 0878cf9..1515c29 100644
--- a/src/sources/Noise.js
+++ b/src/sources/Noise.js
@@ -54,7 +54,7 @@ class Noise extends p5soundSource {
/**
* Changes the type of noise function.
*
- * White noise is brighter and more "full spectrum" while 'pink' and 'brown' noise is a bit darker.
+ * White noise is brighter and has a wider spectrum while 'pink' and 'brown' noise sound warmer.
* @method type
* @for Noise
* @param {String} type the type of noise (white, pink, brown)
diff --git a/src/sources/SoundFile.js b/src/sources/SoundFile.js
index 28a56b7..9a56435 100644
--- a/src/sources/SoundFile.js
+++ b/src/sources/SoundFile.js
@@ -113,7 +113,7 @@ class SoundFile extends p5soundSource {
}
/**
- * Start the soundfile.
+ * Start the soundfile. Same as the play() method.
* @method start
* @for SoundFile
* @example