From 9760dd0242099588897ef37846e8f7e846ccb86f Mon Sep 17 00:00:00 2001 From: Jason Sigal Date: Mon, 6 Jan 2020 00:28:37 -0500 Subject: [PATCH] update inline examples (#388) (#403) - Update inline examples to start audio context on a user gesture, either by playing a sound (soundFile.play() / oscillator.start()) or by explicitly calling userStartAudio() #388 - Use let in examples, instead of var, but not const, as discussed in this issue where it was decided to use let exclusively in examples: processing/p5.js#3877 - Update styles for consistency with other p5 inline examples Some examples use soundFile.play() or oscillator.start() rather than a potentially redundant call to userStartAudio(). It might be worth that redundant call, because the difference between methods that call "start" on a WebAudio node (thus enabling audio on a user gesture) and those that do not is pretty obfuscated... --- fragments/before.frag | 58 ++++---- src/amplitude.js | 83 ++++++----- src/audiocontext.js | 60 ++++---- src/audioin.js | 55 ++++++-- src/delay.js | 41 +++--- src/envelope.js | 313 ++++++++++++++++++++---------------------- src/eq.js | 53 ++++--- src/fft.js | 111 ++++++++------- src/filter.js | 96 ++++++------- src/gain.js | 110 +++++++-------- src/helpers.js | 43 ++++-- src/looper.js | 70 ++++------ src/master.js | 15 +- src/monosynth.js | 84 +++++++----- src/oscillator.js | 85 +++++++----- src/polysynth.js | 95 +++++++------ src/pulse.js | 21 ++- src/reverb.js | 59 ++++++-- src/signal.js | 22 ++- src/soundLoop.js | 53 ++++--- src/soundRecorder.js | 21 ++- src/soundfile.js | 231 ++++++++++++++++++------------- 22 files changed, 1010 insertions(+), 769 deletions(-) diff --git a/fragments/before.frag b/fragments/before.frag index cafe1bb7..e85faada 100644 --- a/fragments/before.frag +++ b/fragments/before.frag @@ -1,40 +1,46 @@ /** - * p5.sound extends p5 with p5.sound extends p5 with Web Audio functionality including audio input, * playback, analysis and synthesis. - *

- * p5.SoundFile: Load and play sound files.
- * p5.Amplitude: Get the current volume of a sound.
- * p5.AudioIn: Get sound from an input source, typically - * a computer microphone.
- * p5.FFT: Analyze the frequency of sound. Returns - * results from the frequency spectrum or time domain (waveform).
- * p5.Oscillator: Generate Sine, + *

+ *