Skip to content

Commit

Permalink
Merge branch 'master' of github.com:processing/p5.js-sound into oscil…
Browse files Browse the repository at this point in the history
…lator
  • Loading branch information
endurance21 committed May 2, 2020
2 parents a22f3b3 + 374d306 commit 548e1ee
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 30 deletions.
2 changes: 1 addition & 1 deletion examples/peakDetect/sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function setup() {

src_length = source_file.duration();
source_file.playMode('restart');
println("source duration: " +src_length);
console.log("source duration: " +src_length);

// draw the waveform to an off-screen graphic
var peaks = source_file.getPeaks(); // get an array of peaks
Expand Down
2 changes: 1 addition & 1 deletion examples/peakDetection_offline/sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function setup() {

src_length = source_file.duration();
source_file.playMode('restart');
println("source duration: " +src_length);
console.log("source duration: " + src_length);

// find beat preprocessing the source file with lowpass
var beats = source_file.processPeaks(onComplete);
Expand Down
11 changes: 5 additions & 6 deletions src/audioin.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,9 @@ define(function (require) {

/**
* Returns a list of available input sources. This is a wrapper
* for <a title="MediaDevices.enumerateDevices() - Web APIs | MDN" target="_blank" href=
* "https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/enumerateDevices"
* > and it returns a Promise.
* for [MediaDevices.enumerateDevices() - Web APIs | MDN](https://developer.mozilla.org/
* en-US/docs/Web/API/MediaDevices/enumerateDevices)
* and it returns a Promise.
*
* @method getSources
* @for p5.AudioIn
Expand Down Expand Up @@ -321,9 +321,8 @@ define(function (require) {
* Set the input source. Accepts a number representing a
* position in the array returned by getSources().
* This is only available in browsers that support
* <a title="MediaDevices.enumerateDevices() - Web APIs | MDN" target="_blank" href=
* "https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/enumerateDevices"
* >navigator.mediaDevices.enumerateDevices()</a>.<br/>
* [navigator.mediaDevices.enumerateDevices()](https://developer.mozilla.org/
* en-US/docs/Web/API/MediaDevices/enumerateDevices)
*
* @method setSource
* @for p5.AudioIn
Expand Down
2 changes: 1 addition & 1 deletion src/envelope.js
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ define(function (require) {
* @param {Object} unit p5.sound Object or Web Audio Param
* @param {Number} secondsFromNow When to trigger the ramp
* @param {Number} v Target value
* @param {Number} [v2] Second target value (optional)
* @param {Number} [v2] Second target value
* @example
* <div><code>
* let env, osc, amp;
Expand Down
2 changes: 1 addition & 1 deletion src/fft.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ define(function(require) {
*
* @method getCentroid
* @for p5.FFT
* @return {Number} Spectral Centroid Frequency Frequency of the spectral centroid in Hz.
* @return {Number} Spectral Centroid Frequency of the spectral centroid in Hz.
*
*
* @example
Expand Down
13 changes: 6 additions & 7 deletions src/panner3d.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ define(function (require) {
* @class p5.Panner3D
* @constructor
*/

p5.Panner3D = function() {
Effect.call(this);

Expand All @@ -28,13 +29,11 @@ define(function (require) {
* "https://developer.mozilla.org/en-US/docs/Web/API/PannerNode">
* Web Audio Spatial Panner Node</a>
*
* Properties include
* - <a title="w3 spec for Panning Model"
* href="https://www.w3.org/TR/webaudio/#idl-def-PanningModelType"
* >panningModel</a>: "equal power" or "HRTF"
* - <a title="w3 spec for Distance Model"
* href="https://www.w3.org/TR/webaudio/#idl-def-DistanceModelType"
* >distanceModel</a>: "linear", "inverse", or "exponential"
* Properties include<br>
* [Panning Model](https://www.w3.org/TR/webaudio/#idl-def-PanningModelType)
* : "equal power" or "HRTF"<br>
* [DistanceModel](https://www.w3.org/TR/webaudio/#idl-def-DistanceModelType)
* : "linear", "inverse", or "exponential"
*
* @property {AudioNode} panner
*
Expand Down
8 changes: 6 additions & 2 deletions src/signal.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ define(function (require) {
* <p>p5.Signal is a constant audio-rate signal used by p5.Oscillator
* and p5.Envelope for modulation math.</p>
*
* <p>This is necessary because Web Audio is processed on a seprate clock.
* <p>This is necessary because Web Audio is processed on a separate clock.
* For example, the p5 draw loop runs about 60 times per second. But
* the audio clock must process samples 44100 times per second. If we
* want to add a value to each of those samples, we can't do it in the
Expand All @@ -31,6 +31,7 @@ define(function (require) {
* @example
* <div><code>
* let carrier, modulator;
* let hasStarted = false;
*
* function setup() {
* let cnv = createCanvas(100, 100);
Expand All @@ -39,7 +40,6 @@ define(function (require) {
* text('tap to play', 20, 20);
*
* carrier = new p5.Oscillator('sine');
* carrier.start();
* carrier.amp(1); // set amplitude
* carrier.freq(220); // set frequency
*
Expand All @@ -58,6 +58,10 @@ define(function (require) {
* function canvasPressed() {
* userStartAudio();
* carrier.amp(1.0);
* if(!hasStarted){
* carrier.start();
* hasStarted = true;
* }
* }
*
* function mouseReleased() {
Expand Down
2 changes: 1 addition & 1 deletion src/soundLoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ define(function (require) {


/**
* Synchronize loops. Use this method to start two more more loops in synchronization
* Synchronize loops. Use this method to start two or more loops in synchronization
* or to start a loop in synchronization with a loop that is already playing
* This method will schedule the implicit loop in sync with the explicit master loop
* i.e. loopToStart.syncedStart(loopToSyncWith)
Expand Down
4 changes: 2 additions & 2 deletions src/soundfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -1724,7 +1724,7 @@ define(function (require) {
/**
* Save a p5.SoundFile as a .wav file. The browser will prompt the user
* to download the file to their device. To upload a file to a server, see
* <a href="/docs/reference/#/p5.SoundFile/getBlob">getBlob</a>
* <a href="/reference/#/p5.SoundFile/getBlob">getBlob</a>
*
* @method save
* @for p5.SoundFile
Expand Down Expand Up @@ -1756,7 +1756,7 @@ define(function (require) {
* .wav-encoded audio data as a "<a target="_blank" title="Blob reference at
* MDN" href="https://developer.mozilla.org/en-US/docs/Web/API/Blob">Blob</a>".
* A Blob is a file-like data object that can be uploaded to a server
* with an <a href="/docs/reference/#/p5/httpDo">http</a> request. We'll
* with an <a href="/reference/#/p5/httpDo">http</a> request. We'll
* use the `httpDo` options object to send a POST request with some
* specific options: we encode the request as `multipart/form-data`,
* and attach the blob as one of the form values using `FormData`.
Expand Down
8 changes: 0 additions & 8 deletions test/tests/p5.SoundFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,6 @@ define(['chai'], function(chai) {
}, 100);
});

it('can getLevel', function(done) {
expect( sf.isPlaying() ).to.equal(true);
setTimeout(function() {
expect(sf.getLevel()).not.equal(0.0);
done();
}, 100);
});

var peaks, firstPeak;
it('can get peaks', function() {
peaks = sf.getPeaks(sf.buffer.length);
Expand Down

0 comments on commit 548e1ee

Please sign in to comment.