diff --git a/public/reference/data.json b/public/reference/data.json index edb525782a..d1965ffbf3 100644 --- a/public/reference/data.json +++ b/public/reference/data.json @@ -2,7 +2,7 @@ "project": { "name": "p5", "description": "[](https://www.npmjs.com/package/p5)", - "version": "1.11.2", + "version": "1.11.3", "url": "https://github.com/processing/p5.js#readme" }, "files": { @@ -914,197 +914,6 @@ "classes": {}, "fors": {}, "namespaces": {} - }, - "src/Amplitude.js": { - "name": "src/Amplitude.js", - "modules": { - "p5.sound": 1 - }, - "classes": { - "Amplitude": 1 - }, - "fors": { - "p5.sound": 1, - "Amplitude": 1 - }, - "namespaces": {} - }, - "src/AudioIn.js": { - "name": "src/AudioIn.js", - "modules": {}, - "classes": { - "AudioIn": 1 - }, - "fors": { - "p5.sound": 1, - "AudioIn": 1 - }, - "namespaces": {} - }, - "src/Biquad.js": { - "name": "src/Biquad.js", - "modules": {}, - "classes": { - "Biquad": 1, - "LowPass": 1, - "HighPass": 1, - "BandPass": 1 - }, - "fors": { - "p5.sound": 1, - "Biquad": 1 - }, - "namespaces": {} - }, - "src/Delay.js": { - "name": "src/Delay.js", - "modules": {}, - "classes": { - "Delay": 1 - }, - "fors": { - "p5.sound": 1, - "Delay": 1 - }, - "namespaces": {} - }, - "src/Envelope.js": { - "name": "src/Envelope.js", - "modules": {}, - "classes": { - "Envelope": 1 - }, - "fors": { - "p5.sound": 1, - "Envelope": 1 - }, - "namespaces": {} - }, - "src/FFT.js": { - "name": "src/FFT.js", - "modules": {}, - "classes": { - "FFT": 1 - }, - "fors": { - "p5.sound": 1, - "FFT": 1 - }, - "namespaces": {} - }, - "src/Gain.js": { - "name": "src/Gain.js", - "modules": {}, - "classes": { - "Gain": 1 - }, - "fors": { - "p5.sound": 1, - "Gain": 1 - }, - "namespaces": {} - }, - "src/Noise.js": { - "name": "src/Noise.js", - "modules": {}, - "classes": { - "Noise": 1 - }, - "fors": { - "p5.sound": 1, - "Noise": 1 - }, - "namespaces": {} - }, - "src/Oscillator.js": { - "name": "src/Oscillator.js", - "modules": {}, - "classes": { - "Oscillator": 1, - "SawOsc": 1, - "SqrOsc": 1, - "TriOsc": 1, - "SinOsc": 1 - }, - "fors": { - "p5.sound": 1, - "Oscillator": 1 - }, - "namespaces": {} - }, - "src/Panner.js": { - "name": "src/Panner.js", - "modules": {}, - "classes": { - "Panner": 1 - }, - "fors": { - "p5.sound": 1, - "Panner": 1 - }, - "namespaces": {} - }, - "src/Panner3D.js": { - "name": "src/Panner3D.js", - "modules": {}, - "classes": { - "Panner3D": 1 - }, - "fors": { - "p5.sound": 1, - "Panner3D": 1 - }, - "namespaces": {} - }, - "src/PitchShifter.js": { - "name": "src/PitchShifter.js", - "modules": {}, - "classes": { - "PitchShifter": 1 - }, - "fors": { - "p5.sound": 1, - "PitchShifter": 1 - }, - "namespaces": {} - }, - "src/Reverb.js": { - "name": "src/Reverb.js", - "modules": {}, - "classes": { - "Reverb": 1 - }, - "fors": { - "p5.sound": 1, - "Reverb": 1 - }, - "namespaces": {} - }, - "src/SoundFile.js": { - "name": "src/SoundFile.js", - "modules": { - "SoundFile": 1 - }, - "classes": { - "SoundFile": 1 - }, - "fors": { - "p5.sound": 1, - "sound": 1, - "SoundFile": 1 - }, - "namespaces": {} - }, - "src/Utils.js": { - "name": "src/Utils.js", - "modules": { - "Sound Utilities": 1 - }, - "classes": {}, - "fors": { - "sound": 1 - }, - "namespaces": {} } }, "modules": { @@ -2081,106 +1890,79 @@ }, "p5.sound": { "name": "p5.sound", - "submodules": { - "SoundFile": 1 - }, - "elements": {}, - "classes": { - "p5.sound": 1, - "Amplitude": 1, - "AudioIn": 1, - "Biquad": 1, - "LowPass": 1, - "HighPass": 1, - "BandPass": 1, - "Delay": 1, - "Envelope": 1, - "FFT": 1, - "Gain": 1, - "Noise": 1, - "Oscillator": 1, - "SawOsc": 1, - "SqrOsc": 1, - "TriOsc": 1, - "SinOsc": 1, - "Panner": 1, - "Panner3D": 1, - "PitchShifter": 1, - "Reverb": 1, - "sound": 1, - "SoundFile": 1 - }, - "fors": { - "p5.sound": 1, - "Amplitude": 1, - "AudioIn": 1, - "Biquad": 1, - "Delay": 1, - "Envelope": 1, - "FFT": 1, - "Gain": 1, - "Noise": 1, - "Oscillator": 1, - "Panner": 1, - "Panner3D": 1, - "PitchShifter": 1, - "Reverb": 1, - "sound": 1, - "SoundFile": 1 - }, - "namespaces": {}, - "module": "p5.sound", - "file": "src/SoundFile.js", - "line": 60, - "description": "Get the current volume of a sound." - }, - "SoundFile": { - "name": "SoundFile", "submodules": {}, "elements": {}, "classes": { - "sound": 1, - "SoundFile": 1 + "p5.sound": 1, + "p5.SoundFile": 1, + "p5.Amplitude": 1, + "p5.FFT": 1, + "p5.Oscillator": 1, + "p5.SinOsc": 1, + "p5.TriOsc": 1, + "p5.SawOsc": 1, + "p5.SqrOsc": 1, + "p5.Envelope": 1, + "p5.Noise": 1, + "p5.Pulse": 1, + "p5.AudioIn": 1, + "p5.Effect": 1, + "p5.Filter": 1, + "p5.LowPass": 1, + "p5.HighPass": 1, + "p5.BandPass": 1, + "p5.EQ": 1, + "p5.Panner3D": 1, + "p5.Delay": 1, + "p5.Reverb": 1, + "p5.Convolver": 1, + "p5.Phrase": 1, + "p5.Part": 1, + "p5.Score": 1, + "p5.SoundLoop": 1, + "p5.Compressor": 1, + "p5.PeakDetect": 1, + "p5.SoundRecorder": 1, + "p5.Distortion": 1, + "p5.Gain": 1, + "p5.AudioVoice": 1, + "p5.MonoSynth": 1, + "p5.OnsetDetect": 1, + "p5.PolySynth": 1 }, "fors": { "p5.sound": 1, - "sound": 1, - "SoundFile": 1 + "p5": 1, + "p5.SoundFile": 1, + "p5.Amplitude": 1, + "p5.FFT": 1, + "p5.Oscillator": 1, + "p5.Envelope": 1, + "p5.AudioIn": 1, + "p5.Effect": 1, + "p5.EQ": 1, + "p5.Panner3D": 1, + "p5.Delay": 1, + "p5.Reverb": 1, + "p5.Convolver": 1, + "p5.Part": 1, + "p5.Score": 1, + "p5.SoundLoop": 1, + "p5.Compressor": 1, + "p5.SoundRecorder": 1, + "p5.Distortion": 1, + "p5.Gain": 1, + "p5.AudioVoice": 1, + "p5.MonoSynth": 1, + "p5.PolySynth": 1 }, - "is_submodule": 1, "namespaces": {}, "module": "p5.sound", - "namespace": "", - "file": "src/SoundFile.js", - "line": 60, - "description": "p5.sound.js extends p5.js with Web Audio functionality including audio input, playback, analysis and synthesis." - }, - "Sound": { - "name": "Sound", - "submodules": { - "Sound Utilities": 1 - }, - "elements": {}, - "classes": {}, - "fors": { - "sound": 1 - }, - "namespaces": {} - }, - "Sound Utilities": { - "name": "Sound Utilities", - "submodules": {}, - "elements": {}, - "classes": {}, - "fors": { - "sound": 1 - }, - "is_submodule": 1, - "namespaces": {}, - "module": "Sound", - "namespace": "", - "file": "src/Utils.js", - "line": 1 + "file": "lib/addons/p5.sound.js", + "line": 11691, + "description": "
p5.sound extends p5 with Web Audio functionality including audio input,\nplayback, analysis and synthesis.\n
\np5.sound is on GitHub.\nDownload the latest version\nhere.
", + "tag": "main", + "itemtype": "main" } }, "classes": { @@ -2772,7 +2554,7 @@ "namespace": "", "file": "src/webgl/p5.Shader.js", "line": 11, - "description": "A class to describe a shader program.
\nEach p5.Shader
object contains a shader program that runs on the graphics\nprocessing unit (GPU). Shaders can process many pixels or vertices at the\nsame time, making them fast for many graphics tasks. They’re written in a\nlanguage called\nGLSL\nand run along with the rest of the code in a sketch.
A shader program consists of two files, a vertex shader and a fragment\nshader. The vertex shader affects where 3D geometry is drawn on the screen\nand the fragment shader affects color. Once the p5.Shader
object is\ncreated, it can be used with the shader()\nfunction, as in shader(myShader)
.
A shader can optionally describe hooks, which are functions in GLSL that\nusers may choose to provide to customize the behavior of the shader. For the\nvertex or the fragment shader, users can pass in an object where each key is\nthe type and name of a hook function, and each value is a string with the\nparameter list and default implementation of the hook. For example, to let users\noptionally run code at the start of the vertex shader, the options object could\ninclude:
\n{\n vertex: {\n 'void beforeVertex': '() {}'\n }\n}\n
\nThen, in your vertex shader source, you can run a hook by calling a function\nwith the same name prefixed by HOOK_
:
void main() {\n HOOK_beforeVertex();\n // Add the rest ofy our shader code here!\n}\n
\nNote: createShader(),\ncreateFilterShader(), and\nloadShader() are the recommended ways to\ncreate an instance of this class.
\n", + "description": "A class to describe a shader program.
\nEach p5.Shader
object contains a shader program that runs on the graphics\nprocessing unit (GPU). Shaders can process many pixels or vertices at the\nsame time, making them fast for many graphics tasks. They’re written in a\nlanguage called\nGLSL\nand run along with the rest of the code in a sketch.
A shader program consists of two files, a vertex shader and a fragment\nshader. The vertex shader affects where 3D geometry is drawn on the screen\nand the fragment shader affects color. Once the p5.Shader
object is\ncreated, it can be used with the shader()\nfunction, as in shader(myShader)
.
A shader can optionally describe hooks, which are functions in GLSL that\nusers may choose to provide to customize the behavior of the shader. For the\nvertex or the fragment shader, users can pass in an object where each key is\nthe type and name of a hook function, and each value is a string with the\nparameter list and default implementation of the hook. For example, to let users\noptionally run code at the start of the vertex shader, the options object could\ninclude:
\n{\n vertex: {\n 'void beforeVertex': '() {}'\n }\n}\n
\nThen, in your vertex shader source, you can run a hook by calling a function\nwith the same name prefixed by HOOK_
:
void main() {\n HOOK_beforeVertex();\n // Add the rest of your shader code here!\n}\n
\nNote: createShader(),\ncreateFilterShader(), and\nloadShader() are the recommended ways to\ncreate an instance of this class.
\n", "is_constructor": 1, "params": [ { @@ -2803,38 +2585,63 @@ }, "p5.sound": { "name": "p5.sound", - "shortname": "sound", + "shortname": "p5.sound", "classitems": [], "plugins": [], "extensions": [], "plugin_for": [], "extension_for": [], "module": "p5.sound", - "submodule": "SoundFile", + "submodule": "p5.sound", "namespace": "" }, "p5.SoundFile": { "name": "p5.SoundFile", - "shortname": "SoundFile", + "shortname": "p5.SoundFile", "classitems": [], "plugins": [], "extensions": [], "plugin_for": [], "extension_for": [], "module": "p5.sound", - "submodule": "SoundFile", + "submodule": "p5.sound", "namespace": "", - "file": "src/SoundFile.js", - "line": 60, - "description": "Load and play sound files.", + "file": "lib/addons/p5.sound.js", + "line": 1405, + "description": "SoundFile object with a path to a file.
\n\nThe p5.SoundFile may not be available immediately because\nit loads the file information asynchronously.
\n\nTo do something with the sound as soon as it loads\npass the name of a function as the second parameter.
\n\nOnly one file path is required. However, audio file formats\n(i.e. mp3, ogg, wav and m4a/aac) are not supported by all\nweb browsers. If you want to ensure compatability, instead of a single\nfile path, you may include an Array of filepaths, and the browser will\nchoose a format that works.
", "is_constructor": 1, + "params": [ + { + "name": "path", + "description": "path to a sound file (String). Optionally,\n you may include multiple file formats in\n an array. Alternately, accepts an object\n from the HTML5 File API, or a p5.File.
\n", + "type": "String|Array" + }, + { + "name": "successCallback", + "description": "Name of a function to call once file loads
\n", + "type": "Function", + "optional": true + }, + { + "name": "errorCallback", + "description": "Name of a function to call if file fails to\n load. This function will receive an error or\n XMLHttpRequest object with information\n about what went wrong.
\n", + "type": "Function", + "optional": true + }, + { + "name": "whileLoadingCallback", + "description": "Name of a function to call while file\n is loading. That function will\n receive progress of the request to\n load the sound file\n (between 0 and 1) as its first\n parameter. This progress\n does not account for the additional\n time needed to decode the audio data.
\n", + "type": "Function", + "optional": true + } + ], "example": [ - "\n\nlet sound, amp, delay, cnv;\n\nfunction preload() {\n //replace this sound with something local with rights to distribute\n //need to fix local asset loading first though :) \n sound = loadSound('/assets/doorbell.mp3');\n}\n\nfunction setup() {\n cnv = createCanvas(100, 100);\n textAlign(CENTER);\n cnv.mousePressed(playSound);\n amp = new p5.Amplitude();\n delay = new p5.Delay();\n sound.disconnect();\n sound.connect(delay);\n delay.connect(amp);\n}\n\nfunction playSound() {\n sound.play();\n}\n\nfunction draw() {\n let dtime = map(mouseX, 0, width, 0, 1);\n delay.delayTime(dtime);\n let f = map(mouseY, 0, height, 0, .75);\n delay.feedback(f);\n let level = map(amp.getLevel(), 0, 0.5, 0, 255);\n background(level, 0, 0);\n fill(255);\n text('click to play', width/2, 20);\n }\n
\n\nlet mySound;\nfunction preload() {\n soundFormats('mp3', 'ogg');\n mySound = loadSound('assets/doorbell');\n}\n\nfunction setup() {\n let cnv = createCanvas(100, 100);\n cnv.mousePressed(canvasPressed);\n background(220);\n text('tap here to play', 10, 20);\n}\n\nfunction canvasPressed() {\n // playing a sound file on a user gesture\n // is equivalent to `userStartAudio()`\n mySound.play();\n}\n
Amplitude measures volume between 0.0 and 1.0.\nListens to all p5sound by default, or use setInput()\nto listen to a specific sound source. Accepts an optional\nsmoothing value, which defaults to 0.
\n", "is_constructor": 1, "params": [ { "name": "smoothing", - "description": "Smooth the amplitude analysis by averaging with the last analysis frame. 0.0 is no time averaging with the last analysis frame.", + "description": "between 0.0 and .999 to smooth\n amplitude readings (defaults to 0)
\n", "type": "Number", "optional": true } ], "example": [ - "\n\nlet sound, amp, cnv;\n \nfunction preload() {\n //replace this sound with something local with rights to distribute\n sound = loadSound('/assets/Damscray_DancingTiger.mp3');\n}\n\nfunction setup() {\n cnv = createCanvas(100, 100);\n cnv.mousePressed(playSound);\n textAlign(CENTER);\n fill(255);\n amp = new p5.Amplitude();\n sound.connect(amp);\n}\n\nfunction playSound() {\n sound.play();\n}\n\nfunction draw() {\n let level = amp.getLevel();\n level = map(level, 0, 0.2, 0, 255);\n background(level, 0, 0);\n text('tap to play', width/2, 20);\n describe('The color of the background changes based on the amplitude of the sound.');\n}\n
\n\nlet sound, amplitude;\n\nfunction preload(){\n sound = loadSound('assets/beat.mp3');\n}\nfunction setup() {\n let cnv = createCanvas(100,100);\n cnv.mouseClicked(togglePlay);\n amplitude = new p5.Amplitude();\n}\n\nfunction draw() {\n background(220);\n text('tap to play', 20, 20);\n\n let level = amplitude.getLevel();\n let size = map(level, 0, 1, 0, 200);\n ellipse(width/2, height/2, size, size);\n}\n\nfunction togglePlay() {\n if (sound.isPlaying() ){\n sound.pause();\n } else {\n sound.loop();\n\t\tamplitude = new p5.Amplitude();\n\t\tamplitude.setInput(sound);\n }\n}\n\n
FFT (Fast Fourier Transform) is an analysis algorithm that\nisolates individual\n\naudio frequencies within a waveform.
\n\nOnce instantiated, a p5.FFT object can return an array based on\ntwo types of analyses:
• FFT.waveform()
computes\namplitude values along the time domain. The array indices correspond\nto samples across a brief moment in time. Each value represents\namplitude of the waveform at that sample of time.
\n• FFT.analyze()
computes amplitude values along the\nfrequency domain. The array indices correspond to frequencies (i.e.\npitches), from the lowest to the highest that humans can hear. Each\nvalue represents amplitude at that slice of the frequency spectrum.\nUse with getEnergy()
to measure amplitude at specific\nfrequencies, or within a range of frequencies.
FFT analyzes a very short snapshot of sound called a sample\nbuffer. It returns an array of amplitude measurements, referred\nto as bins
. The array is 1024 bins long by default.\nYou can change the bin array length, but it must be a power of 2\nbetween 16 and 1024 in order for the FFT algorithm to function\ncorrectly. The actual size of the FFT buffer is twice the\nnumber of bins, so given a standard sample rate, the buffer is\n2048/44100 seconds long.
Smooth results of Freq Spectrum.\n 0.0 < smoothing < 1.0.\n Defaults to 0.8.
\n", "type": "Number", "optional": true - } - ], + }, + { + "name": "bins", + "description": "Length of resulting array.\n Must be a power of two between\n 16 and 1024. Defaults to 1024.
\n", + "type": "Number", + "optional": true + } + ], "example": [ - "\n\nlet osc;\n\nfunction setup(){\n let cnv = createCanvas(100,100);\n cnv.mouseClicked(togglePlay);\n fft = new p5.FFT(32);\n osc = new p5.TriOsc(440);\n osc.connect(fft);\n}\n\nfunction draw(){\n background(220);\n let spectrum = fft.analyze();\n noStroke();\n fill(255, 0, 0);\n\n for (let i = 0; i < spectrum.length; i++) {\n let x = map(i, 0, spectrum.length, 0, width); \n let h = -height + map(spectrum[i], 0, 0.1, height, 0);\n rect(x, height, width / spectrum.length, h )\n }\n\n let waveform = fft.waveform();\n noFill();\n beginShape();\n stroke(20);\n \n for (let i = 0; i < waveform.length; i++){\n let x = map(i, 0, waveform.length, 0, width);\n let y = map( waveform[i], -1, 1, 0, height);\n vertex(x,y);\n }\n endShape();\n \n textAlign(CENTER);\n text('tap to play', width/2, 20);\n osc.freq(map(mouseX, 0, width, 100, 2000));\n describe('The sketch displays the frequency spectrum and waveform of the sound that plays.');\n}\n\nfunction togglePlay() {\n osc.start();\n}\n
\n\nfunction preload(){\n sound = loadSound('assets/Damscray_DancingTiger.mp3');\n}\n\nfunction setup(){\n let cnv = createCanvas(100,100);\n cnv.mouseClicked(togglePlay);\n fft = new p5.FFT();\n sound.amp(0.2);\n}\n\nfunction draw(){\n background(220);\n\n let spectrum = fft.analyze();\n noStroke();\n fill(255, 0, 255);\n for (let i = 0; i< spectrum.length; i++){\n let x = map(i, 0, spectrum.length, 0, width);\n let h = -height + map(spectrum[i], 0, 255, height, 0);\n rect(x, height, width / spectrum.length, h )\n }\n\n let waveform = fft.waveform();\n noFill();\n beginShape();\n stroke(20);\n for (let i = 0; i < waveform.length; i++){\n let x = map(i, 0, waveform.length, 0, width);\n let y = map( waveform[i], -1, 1, 0, height);\n vertex(x,y);\n }\n endShape();\n\n text('tap to play', 20, 20);\n}\n\nfunction togglePlay() {\n if (sound.isPlaying()) {\n sound.pause();\n } else {\n sound.loop();\n }\n}\n
Creates a signal that oscillates between -1.0 and 1.0.\nBy default, the oscillation takes the form of a sinusoidal\nshape ('sine'). Additional types include 'triangle',\n'sawtooth' and 'square'. The frequency defaults to\n440 oscillations per second (440Hz, equal to the pitch of an\n'A' note).
\n\nSet the type of oscillation with setType(), or by instantiating a\nspecific oscillator: p5.SinOsc, p5.TriOsc, p5.SqrOsc, or p5.SawOsc.\n
", "is_constructor": 1, "params": [ { - "name": "frequency", - "description": "frequency defaults to 440Hz", + "name": "freq", + "description": "frequency defaults to 440Hz
\n", "type": "Number", "optional": true }, { "name": "type", - "description": "type of oscillator. Options:\n 'sine' (default), 'triangle',\n 'sawtooth', 'square'", + "description": "type of oscillator. Options:\n 'sine' (default), 'triangle',\n 'sawtooth', 'square'
\n", "type": "String", "optional": true } ], "example": [ - "\n\nlet osc, playing, freq, amp;\n\nfunction setup() {\n describe(\"a sketch that demonstrates the frequency and amplitude parameters of an oscillator.\");\n let cnv = createCanvas(100, 100);\n cnv.mousePressed(playOscillator);\n osc = new p5.Oscillator();\n}\n\nfunction draw() {\n background(220)\n freq = constrain(map(mouseX, 0, width, 100, 500), 100, 500);\n //amp = constrain(map(mouseY, height, 0, 0, 1), 0, 1);\n text('tap to play', 20, 20);\n text('freq: ' + freq, 20, 40);\n //text('amp: ' + amp, 20, 60);\n\n if (playing) {\n // smooth the transitions by 0.1 seconds\n osc.freq(freq);\n //osc.amp(amp);\n }\n}\n\nfunction playOscillator() {\n // starting an oscillator on a user gesture will enable audio\n // in browsers that have a strict autoplay policy.\n osc.start();\n playing = true;\n}\n\nfunction mouseReleased() {\n // ramp amplitude to 0 over 0.5 seconds\n //osc.amp(0, 0.5);\n playing = false;\n}\n
\n\nlet osc, playing, freq, amp;\n\nfunction setup() {\n let cnv = createCanvas(100, 100);\n cnv.mousePressed(playOscillator);\n osc = new p5.Oscillator('sine');\n}\n\nfunction draw() {\n background(220)\n freq = constrain(map(mouseX, 0, width, 100, 500), 100, 500);\n amp = constrain(map(mouseY, height, 0, 0, 1), 0, 1);\n\n text('tap to play', 20, 20);\n text('freq: ' + freq, 20, 40);\n text('amp: ' + amp, 20, 60);\n\n if (playing) {\n // smooth the transitions by 0.1 seconds\n osc.freq(freq, 0.1);\n osc.amp(amp, 0.1);\n }\n}\n\nfunction playOscillator() {\n // starting an oscillator on a user gesture will enable audio\n // in browsers that have a strict autoplay policy.\n // See also: userStartAudio();\n osc.start();\n playing = true;\n}\n\nfunction mouseReleased() {\n // ramp amplitude to 0 over 0.5 seconds\n osc.amp(0, 0.5);\n playing = false;\n}\n
Constructor: new p5.SinOsc()
.\nThis creates a Sine Wave Oscillator and is\nequivalent to new p5.Oscillator('sine')\n
or creating a p5.Oscillator and then calling\nits method setType('sine')
.\nSee p5.Oscillator for methods.
Set the frequency
\n", "type": "Number", "optional": true } @@ -2946,7 +2759,7 @@ }, "p5.TriOsc": { "name": "p5.TriOsc", - "shortname": "TriOsc", + "shortname": "p5.TriOsc", "classitems": [], "plugins": [], "extensions": [], @@ -2955,15 +2768,15 @@ "module": "p5.sound", "submodule": "p5.sound", "namespace": "", - "file": "src/Oscillator.js", - "line": 247, - "description": "Creates a triangle oscillator.", + "file": "lib/addons/p5.sound.js", + "line": 4629, + "description": "Constructor: new p5.TriOsc()
.\nThis creates a Triangle Wave Oscillator and is\nequivalent to new p5.Oscillator('triangle')\n
or creating a p5.Oscillator and then calling\nits method setType('triangle')
.\nSee p5.Oscillator for methods.
Set the frequency
\n", "type": "Number", "optional": true } @@ -2971,7 +2784,7 @@ }, "p5.SawOsc": { "name": "p5.SawOsc", - "shortname": "SawOsc", + "shortname": "p5.SawOsc", "classitems": [], "plugins": [], "extensions": [], @@ -2980,15 +2793,15 @@ "module": "p5.sound", "submodule": "p5.sound", "namespace": "", - "file": "src/Oscillator.js", - "line": 219, - "description": "Creates a sawtooth oscillator.", + "file": "lib/addons/p5.sound.js", + "line": 4656, + "description": "Constructor: new p5.SawOsc()
.\nThis creates a SawTooth Wave Oscillator and is\nequivalent to new p5.Oscillator('sawtooth')\n
or creating a p5.Oscillator and then calling\nits method setType('sawtooth')
.\nSee p5.Oscillator for methods.
Set the frequency
\n", "type": "Number", "optional": true } @@ -2996,7 +2809,7 @@ }, "p5.SqrOsc": { "name": "p5.SqrOsc", - "shortname": "SqrOsc", + "shortname": "p5.SqrOsc", "classitems": [], "plugins": [], "extensions": [], @@ -3005,15 +2818,15 @@ "module": "p5.sound", "submodule": "p5.sound", "namespace": "", - "file": "src/Oscillator.js", - "line": 233, - "description": "Creates a square oscillator.", + "file": "lib/addons/p5.sound.js", + "line": 4683, + "description": "Constructor: new p5.SqrOsc()
.\nThis creates a Square Wave Oscillator and is\nequivalent to new p5.Oscillator('square')\n
or creating a p5.Oscillator and then calling\nits method setType('square')
.\nSee p5.Oscillator for methods.
Set the frequency
\n", "type": "Number", "optional": true } @@ -3021,7 +2834,7 @@ }, "p5.Envelope": { "name": "p5.Envelope", - "shortname": "Envelope", + "shortname": "p5.Envelope", "classitems": [], "plugins": [], "extensions": [], @@ -3030,43 +2843,17 @@ "module": "p5.sound", "submodule": "p5.sound", "namespace": "", - "file": "src/Envelope.js", - "line": 10, - "description": "Generate an amplitude envelope.", + "file": "lib/addons/p5.sound.js", + "line": 4721, + "description": "Envelopes are pre-defined amplitude distribution over time.\nTypically, envelopes are used to control the output volume\nof an object, a series of fades referred to as Attack, Decay,\nSustain and Release (\nADSR\n). Envelopes can also control other Web Audio Parameters—for example, a p5.Envelope can\ncontrol an Oscillator's frequency like this: osc.freq(env)
.
Use setRange
to change the attack/release level.\nUse setADSR
to change attackTime, decayTime, sustainPercent and releaseTime.
Use the play
method to play the entire envelope,\nthe ramp
method for a pingable trigger,\nor triggerAttack
/\ntriggerRelease
to trigger noteOn/noteOff.
\nconsoe.log('do an example here');\n
\n\nlet t1 = 0.1; // attack time in seconds\nlet l1 = 0.7; // attack level 0.0 to 1.0\nlet t2 = 0.3; // decay time in seconds\nlet l2 = 0.1; // decay level 0.0 to 1.0\n\nlet env;\nlet triOsc;\n\nfunction setup() {\n let cnv = createCanvas(100, 100);\n background(220);\n text('tap to play', 20, 20);\n cnv.mousePressed(playSound);\n\n env = new p5.Envelope(t1, l1, t2, l2);\n triOsc = new p5.Oscillator('triangle');\n}\n\nfunction playSound() {\n // starting the oscillator ensures that audio is enabled.\n triOsc.start();\n env.play(triOsc);\n}\n
Noise is a type of oscillator that generates a buffer with random values.
\n", + "extends": "p5.Oscillator", "is_constructor": 1, "params": [ { "name": "type", - "description": "- the type of noise (white, pink, brown)", - "type": "String", - "optional": true + "description": "Type of noise can be 'white' (default),\n 'brown' or 'pink'.
\n", + "type": "String" } - ], - "example": [ - "\n\nlet noise, env, cnv;\nlet types = ['white', 'pink', 'brown'];\nlet noiseType = 'brown';\n\nfunction setup() {\n cnv = createCanvas(100, 100);\n textAlign(CENTER);\n cnv.mousePressed(start);\n noise = new p5.Noise(noiseType);\n env = new p5.Envelope(0.01, 0.1, 0.15, 0.5);\n noise.disconnect();\n noise.connect(env);\n noise.start();\n}\n\nfunction start() {\n noiseType = random(types);\n noise.type(noiseType);\n env.play();\n}\n\nfunction draw() {\n background(noiseType);\n text('tap to play', width/2, 20);\n let txt = 'type: ' + noiseType;\n text(txt, width/2, 40);\n}\n
\nCreates a Pulse object, an oscillator that implements\nPulse Width Modulation.\nThe pulse is created with two oscillators.\nAccepts a parameter for frequency, and to set the\nwidth between the pulses. See \np5.Oscillator
for a full list of methods.
Creates a Pulse object, an oscillator that implements\nPulse Width Modulation.\nThe pulse is created with two oscillators.\nAccepts a parameter for frequency, and to set the\nwidth between the pulses. See \np5.Oscillator
for a full list of methods.
Get audio from an input, i.e. your computer's microphone.
\n\nTurn the mic on/off with the start() and stop() methods. When the mic\nis on, its volume can be measured with getLevel or by connecting an\nFFT object.
\n\nIf you want to hear the AudioIn, use the .connect() method.\nAudioIn does not connect to p5.sound output by default to prevent\nfeedback.
\n\nNote: This uses the getUserMedia/\nStream API, which is not supported by certain browsers. Access in Chrome browser\nis limited to localhost and https, but access over http may be limited.
", "is_constructor": 1, + "params": [ + { + "name": "errorCallback", + "description": "A function to call if there is an error\n accessing the AudioIn. For example,\n Safari and iOS devices do not\n currently allow microphone access.
\n", + "type": "Function", + "optional": true + } + ], "example": [ - "\n\nlet mic, delay, filter;\n\nfunction setup() {\n let cnv = createCanvas(100, 100);\n cnv.mousePressed(startMic);\n background(220);\n \n mic = new p5.AudioIn();\n delay = new p5.Delay(0.74, 0.1);\n filter = new p5.Biquad(600, \"bandpass\");\n \n mic.disconnect();\n mic.connect(delay);\n delay.disconnect();\n delay.connect(filter);\n \n textAlign(CENTER);\n textWrap(WORD);\n textSize(10);\n text('click to open mic, watch out for feedback', 0, 20, 100);\n describe('a sketch that accesses the user\\'s microphone and connects it to a delay line.')\n}\n\nfunction startMic() {\n mic.start();\n}\n\nfunction draw() {\n d = map(mouseX, 0, width, 0.0, 0.5);\n delay.delayTime(d);\n}\n
\n\nlet mic;\n\n function setup(){\n let cnv = createCanvas(100, 100);\n cnv.mousePressed(userStartAudio);\n textAlign(CENTER);\n mic = new p5.AudioIn();\n mic.start();\n}\n\nfunction draw(){\n background(0);\n fill(255);\n text('tap to start', width/2, 20);\n\n micLevel = mic.getLevel();\n let y = height - micLevel * height;\n ellipse(width/2, y, 10, 10);\n}\n
Effect is a base class for audio effects in p5.
\nThis module handles the nodes and methods that are\ncommon and useful for current and future effects.
This class is extended by p5.Distortion,\np5.Compressor,\np5.Delay,\np5.Filter,\np5.Reverb.
\n", + "description": "Effect is a base class for audio effects in p5.
\nThis module handles the nodes and methods that are\ncommon and useful for current and future effects.
This class is extended by p5.Distortion,\np5.Compressor,\np5.Delay,\np5.Filter,\np5.Reverb.
\n", "is_constructor": 1, "params": [ { @@ -3205,7 +2997,7 @@ "namespace": "", "file": "lib/addons/p5.sound.js", "line": 6628, - "description": "A p5.Filter uses a Web Audio Biquad Filter to filter\nthe frequency response of an input source. Subclasses\ninclude:
\np5.LowPass
:\nAllows frequencies below the cutoff frequency to pass through,\nand attenuates frequencies above the cutoff.p5.HighPass
:\nThe opposite of a lowpass filter. p5.BandPass
:\nAllows a range of frequencies to pass through and attenuates\nthe frequencies below and above this frequency range.The .res()
method controls either width of the\nbandpass, or resonance of the low/highpass cutoff frequency.
This class extends p5.Effect.\nMethods amp(), chain(),\ndrywet(), connect(), and\ndisconnect() are available.
\n", + "description": "A p5.Filter uses a Web Audio Biquad Filter to filter\nthe frequency response of an input source. Subclasses\ninclude:
\np5.LowPass
:\nAllows frequencies below the cutoff frequency to pass through,\nand attenuates frequencies above the cutoff.p5.HighPass
:\nThe opposite of a lowpass filter. p5.BandPass
:\nAllows a range of frequencies to pass through and attenuates\nthe frequencies below and above this frequency range.The .res()
method controls either width of the\nbandpass, or resonance of the low/highpass cutoff frequency.
This class extends p5.Effect.\nMethods amp(), chain(),\ndrywet(), connect(), and\ndisconnect() are available.
\n", "extends": "p5.Effect", "is_constructor": 1, "params": [ @@ -3222,7 +3014,7 @@ }, "p5.LowPass": { "name": "p5.LowPass", - "shortname": "LowPass", + "shortname": "p5.LowPass", "classitems": [], "plugins": [], "extensions": [], @@ -3231,23 +3023,15 @@ "module": "p5.sound", "submodule": "p5.sound", "namespace": "", - "file": "src/Biquad.js", - "line": 136, - "description": "Creates a Lowpass Biquad filter.", + "file": "lib/addons/p5.sound.js", + "line": 6914, + "description": "Constructor: new p5.LowPass()
Filter.\nThis is the same as creating a p5.Filter and then calling\nits method setType('lowpass')
.\nSee p5.Filter for methods.
Constructor: new p5.HighPass()
Filter.\nThis is the same as creating a p5.Filter and then calling\nits method setType('highpass')
.\nSee p5.Filter for methods.
Constructor: new p5.BandPass()
Filter.\nThis is the same as creating a p5.Filter and then calling\nits method setType('bandpass')
.\nSee p5.Filter for methods.
p5.EQ is an audio effect that performs the function of a multiband\naudio equalizer. Equalization is used to adjust the balance of\nfrequency compoenents of an audio signal. This process is commonly used\nin sound production and recording to change the waveform before it reaches\na sound output device. EQ can also be used as an audio effect to create\ninteresting distortions by filtering out parts of the spectrum. p5.EQ is\nbuilt using a chain of Web Audio Biquad Filter Nodes and can be\ninstantiated with 3 or 8 bands. Bands can be added or removed from\nthe EQ by directly modifying p5.EQ.bands (the array that stores filters).
\nThis class extends p5.Effect.\nMethods amp(), chain(),\ndrywet(), connect(), and\ndisconnect() are available.
\n", + "description": "p5.EQ is an audio effect that performs the function of a multiband\naudio equalizer. Equalization is used to adjust the balance of\nfrequency compoenents of an audio signal. This process is commonly used\nin sound production and recording to change the waveform before it reaches\na sound output device. EQ can also be used as an audio effect to create\ninteresting distortions by filtering out parts of the spectrum. p5.EQ is\nbuilt using a chain of Web Audio Biquad Filter Nodes and can be\ninstantiated with 3 or 8 bands. Bands can be added or removed from\nthe EQ by directly modifying p5.EQ.bands (the array that stores filters).
\nThis class extends p5.Effect.\nMethods amp(), chain(),\ndrywet(), connect(), and\ndisconnect() are available.
\n", "is_constructor": 1, "extends": "p5.Effect", "params": [ @@ -3329,7 +3097,7 @@ }, "p5.Panner3D": { "name": "p5.Panner3D", - "shortname": "Panner3D", + "shortname": "p5.Panner3D", "classitems": [], "plugins": [], "extensions": [], @@ -3338,17 +3106,14 @@ "module": "p5.sound", "submodule": "p5.sound", "namespace": "", - "file": "src/Panner3D.js", - "line": 10, - "description": "A 3D sound spatializer.", - "is_constructor": 1, - "example": [ - "\n\nlet radius = 10 ; \nlet soundSource, spatializer;\nlet font;\nlet cnv;\n\nlet x = 0;\nlet y = 0;\nlet z = 100;\n\nlet vX;\nlet vY;\nlet vZ;\n\nfunction preload() {\n soundSource = loadSound('/assets/beat.mp3');\n font = loadFont('/assets/SourceSansPro-Regular.otf');\n}\n\nfunction setup() {\n describe(\n 'A 3D shape with a sound source attached to it. The sound source is spatialized using the Panner3D class. Click to play the sound.'\n );\n cnv = createCanvas(100, 100, WEBGL);\n cnv.mousePressed(playSound);\n\n camera(0, 0, 0, 0, 0, 1);\n \n textFont(font);\n textAlign(CENTER,CENTER);\n \n angleMode(DEGREES);\n\n vX = random(-0.5, 0.5);\n vY = random(-0.5, 0.5);\n vZ = random(-0.5, 0.5) * 1.5;\n\n spatializer = new p5.Panner3D();\n spatializer.maxDist(100);\n soundSource.loop();\n soundSource.disconnect();\n soundSource.connect(spatializer);\n}\n\nfunction playSound() {\n soundSource.play();\n}\n\nfunction draw() {\n background(220);\n push();\n textSize(5);\n fill(0);\n translate(0,0,100);\n //text('click to play', 0, 0);\n pop();\n // Update Box and Sound Source Position\n push();\n moveSoundBox();\n box(5, 5, 5);\n pop();\n}\n\n// Rotate 1 degree per frame along all three axes\nfunction moveSoundBox() {\n x = x + vX;\n y = y + vY;\n z = z + vZ;\n\n if (x > radius || x < -radius) {\n vX = -vX;\n }\n if (y > radius || y < -radius) {\n vY = -vY;\n }\n if (z > 250 || z < 80) {\n vZ = -vZ;\n }\n //set the position of the 3D panner\n spatializer.set(x, y, z);\n //set the postion of the box\n translate(x, y, z);\n rotateX(45 + frameCount);\n rotateZ(45);\n}\n
\nPanner3D is based on the \nWeb Audio Spatial Panner Node.\nThis panner is a spatial processing node that allows audio to be positioned\nand oriented in 3D space.
\nThe position is relative to an \nAudio Context Listener, which can be accessed\nby p5.soundOut.audiocontext.listener
Delay is an echo effect. It processes an existing sound source,\nand outputs a delayed version of that sound. The p5.Delay can\nproduce different effects depending on the delayTime, feedback,\nfilter, and type. In the example below, a feedback of 0.5 (the\ndefault value) will produce a looping delay that decreases in\nvolume by 50% each repeat. A filter will cut out the high\nfrequencies so that the delay does not sound as piercing as the\noriginal source.
\nThis class extends p5.Effect.\nMethods amp(), chain(),\ndrywet(), connect(), and\ndisconnect() are available.
\n", + "extends": "p5.Effect", "is_constructor": 1, - "params": [ - { - "name": "delayTime", - "description": "The delay time in seconds between 0 and 1. Defaults to 0.250.", - "type": "Number", - "optional": true - }, - { - "name": "feedback", - "description": "The amount of feedback in the delay line between 0 and 1. Defaults to 0.2.", - "type": "Number", - "optional": true - } - ], "example": [ - "\n\nlet osc;\n\nfunction setup() {\n let cnv = createCanvas(100, 100);\n background(220);\n textAlign(CENTER);\n text('tap to play', width/2, height/2);\n\n osc = new p5.Oscillator('square');\n osc.amp(0.5);\n delay = new p5.Delay(0.12, 0.7);\n \n osc.disconnect();\n osc.connect(delay);\n\n cnv.mousePressed(oscStart);\n describe('Tap to play a square wave with delay effect.');\n}\n\nfunction oscStart() {\n osc.start();\n}\n\n
\n\nlet osc;\n\nfunction setup() {\n let cnv = createCanvas(100, 100);\n background(220);\n textAlign(CENTER);\n text('tap to play', width/2, height/2);\n\n osc = new p5.Oscillator('square');\n osc.amp(0.5);\n delay = new p5.Delay();\n\n // delay.process() accepts 4 parameters:\n // source, delayTime (in seconds), feedback, filter frequency\n delay.process(osc, 0.12, .7, 2300);\n\n cnv.mousePressed(oscStart);\n}\n\nfunction oscStart() {\n osc.start();\n}\n\nfunction mouseReleased() {\n osc.stop();\n}\n
Reverb adds depth to a sound through a large number of decaying\nechoes. It creates the perception that sound is occurring in a\nphysical space. The p5.Reverb has paramters for Time (how long does the\nreverb last) and decayRate (how much the sound decays with each echo)\nthat can be set with the .set() or .process() methods. The p5.Convolver\nextends p5.Reverb allowing you to recreate the sound of actual physical\nspaces through convolution.
\nThis class extends p5.Effect.\nMethods amp(), chain(),\ndrywet(), connect(), and\ndisconnect() are available.
\n", + "extends": "p5.Effect", "is_constructor": 1, - "params": [ - { - "name": "decayTime", - "description": "Set the decay time of the reverb", - "type": "Number", - "optional": true - } - ], "example": [ - "\n\nlet noise, osc, env, reverb;\nlet randomTime = 0;\n\nfunction setup() {\n let cnv = createCanvas(100, 100);\n cnv.mousePressed(playSound);\n noise = new p5.Noise();\n env = new p5.Envelope();\n reverb = new p5.Reverb();\n noise.disconnect();\n noise.connect(env);\n env.disconnect();\n env.connect(reverb);\n noise.start();\n textAlign(CENTER);\n}\n\nfunction playSound() {\n randomTime = random(0.1, 3);\n reverb.set(randomTime); \n env.play();\n}\n\nfunction draw() {\n background(220);\n text('click to play', width/2, 20);\n text('decay ' + round(randomTime, 2), width/2, 40);\n describe('Click to play a sound with a random decay time.');\n}\n
\n\nlet soundFile, reverb;\nfunction preload() {\n soundFile = loadSound('assets/Damscray_DancingTiger.mp3');\n}\n\nfunction setup() {\n let cnv = createCanvas(100, 100);\n cnv.mousePressed(playSound);\n\n reverb = new p5.Reverb();\n soundFile.disconnect(); // so we'll only hear reverb...\n\n // connect soundFile to reverb, process w/\n // 3 second reverbTime, decayRate of 2%\n reverb.process(soundFile, 3, 2);\n}\n\nfunction draw() {\n let dryWet = constrain(map(mouseX, 0, width, 0, 1), 0, 1);\n // 1 = all reverb, 0 = no reverb\n reverb.drywet(dryWet);\n\n background(220);\n text('tap to play', 10, 20);\n text('dry/wet: ' + round(dryWet * 100) + '%', 10, height - 20);\n}\n\nfunction playSound() {\n soundFile.play();\n}\n
Compressor is an audio effect class that performs dynamics compression\non an audio input source. This is a very commonly used technique in music\nand sound production. Compression creates an overall louder, richer,\nand fuller sound by lowering the volume of louds and raising that of softs.\nCompression can be used to avoid clipping (sound distortion due to\npeaks in volume) and is especially useful when many sounds are played\nat once. Compression can be used on indivudal sound sources in addition\nto the main output.
\nThis class extends p5.Effect.\nMethods amp(), chain(),\ndrywet(), connect(), and\ndisconnect() are available.
\n", + "description": "Compressor is an audio effect class that performs dynamics compression\non an audio input source. This is a very commonly used technique in music\nand sound production. Compression creates an overall louder, richer,\nand fuller sound by lowering the volume of louds and raising that of softs.\nCompression can be used to avoid clipping (sound distortion due to\npeaks in volume) and is especially useful when many sounds are played\nat once. Compression can be used on indivudal sound sources in addition\nto the main output.
\nThis class extends p5.Effect.\nMethods amp(), chain(),\ndrywet(), connect(), and\ndisconnect() are available.
\n", "is_constructor": 1, "extends": "p5.Effect" }, @@ -3665,7 +3410,7 @@ "namespace": "", "file": "lib/addons/p5.sound.js", "line": 10816, - "description": "A Distortion effect created with a Waveshaper Node,\nwith an approach adapted from\nKevin Ennis
\nThis class extends p5.Effect.\nMethods amp(), chain(),\ndrywet(), connect(), and\ndisconnect() are available.
\n", + "description": "A Distortion effect created with a Waveshaper Node,\nwith an approach adapted from\nKevin Ennis
\nThis class extends p5.Effect.\nMethods amp(), chain(),\ndrywet(), connect(), and\ndisconnect() are available.
\n", "extends": "p5.Effect", "is_constructor": 1, "params": [ @@ -3687,7 +3432,7 @@ }, "p5.Gain": { "name": "p5.Gain", - "shortname": "Gain", + "shortname": "p5.Gain", "classitems": [], "plugins": [], "extensions": [], @@ -3696,12 +3441,12 @@ "module": "p5.sound", "submodule": "p5.sound", "namespace": "", - "file": "src/Gain.js", - "line": 10, - "description": "Generate a gain node to use for mixing and main volume.", + "file": "lib/addons/p5.sound.js", + "line": 10973, + "description": "A gain node is usefull to set the relative volume of sound.\nIt's typically used to build mixers.
\n", "is_constructor": 1, "example": [ - "\n\nlet cnv, soundFile, osc, gain;\n\nfunction preload() {\n soundFile = loadSound('assets/Damscray_DancingTiger.mp3');\n}\n\nfunction setup() {\n cnv = createCanvas(100, 100);\n cnv.mousePressed(playSound);\n\n gain = new p5.Gain(0.74);\n osc = new p5.Oscillator();\n osc.amp(0.74);\n osc.disconnect();\n soundFile.loop();\n soundFile.disconnect();\n\n //connect both sound sources to gain node\n soundFile.connect(gain);\n osc.connect(gain);\n}\n\nfunction playSound() {\n soundFile.play();\n soundFile.play();\n}\n\nfunction draw() {\n background(220);\n let level = map(mouseX, 0, width, 0, 1);\n gain.amp(level);\n}\n
\n\n\n// load two soundfile and crossfade beetween them\nlet sound1,sound2;\nlet sound1Gain, sound2Gain, mixGain;\nfunction preload(){\n soundFormats('ogg', 'mp3');\n sound1 = loadSound('assets/Damscray_-_Dancing_Tiger_01');\n sound2 = loadSound('assets/beat');\n}\nfunction setup() {\n let cnv = createCanvas(100, 100);\n cnv.mousePressed(startSound);\n // create a 'mix' gain bus to which we will connect both soundfiles\n mixGain = new p5.Gain();\n mixGain.connect();\n sound1.disconnect(); // diconnect from p5 output\n sound1Gain = new p5.Gain(); // setup a gain node\n sound1Gain.setInput(sound1); // connect the first sound to its input\n sound1Gain.connect(mixGain); // connect its output to the final mix bus\n sound2.disconnect();\n sound2Gain = new p5.Gain();\n sound2Gain.setInput(sound2);\n sound2Gain.connect(mixGain);\n}\nfunction startSound() {\n sound1.loop();\n sound2.loop();\n loop();\n}\nfunction mouseReleased() {\n sound1.stop();\n sound2.stop();\n}\nfunction draw(){\n background(220);\n textAlign(CENTER);\n textSize(11);\n fill(0);\n if (!sound1.isPlaying()) {\n text('tap and drag to play', width/2, height/2);\n return;\n }\n // map the horizontal position of the mouse to values useable for volume * control of sound1\n var sound1Volume = constrain(map(mouseX,width,0,0,1), 0, 1);\n var sound2Volume = 1-sound1Volume;\n sound1Gain.amp(sound1Volume);\n sound2Gain.amp(sound2Volume);\n // map the vertical position of the mouse to values useable for 'output * volume control'\n var outputVolume = constrain(map(mouseY,height,0,0,1), 0, 1);\n mixGain.amp(outputVolume);\n text('output', width/2, height - outputVolume * height * 0.9)\n fill(255, 0, 255);\n textAlign(LEFT);\n text('sound1', 5, height - sound1Volume * height * 0.9);\n textAlign(RIGHT);\n text('sound2', width - 5, height - sound2Volume * height * 0.9);\n}\n
\nlet polySynth;\n\nfunction setup() {\n let cnv = createCanvas(100, 100);\n cnv.mousePressed(playSynth);\n background(220);\n text('click to play', 20, 20);\n\n polySynth = new p5.PolySynth();\n}\n\nfunction playSynth() {\n userStartAudio();\n\n // note duration (in seconds)\n let dur = 1.5;\n\n // time from now (in seconds)\n let time = 0;\n\n // velocity (volume, from 0 to 1)\n let vel = 0.1;\n\n // notes can overlap with each other\n polySynth.play('G2', vel, 0, dur);\n polySynth.play('C3', vel, time += 1/3, dur);\n polySynth.play('G3', vel, time += 1/3, dur);\n}\n
\n///kind of Karplus-Strong string synthesis using p5.sound.js\n\nlet noise, lowPass, hiPass, delay, env, gain;\n\nfunction setup() {\n let cnv = createCanvas(100, 100);\n background(220);\n textAlign(CENTER);\n textSize(9);\n text('click and drag mouse', width/2, height/2);\n \n noise = new p5.Noise('white');\n env = new p5.Envelope(0);\n lowPass = new p5.Biquad(1200, 'lowpass');\n hiPass = new p5.Biquad(55, 'highpass');\n delay = new p5.Delay(0.0005, 0.97);\n gain = new p5.Gain(0.5);\n noise.disconnect();\n noise.connect(hiPass);\n hiPass.disconnect();\n hiPass.connect(env);\n env.disconnect();\n env.connect(lowPass);\n lowPass.disconnect();\n lowPass.connect(delay);\n\n cnv.mousePressed(pluckStart);\n cnv.mouseReleased(pluckStop);\n cnv.mouseOut(pluckStop);\n describe('A sketch that synthesizes string sounds.');\n}\n\nfunction pluckStart() {\n background(0, 255, 255);\n text('release to trigger decay', width/2, height/2);\n let dtime = map(mouseX, 0, width, 0.009, 0.001);\n delay.delayTime(dtime, 0);\n noise.start();\n env.triggerAttack();\n}\n\nfunction pluckStop() {\n background(220);\n text('click to pluck', width/2, height/2);\n env.triggerRelease();\n}\n
\n\nlet panner, lfo, soundfile, cnv;\n\nfunction preload() {\n soundfile = loadSound('/assets/beat.mp3');\n}\n\nfunction setup() {\n cnv = createCanvas(100, 100);\n background(220);\n cnv.mousePressed(startSound);\n \n panner = new p5.Panner();\n lfo = new p5.Oscillator(1);\n //disconnect lfo from speakers because we don't want to hear it!\n lfo.disconnect();\n panner.pan(lfo);\n\n soundfile.loop();\n soundfile.disconnect();\n soundfile.connect(panner);\n \n}\n\nfunction startSound() {\n lfo.start();\n soundfile.start();\n}\n
\n\n let cnv, soundFile, pitchShifter;\n \nfunction preload() {\n soundFile = loadSound('/assets/beatbox.mp3');\n}\n \nfunction setup() {\n cnv = createCanvas(100, 100);\n cnv.mousePressed(startSound);\n background(220);\n textAlign(CENTER);\n textSize(9);\n text('click to play sound', width/2, height/2);\n pitchShifter = new p5.PitchShifter();\n \n soundFile.disconnect();\n soundFile.connect(pitchShifter);\n //change the pitch and retrigger sample when done playing\n soundFile.onended(changePitch);\n}\n\nfunction startSound () {\n soundFile.play();\n}\n \nfunction changePitch () {\n let pitchValue = random(-12, 12);\n pitchShifter.shift(pitchValue);\n soundFile.play();\n}\n
\noptional alpha value, controls transparency (0 - transparent, 255 - opaque).
\n", + "description": "alpha value, controls transparency (0 - transparent, 255 - opaque).
\n", "type": "Number", "optional": true } @@ -5043,7 +4706,7 @@ }, { "name": "alpha", - "description": "", + "description": "alpha value, controls transparency (0 - transparent, 255 - opaque).
\n", "type": "Number", "optional": true } @@ -6975,7 +6638,7 @@ { "file": "src/core/constants.js", "line": 24, - "description": "One of the two render modes in p5.js, used for computationally intensive tasks like 3D rendering and shaders.
\nWEBGL
differs from the default P2D
renderer in the following ways:
WEBGL
mode, the origin point (0,0,0) is located at the center of the screen, not the top-left corner. See the tutorial page about coordinates and transformations.WEBGL
mode can be used to draw 3-dimensional shapes like box(), sphere(), cone(), and more. See the tutorial page about custom geometry to make more complex objects.WEBGL
mode, you can specify how smooth curves should be drawn by using a detail
parameter. See the wiki section about shapes for a more information and an example.WEBGL
offers different types of lights like ambientLight() to place around a scene. Materials like specularMaterial() reflect the lighting to convey shape and depth. See the tutorial page for styling and appearance to experiment with different combinations.WEBGL
sketch can be adjusted by changing camera attributes. See the tutorial page section about cameras for an explanation of camera controls.WEBGL
requires opentype/truetype font files to be preloaded using loadFont(). See the wiki section about text for details, along with a workaround.WEBGL
mode uses the graphics card instead of the CPU, so it may help boost the performance of your sketch (example: drawing more shapes on the screen at once).To learn more about WEBGL mode, check out all the interactive WEBGL tutorials in the \"Tutorials\" section of this website, or read the wiki article \"Getting started with WebGL in p5\".
\n", + "description": "One of the two render modes in p5.js, used for computationally intensive tasks like 3D rendering and shaders.
\nWEBGL
differs from the default P2D
renderer in the following ways:
WEBGL
mode, the origin point (0,0,0) is located at the center of the screen, not the top-left corner. See the tutorial page about coordinates and transformations.WEBGL
mode can be used to draw 3-dimensional shapes like box(), sphere(), cone(), and more. See the tutorial page about custom geometry to make more complex objects.WEBGL
mode, you can specify how smooth curves should be drawn by using a detail
parameter. See the wiki section about shapes for a more information and an example.WEBGL
offers different types of lights like ambientLight() to place around a scene. Materials like specularMaterial() reflect the lighting to convey shape and depth. See the tutorial page for styling and appearance to experiment with different combinations.WEBGL
sketch can be adjusted by changing camera attributes. See the tutorial page section about cameras for an explanation of camera controls.WEBGL
requires opentype/truetype font files to be preloaded using loadFont(). See the wiki section about text for details, along with a workaround.WEBGL
mode uses the graphics card instead of the CPU, so it may help boost the performance of your sketch (example: drawing more shapes on the screen at once).To learn more about WEBGL mode, check out all the interactive WEBGL tutorials in the \"Tutorials\" section of this website, or read the wiki article \"Getting started with WebGL in p5\".
\n", "itemtype": "property", "name": "WEBGL", "type": "String", @@ -7524,7 +7187,7 @@ { "file": "src/core/constants.js", "line": 810, - "description": "AUTO allows us to automatically set the width or height of an element (but not both),\nbased on the current height and width of the element. Only one parameter can\nbe passed to the size function as AUTO, at a time.
\n", + "description": "AUTO allows us to automatically set the width or height of an element (but not both),\nbased on the current height and width of the element. Only one parameter can\nbe passed to the size function as AUTO, at a time.
\n", "itemtype": "property", "name": "AUTO", "type": "String", @@ -9499,7 +9162,7 @@ "itemtype": "property", "name": "class", "example": [ - "\n\n// Declare a frog variable.\nlet fifi;\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Assign the frog variable a new Frog object.\n fifi = new Frog(50, 50, 20);\n\n describe('A frog face drawn on a gray background.');\n}\n\nfunction draw() {\n background('cornflowerblue');\n\n // Show the frog.\n fifi.show();\n}\n\nclass Frog {\n constructor(x, y, size) {\n this.x = x;\n this.y = y;\n this.size = size;\n }\n\n show() {\n textAlign(CENTER, CENTER);\n textSize(this.size);\n text('🐸', this.x, this.y);\n }\n}\n
\n\n// Declare two frog variables.\nlet frog1;\nlet frog2;\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Assign the frog variables a new Frog object.\n frog1 = new Frog(25, 50, 10);\n frog2 = new Frog(75, 50, 20);\n\n describe('Two frog faces drawn next to each other on a gray background.');\n}\n\nfunction draw() {\n background('cornflowerblue');\n\n // Show the frogs.\n frog1.show();\n frog2.show();\n}\n\nclass Frog {\n constructor(x, y, size) {\n this.x = x;\n this.y = y;\n this.size = size;\n }\n\n show() {\n textAlign(CENTER, CENTER);\n textSize(this.size);\n text('🐸', this.x, this.y);\n }\n}\n
\n\n// Declare two frog variables.\nlet frog1;\nlet frog2;\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Assign the frog variables a new Frog object.\n frog1 = new Frog(25, 50, 10);\n frog2 = new Frog(75, 50, 20);\n\n // Slow the frame rate.\n frameRate(1);\n\n describe('Two frog faces on a gray background. The frogs hop around randomly.');\n}\n\nfunction draw() {\n background('cornflowerblue');\n\n // Show the frogs.\n frog1.show();\n frog2.show();\n\n // Move the frogs.\n frog1.hop();\n frog2.hop();\n\n // Wrap around if they've hopped off the edge.\n frog1.checkEdges();\n frog2.checkEdges();\n}\n\nclass Frog {\n constructor(x, y, size) {\n this.x = x;\n this.y = y;\n this.size = size;\n }\n\n show() {\n textAlign(CENTER, CENTER);\n textSize(this.size);\n text('🐸', this.x, this.y);\n }\n\n hop() {\n this.x += random(-10, 10);\n this.y += random(-10, 10);\n }\n\n checkEdges() {\n if (this.x > width) {\n this.x = this.x - width;\n } else if (this.x < 0) {\n this.x = width - this.x;\n }\n\n if (this.y > height) {\n this.y = this.y - height;\n } else if (this.y < 0) {\n this.y = height - this.y;\n }\n }\n}\n
\n\n// Declare two frog variables.\nlet frog1;\nlet frog2;\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Assign the frog variables a new Frog object.\n frog1 = new Frog(25, 50, 10);\n frog2 = new Frog(75, 50, 20);\n\n describe('Two frog faces drawn next to each other on a gray background.');\n}\n\nfunction draw() {\n background('cornflowerblue');\n\n // Show the frogs.\n frog1.show();\n frog2.show();\n}\n\nclass Frog {\n constructor(x, y, size) {\n this.x = x;\n this.y = y;\n this.size = size;\n }\n\n show() {\n textAlign(CENTER, CENTER);\n textSize(this.size);\n text('🐸', this.x, this.y);\n }\n}\n
\n\n// Create an array that will hold frogs.\nlet frogs = [];\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Add Frog objects to the array.\n for (let i = 0; i < 5; i += 1) {\n // Calculate random coordinates and size.\n let x = random(0, 100);\n let y = random(0, 100);\n let s = random(2, 20);\n\n // Create a new Frog object.\n let frog = new Frog(x, y, s);\n\n // Add the Frog to the array.\n frogs.push(frog);\n }\n\n // Slow the frame rate.\n frameRate(1);\n\n describe(\n 'Five frog faces on a gray background. The frogs hop around randomly.'\n );\n}\n\nfunction draw() {\n background('cornflowerblue');\n\n for (let frog of frogs) {\n // Show the frog.\n frog.show();\n\n // Move the frog.\n frog.hop();\n\n // Wrap around if they've hopped off the edge.\n frog.checkEdges();\n }\n}\n\nclass Frog {\n constructor(x, y, size) {\n this.x = x;\n this.y = y;\n this.size = size;\n }\n\n show() {\n textAlign(CENTER, CENTER);\n textSize(this.size);\n text('🐸', this.x, this.y);\n }\n\n hop() {\n this.x += random(-10, 10);\n this.y += random(-10, 10);\n }\n\n checkEdges() {\n if (this.x > width) {\n this.x = this.x - width;\n } else if (this.x < 0) {\n this.x = width - this.x;\n }\n\n if (this.y > height) {\n this.y = this.y - height;\n } else if (this.y < 0) {\n this.y = height - this.y;\n }\n }\n}\n
\n\n// Declare a frog variable.\nlet fifi;\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Assign the frog variable a new Frog object.\n fifi = new Frog(50, 50, 20);\n\n describe('A frog face drawn on a blue background.');\n}\n\nfunction draw() {\n background('cornflowerblue');\n\n // Show the frog.\n fifi.show();\n}\n\nclass Frog {\n constructor(x, y, size) {\n this.x = x;\n this.y = y;\n this.size = size;\n }\n\n show() {\n textAlign(CENTER, CENTER);\n textSize(this.size);\n text('🐸', this.x, this.y);\n }\n}\n
\n\n// Declare two frog variables.\nlet frog1;\nlet frog2;\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Assign the frog variables a new Frog object.\n frog1 = new Frog(25, 50, 10);\n frog2 = new Frog(75, 50, 20);\n\n describe('Two frog faces drawn next to each other on a blue background.');\n}\n\nfunction draw() {\n background('cornflowerblue');\n\n // Show the frogs.\n frog1.show();\n frog2.show();\n}\n\nclass Frog {\n constructor(x, y, size) {\n this.x = x;\n this.y = y;\n this.size = size;\n }\n\n show() {\n textAlign(CENTER, CENTER);\n textSize(this.size);\n text('🐸', this.x, this.y);\n }\n}\n
\n\n// Declare two frog variables.\nlet frog1;\nlet frog2;\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Assign the frog variables a new Frog object.\n frog1 = new Frog(25, 50, 10);\n frog2 = new Frog(75, 50, 20);\n\n // Slow the frame rate.\n frameRate(1);\n\n describe('Two frog faces on a blue background. The frogs hop around randomly.');\n}\n\nfunction draw() {\n background('cornflowerblue');\n\n // Show the frogs.\n frog1.show();\n frog2.show();\n\n // Move the frogs.\n frog1.hop();\n frog2.hop();\n\n // Wrap around if they've hopped off the edge.\n frog1.checkEdges();\n frog2.checkEdges();\n}\n\nclass Frog {\n constructor(x, y, size) {\n this.x = x;\n this.y = y;\n this.size = size;\n }\n\n show() {\n textAlign(CENTER, CENTER);\n textSize(this.size);\n text('🐸', this.x, this.y);\n }\n\n hop() {\n this.x += random(-10, 10);\n this.y += random(-10, 10);\n }\n\n checkEdges() {\n if (this.x > width) {\n this.x = this.x - width;\n } else if (this.x < 0) {\n this.x = width - this.x;\n }\n\n if (this.y > height) {\n this.y = this.y - height;\n } else if (this.y < 0) {\n this.y = height - this.y;\n }\n }\n}\n
\n\n// Create an array that will hold frogs.\nlet frogs = [];\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Add Frog objects to the array.\n for (let i = 0; i < 5; i += 1) {\n // Calculate random coordinates and size.\n let x = random(0, 100);\n let y = random(0, 100);\n let s = random(2, 20);\n\n // Create a new Frog object.\n let frog = new Frog(x, y, s);\n\n // Add the Frog to the array.\n frogs.push(frog);\n }\n\n // Slow the frame rate.\n frameRate(1);\n\n describe(\n 'Five frog faces on a blue background. The frogs hop around randomly.'\n );\n}\n\nfunction draw() {\n background('cornflowerblue');\n\n for (let frog of frogs) {\n // Show the frog.\n frog.show();\n\n // Move the frog.\n frog.hop();\n\n // Wrap around if they've hopped off the edge.\n frog.checkEdges();\n }\n}\n\nclass Frog {\n constructor(x, y, size) {\n this.x = x;\n this.y = y;\n this.size = size;\n }\n\n show() {\n textAlign(CENTER, CENTER);\n textSize(this.size);\n text('🐸', this.x, this.y);\n }\n\n hop() {\n this.x += random(-10, 10);\n this.y += random(-10, 10);\n }\n\n checkEdges() {\n if (this.x > width) {\n this.x = this.x - width;\n } else if (this.x < 0) {\n this.x = width - this.x;\n }\n\n if (this.y > height) {\n this.y = this.y - height;\n } else if (this.y < 0) {\n this.y = height - this.y;\n }\n }\n}\n
\nA way to repeat a block of code when the number of iterations is known.
\nfor
loops are helpful for repeating statements a certain number of times.\nFor example, a for
loop makes it easy to express the idea\n\"draw five lines\" like so:
for (let x = 10; x < 100; x += 20) {\n line(x, 25, x, 75);\n}\n
\nThe loop's header begins with the keyword for
. Loops generally count up\nor count down as they repeat, or iterate. The statements in parentheses\nlet x = 10; x < 100; x += 20
tell the loop how it should repeat:
let x = 10
tells the loop to start counting at 10
and keep track of iterations using the variable x
.x < 100
tells the loop to count up to, but not including, 100
.x += 20
tells the loop to count up by 20
at the end of each iteration.The code between the curly braces {}
is the loop's body. Statements in the\nloop body are repeated during each iteration of the loop.
It's common to create infinite loops accidentally. When this happens,\nsketches may become unresponsive and the web browser may display a warning.\nFor example, the following loop never stops iterating because it doesn't\ncount up:
\nfor (let x = 10; x < 100; x = 20) {\n line(x, 25, x, 75);\n}\n
\nThe statement x = 20
keeps the variable x
stuck at 20
, which is\nalways less than 100
.
for
loops can also count down:
for (let d = 100; d > 0; d -= 10) {\n circle(50, 50, d);\n}\n
\nfor
loops can also contain other loops. The following nested loop draws a\ngrid of points:
// Loop from left to right.\nfor (let x = 10; x < 100; x += 10) {\n\n // Loop from top to bottom.\n for (let y = 10; y < 100; y += 10) {\n point(x, y);\n }\n\n}\n
\nfor
loops are also helpful for iterating through the elements of an\narray. For example, it's common to iterate through an array that contains\ninformation about where or what to draw:
// Create an array of x-coordinates.\nlet xCoordinates = [20, 40, 60];\n\nfor (let i = 0; i < xCoordinates.length; i += 1) {\n // Update the element.\n xCoordinates[i] += random(-1, 1);\n\n // Draw a circle.\n circle(xCoordinates[i], 50, 20);\n}\n
\nIf the array's values aren't modified, the for...of
statement can\nsimplify the code. They're similar to for
loops in Python and for-each
\nloops in C++ and Java. The following loops have the same effect:
// Draw circles with a for loop.\nlet xCoordinates = [20, 40, 60];\n\nfor (let i = 0; i < xCoordinates.length; i += 1) {\n circle(xCoordinates[i], 50, 20);\n}\n
\n// Draw circles with a for...of statement.\nlet xCoordinates = [20, 40, 60];\n\nfor (let x of xCoordinates) {\n circle(x, 50, 20);\n}\n
\nIn the code snippets above, the variables i
and x
have different roles.
In the first snippet, i
counts from 0
up to 2
, which is one less than\nxCoordinates.length
. i
is used to access the element in xCoordinates
\nat index i
.
In the second code snippet, x
isn't keeping track of the loop's progress\nor an index. During each iteration, x
contains the next element of\nxCoordinates
. x
starts from the beginning of xCoordinates
(20
) and\nupdates its value to 40
and then 60
during the next iterations.
A way to repeat a block of code.
\nwhile
loops are helpful for repeating statements while a condition is\ntrue
. They're like if
statements that repeat. For example, a while
\nloop makes it easy to express the idea \"draw several lines\" like so:
// Declare a variable to keep track of iteration.\nlet x = 10;\n\n// Repeat as long as x < 100\nwhile (x < 100) {\n line(x, 25, x, 75);\n\n // Increment by 20.\n x += 20;\n}\n
\nThe loop's header begins with the keyword while
. Loops generally count up\nor count down as they repeat, or iterate. The statement in parentheses\nx < 100
is a condition the loop checks each time it iterates. If the\ncondition is true
, the loop runs the code between the curly braces {}
,\nThe code between the curly braces is called the loop's body. If the\ncondition is false
, the body is skipped and the loop is stopped.
It's common to create infinite loops accidentally. For example, the\nfollowing loop never stops iterating because it doesn't count up:
\n// Declare a variable to keep track of iteration.\nlet x = 10;\n\n// Repeat as long as x < 100\nwhile (x < 100) {\n line(x, 25, x, 75);\n}\n\n// This should be in the loop's body!\nx += 20;\n
\nThe statement x += 20
appears after the loop's body. That means the\nvariable x
is stuck at 10
, which is always less than 100
.
while
loops are useful when the number of iterations isn't known in\nadvance. For example, concentric circles could be drawn at random\nincrements:
let d = 100;\nlet minSize = 5;\n\nwhile (d > minSize) {\n circle(50, 50, d);\n d -= random(10);\n}\n
\n",
"itemtype": "property",
"name": "while",
@@ -9533,7 +9196,7 @@
},
{
"file": "src/core/reference.js",
- "line": 2028,
+ "line": 1988,
"description": "Prints a message to the web browser's console.
\nThe console\nobject is helpful for printing messages while debugging. For example, it's\ncommon to add a console.log()
statement while studying how a section of\ncode works:
if (isPlaying === true) {\n // Add a console.log() statement to make sure this block of code runs.\n console.log('Got here!');\n\n // Game logic.\n}\n
\nconsole.error()
is helpful for tracking errors because it prints\nformatted messages. For example, it's common to encounter errors when\nloading media assets:
// Logs an error message with special formatting.\nfunction handleFailure(error) {\n console.error('Oops!', error);\n}\n\n// Try to load an image and call handleError() if it fails.\nloadImage('https://example.com/cat.jpg', handleImage, handleError);\n
\n",
"itemtype": "property",
"name": "console",
@@ -13085,7 +12748,7 @@
},
{
"file": "src/events/keyboard.js",
- "line": 461,
+ "line": 472,
"description": "A function that's called once when any key is released.
\nDeclaring the function keyReleased()
sets a code block to run once\nautomatically when the user releases any key:
function keyReleased() {\n // Code to run.\n}\n
\nThe key and keyCode\nvariables will be updated with the most recently released value when\nkeyReleased()
is called by p5.js:
function keyReleased() {\n if (key === 'c') {\n // Code to run.\n }\n\n if (keyCode === ENTER) {\n // Code to run.\n }\n}\n
\nThe parameter, event
, is optional. keyReleased()
is always passed a\nKeyboardEvent\nobject with properties that describe the key press event:
function keyReleased(event) {\n // Code to run that uses the event.\n console.log(event);\n}\n
\nBrowsers may have default behaviors attached to various key events. To\nprevent any default behavior for this event, add return false;
to the end\nof the function.
A function that's called once when keys with printable characters are pressed.
\nDeclaring the function keyTyped()
sets a code block to run once\nautomatically when the user presses any key with a printable character such\nas a
or 1. Modifier keys such as SHIFT
, CONTROL
, and the arrow keys\nwill be ignored:
function keyTyped() {\n // Code to run.\n}\n
\nThe key and keyCode\nvariables will be updated with the most recently released value when\nkeyTyped()
is called by p5.js:
function keyTyped() {\n // Check for the \"c\" character using key.\n if (key === 'c') {\n // Code to run.\n }\n\n // Check for \"c\" using keyCode.\n if (keyCode === 67) {\n // Code to run.\n }\n}\n
\nThe parameter, event
, is optional. keyTyped()
is always passed a\nKeyboardEvent\nobject with properties that describe the key press event:
function keyReleased(event) {\n // Code to run that uses the event.\n console.log(event);\n}\n
\nNote: Use the keyPressed() function and\nkeyCode system variable to respond to modifier\nkeys such as ALT
.
Browsers may have default behaviors attached to various key events. To\nprevent any default behavior for this event, add return false;
to the end\nof the function.
The onblur function is called when the user is no longer focused\non the p5 element. Because the keyup events will not fire if the user is\nnot focused on the element we must assume all keys currently down have\nbeen released.
\n", "class": "p5", "module": "Events", @@ -13135,7 +12798,7 @@ }, { "file": "src/events/keyboard.js", - "line": 795, + "line": 809, "description": "Returns true
if the key it’s checking is pressed and false
if not.
keyIsDown()
is helpful when checking for multiple different key presses.\nFor example, keyIsDown()
can be used to check if both LEFT_ARROW
and\nUP_ARROW
are pressed:
if (keyIsDown(LEFT_ARROW) && keyIsDown(UP_ARROW)) {\n // Move diagonally.\n}\n
\nkeyIsDown()
can check for key presses using\nkeyCode values, as in keyIsDown(37)
or\nkeyIsDown(LEFT_ARROW)
. Key codes can be found on websites such as\nkeycode.info.
Captures a sequence of frames from the canvas that can be saved as images.
\nsaveFrames()
creates an array of frame objects. Each frame is stored as\nan object with its file type, file name, and image data as a string. For\nexample, the first saved frame might have the following properties:
{ ext: 'png', filenmame: 'frame0', imageData: 'data:image/octet-stream;base64, abc123' }
.
The first parameter, filename
, sets the prefix for the file names. For\nexample, setting the prefix to 'frame'
would generate the image files\nframe0.png
, frame1.png
, and so on.
The second parameter, extension
, sets the file type to either 'png'
or\n'jpg'
.
The third parameter, duration
, sets the duration to record in seconds.\nThe maximum duration is 15 seconds.
The fourth parameter, framerate
, sets the number of frames to record per\nsecond. The maximum frame rate value is 22. Limits are placed on duration
\nand framerate
to avoid using too much memory. Recording large canvases\ncan easily crash sketches or even web browsers.
The fifth parameter, callback
, is optional. If a function is passed,\nimage files won't be saved by default. The callback function can be used\nto process an array containing the data for each captured frame. The array\nof image data contains a sequence of objects with three properties for each\nframe: imageData
, filename
, and extension
.
Note: Frames are downloaded as individual image files by default.
\n", + "description": "Captures a sequence of frames from the canvas that can be saved as images.
\nsaveFrames()
creates an array of frame objects. Each frame is stored as\nan object with its file type, file name, and image data as a string. For\nexample, the first saved frame might have the following properties:
{ ext: 'png', filename: 'frame0', imageData: 'data:image/octet-stream;base64, abc123' }
.
The first parameter, filename
, sets the prefix for the file names. For\nexample, setting the prefix to 'frame'
would generate the image files\nframe0.png
, frame1.png
, and so on.
The second parameter, extension
, sets the file type to either 'png'
or\n'jpg'
.
The third parameter, duration
, sets the duration to record in seconds.\nThe maximum duration is 15 seconds.
The fourth parameter, framerate
, sets the number of frames to record per\nsecond. The maximum frame rate value is 22. Limits are placed on duration
\nand framerate
to avoid using too much memory. Recording large canvases\ncan easily crash sketches or even web browsers.
The fifth parameter, callback
, is optional. If a function is passed,\nimage files won't be saved by default. The callback function can be used\nto process an array containing the data for each captured frame. The array\nof image data contains a sequence of objects with three properties for each\nframe: imageData
, filename
, and extension
.
Note: Frames are downloaded as individual image files by default.
\n", "itemtype": "method", "name": "saveFrames", "params": [ @@ -19960,7 +19623,7 @@ "params": [ { "name": "angle", - "description": "the angle.
\n", + "description": "the angle in radians unless specified by angleMode().
\n", "type": "Number" } ], @@ -19984,7 +19647,7 @@ "params": [ { "name": "angle", - "description": "the angle.
\n", + "description": "the angle in radians unless specified by angleMode().
\n", "type": "Number" } ], @@ -20008,7 +19671,7 @@ "params": [ { "name": "angle", - "description": "the angle.
\n", + "description": "the angle in radians unless specified by angleMode().
\n", "type": "Number" } ], @@ -23405,7 +23068,7 @@ { "file": "src/webgl/loading.js", "line": 13, - "description": "Loads a 3D model to create a\np5.Geometry object.
\nloadModel()
can load 3D models from OBJ and STL files. Once the model is\nloaded, it can be displayed with the\nmodel() function, as in model(shape)
.
There are three ways to call loadModel()
with optional parameters to help\nprocess the model.
The first parameter, path
, is always a String
with the path to the\nfile. Paths to local files should be relative, as in\nloadModel('assets/model.obj')
. URLs such as\n'https://example.com/model.obj'
may be blocked due to browser security.
The first way to call loadModel()
has three optional parameters after the\nfile path. The first optional parameter, successCallback
, is a function\nto call once the model loads. For example,\nloadModel('assets/model.obj', handleModel)
will call the handleModel()
\nfunction once the model loads. The second optional parameter,\nfailureCallback
, is a function to call if the model fails to load. For\nexample, loadModel('assets/model.obj', handleModel, handleFailure)
will\ncall the handleFailure()
function if an error occurs while loading. The\nthird optional parameter, fileType
, is the model’s file extension as a\nstring. For example,\nloadModel('assets/model', handleModel, handleFailure, '.obj')
will try to\nload the file model as a .obj
file.
The second way to call loadModel()
has four optional parameters after the\nfile path. The first optional parameter is a Boolean
value. If true
is\npassed, as in loadModel('assets/model.obj', true)
, then the model will be\nresized to ensure it fits the canvas. The next three parameters are\nsuccessCallback
, failureCallback
, and fileType
as described above.
The third way to call loadModel()
has one optional parameter after the\nfile path. The optional parameter, options
, is an Object
with options,\nas in loadModel('assets/model.obj', options)
. The options
object can\nhave the following properties:
let options = {\n // Enables standardized size scaling during loading if set to true.\n normalize: true,\n\n // Function to call once the model loads.\n successCallback: handleModel,\n\n // Function to call if an error occurs while loading.\n failureCallback: handleError,\n\n // Model's file extension.\n fileType: '.stl',\n\n // Flips the U texture coordinates of the model.\n flipU: false,\n\n // Flips the V texture coordinates of the model.\n flipV: false\n};\n\n// Pass the options object to loadModel().\nloadModel('assets/model.obj', options);\n
\nModels can take time to load. Calling loadModel()
in\npreload() ensures models load before they're\nused in setup() or draw().
Note: There’s no support for colored STL files. STL files with color will\nbe rendered without color.
\n", + "description": "Loads a 3D model to create a\np5.Geometry object.
\nloadModel()
can load 3D models from OBJ and STL files. Once the model is\nloaded, it can be displayed with the\nmodel() function, as in model(shape)
.
There are three ways to call loadModel()
with optional parameters to help\nprocess the model.
The first parameter, path
, is always a String
with the path to the\nfile. Paths to local files should be relative, as in\nloadModel('assets/model.obj')
. URLs such as\n'https://example.com/model.obj'
may be blocked due to browser security.
Note: When loading a .obj
file that references materials stored in\n.mtl
files, p5.js will attempt to load and apply those materials.\nTo ensure that the .obj
file reads the .mtl
file correctly include the\n.mtl
file alongside it.
The first way to call loadModel()
has three optional parameters after the\nfile path. The first optional parameter, successCallback
, is a function\nto call once the model loads. For example,\nloadModel('assets/model.obj', handleModel)
will call the handleModel()
\nfunction once the model loads. The second optional parameter,\nfailureCallback
, is a function to call if the model fails to load. For\nexample, loadModel('assets/model.obj', handleModel, handleFailure)
will\ncall the handleFailure()
function if an error occurs while loading. The\nthird optional parameter, fileType
, is the model’s file extension as a\nstring. For example,\nloadModel('assets/model', handleModel, handleFailure, '.obj')
will try to\nload the file model as a .obj
file.
The second way to call loadModel()
has four optional parameters after the\nfile path. The first optional parameter is a Boolean
value. If true
is\npassed, as in loadModel('assets/model.obj', true)
, then the model will be\nresized to ensure it fits the canvas. The next three parameters are\nsuccessCallback
, failureCallback
, and fileType
as described above.
The third way to call loadModel()
has one optional parameter after the\nfile path. The optional parameter, options
, is an Object
with options,\nas in loadModel('assets/model.obj', options)
. The options
object can\nhave the following properties:
let options = {\n // Enables standardized size scaling during loading if set to true.\n normalize: true,\n\n // Function to call once the model loads.\n successCallback: handleModel,\n\n // Function to call if an error occurs while loading.\n failureCallback: handleError,\n\n // Model's file extension.\n fileType: '.stl',\n\n // Flips the U texture coordinates of the model.\n flipU: false,\n\n // Flips the V texture coordinates of the model.\n flipV: false\n};\n\n// Pass the options object to loadModel().\nloadModel('assets/model.obj', options);\n
\nModels can take time to load. Calling loadModel()
in\npreload() ensures models load before they're\nused in setup() or draw().
Note: There’s no support for colored STL files. STL files with color will\nbe rendered without color.
\n", "itemtype": "method", "name": "loadModel", "return": { @@ -23457,7 +23120,7 @@ } }, { - "line": 319, + "line": 324, "params": [ { "name": "path", @@ -23489,7 +23152,7 @@ } }, { - "line": 327, + "line": 332, "params": [ { "name": "path", @@ -23550,7 +23213,7 @@ }, { "file": "src/webgl/loading.js", - "line": 546, + "line": 551, "description": "Parse OBJ lines into model. For reference, this is what a simple model of a\nsquare might look like:
\nv -0.5 -0.5 0.5\nv -0.5 -0.5 -0.5\nv -0.5 0.5 -0.5\nv -0.5 0.5 0.5
\nf 4 3 2 1
\n", "class": "p5", "module": "Shape", @@ -23558,7 +23221,7 @@ }, { "file": "src/webgl/loading.js", - "line": 690, + "line": 695, "description": "STL files can be of two types, ASCII and Binary,
\nWe need to convert the arrayBuffer to an array of strings,\nto parse it as an ASCII file.
\n", "class": "p5", "module": "Shape", @@ -23566,7 +23229,7 @@ }, { "file": "src/webgl/loading.js", - "line": 717, + "line": 722, "description": "This function checks if the file is in ASCII format or in Binary format
\nIt is done by searching keyword solid
at the start of the file.
An ASCII STL data must begin with solid
as the first six bytes.\nHowever, ASCII STLs lacking the SPACE after the d
are known to be\nplentiful. So, check the first 5 bytes for solid
.
Several encodings, such as UTF-8, precede the text with up to 5 bytes:\nhttps://en.wikipedia.org/wiki/Byte_order_mark#Byte_order_marks_by_encoding\nSearch for solid
to start anywhere after those prefixes.
This function matches the query
at the provided offset
This function parses the Binary STL files.\nhttps://en.wikipedia.org/wiki/STL_%28file_format%29#Binary_STL
\nCurrently there is no support for the colors provided in STL files.
\n", "class": "p5", "module": "Shape", @@ -23590,7 +23253,7 @@ }, { "file": "src/webgl/loading.js", - "line": 844, + "line": 849, "description": "ASCII STL file starts with solid 'nameOfFile'
\nThen contain the normal of the face, starting with facet normal
\nNext contain a keyword indicating the start of face vertex, outer loop
\nNext comes the three vertex, starting with vertex x y z
\nVertices ends with endloop
\nFace ends with endfacet
\nNext face starts with facet normal
\nThe end of the file is indicated by endsolid
Draws a p5.Geometry object to the canvas.
\nThe parameter, model
, is the\np5.Geometry object to draw.\np5.Geometry objects can be built with\nbuildGeometry(), or\nbeginGeometry() and\nendGeometry(). They can also be loaded from\na file with loadGeometry().
Note: model()
can only be used in WebGL mode.
Load a 3d model from an OBJ or STL string.
\nOBJ and STL files lack a built-in sense of scale, causing models exported from different programs to vary in size.\nIf your model doesn't display correctly, consider using loadModel()
with normalize
set to true
to standardize its size.\nFurther adjustments can be made using the scale()
function.
Also, the support for colored STL files is not present. STL files with color will be\nrendered without color properties.
\nmodelString
: Specifies the plain text string of either an stl or obj file to be loaded.fileType
: Defines the file extension of the model.normalize
: Enables standardized size scaling during loading if set to true.successCallback
: Callback for post-loading actions with the 3D model object.failureCallback
: Handles errors if model loading fails, receiving an event error.flipU
: Flips the U texture coordinates of the model.flipV
: Flips the V texture coordinates of the model.Flips the geometry’s texture v-coordinates.
\nIn order for texture() to work, the geometry\nneeds a way to map the points on its surface to the pixels in a rectangular\nimage that's used as a texture. The geometry's vertex at coordinates\n(x, y, z)
maps to the texture image's pixel at coordinates (u, v)
.
The myGeometry.uvs array stores the\n(u, v)
coordinates for each vertex in the order it was added to the\ngeometry. Calling myGeometry.flipV()
flips a geometry's v-coordinates\nso that the texture appears mirrored vertically.
For example, a plane's four vertices are added clockwise starting from the\ntop-left corner. Here's how calling myGeometry.flipV()
would change a\nplane's texture coordinates:
// Print the original texture coordinates.\n// Output: [0, 0, 1, 0, 0, 1, 1, 1]\nconsole.log(myGeometry.uvs);\n\n// Flip the v-coordinates.\nmyGeometry.flipV();\n\n// Print the flipped texture coordinates.\n// Output: [0, 1, 1, 1, 0, 0, 1, 0]\nconsole.log(myGeometry.uvs);\n\n// Notice the swaps:\n// Left vertices: [0, 0] <--> [1, 0]\n// Right vertices: [1, 0] <--> [1, 1]\n
\n",
+ "description": "Flips the geometry’s texture v-coordinates.
\nIn order for texture() to work, the geometry\nneeds a way to map the points on its surface to the pixels in a rectangular\nimage that's used as a texture. The geometry's vertex at coordinates\n(x, y, z)
maps to the texture image's pixel at coordinates (u, v)
.
The myGeometry.uvs array stores the\n(u, v)
coordinates for each vertex in the order it was added to the\ngeometry. Calling myGeometry.flipV()
flips a geometry's v-coordinates\nso that the texture appears mirrored vertically.
For example, a plane's four vertices are added clockwise starting from the\ntop-left corner. Here's how calling myGeometry.flipV()
would change a\nplane's texture coordinates:
// Print the original texture coordinates.\n// Output: [0, 0, 1, 0, 0, 1, 1, 1]\nconsole.log(myGeometry.uvs);\n\n// Flip the v-coordinates.\nmyGeometry.flipV();\n\n// Print the flipped texture coordinates.\n// Output: [0, 1, 1, 1, 0, 0, 1, 0]\nconsole.log(myGeometry.uvs);\n\n// Notice the swaps:\n// Left vertices: [0, 0] <--> [1, 0]\n// Right vertices: [1, 0] <--> [1, 1]\n
\n",
"itemtype": "method",
"name": "flipV",
"example": [
@@ -25602,7 +25265,7 @@
},
{
"file": "src/webgl/p5.Geometry.js",
- "line": 2222,
+ "line": 2228,
"description": "Transforms the geometry's vertices to fit snugly within a 100×100×100 box\ncentered at the origin.
\nCalling myGeometry.normalize()
translates the geometry's vertices so that\nthey're centered at the origin (0, 0, 0)
. Then it scales the vertices so\nthat they fill a 100×100×100 box. As a result, small geometries will grow\nand large geometries will shrink.
Note: myGeometry.normalize()
only works when called in the\nsetup() function.
Returns a new shader, based on the original, but with custom snippets\nof shader code replacing default behaviour.
\nEach shader may let you override bits of its behavior. Each bit is called\na hook. A hook is either for the vertex shader, if it affects the\nposition of vertices, or in the fragment shader, if it affects the pixel\ncolor. You can inspect the different hooks available by calling\nyourShader.inspectHooks()
. You can\nalso read the reference for the default material, normal material, color, line, and point shaders to\nsee what hooks they have available.
modify()
takes one parameter, hooks
, an object with the hooks you want\nto override. Each key of the hooks
object is the name\nof a hook, and the value is a string with the GLSL code for your hook.
If you supply functions that aren't existing hooks, they will get added at the start of\nthe shader as helper functions so that you can use them in your hooks.
\nTo add new uniforms to your shader, you can pass in a uniforms
object containing\nthe type and name of the uniform as the key, and a default value or function returning\na default value as its value. These will be automatically set when the shader is set\nwith shader(yourShader)
.
You can also add a declarations
key, where the value is a GLSL string declaring\ncustom uniform variables, globals, and functions shared\nbetween hooks. To add declarations just in a vertex or fragment shader, add\nvertexDeclarations
and fragmentDeclarations
keys.
Copies the shader from one drawing context to another.
\nEach p5.Shader
object must be compiled by calling\nshader() before it can run. Compilation happens\nin a drawing context which is usually the main canvas or an instance of\np5.Graphics. A shader can only be used in the\ncontext where it was compiled. The copyToContext()
method compiles the\nshader again and copies it to another drawing context where it can be\nreused.
The parameter, context
, is the drawing context where the shader will be\nused. The shader can be copied to an instance of\np5.Graphics, as in\nmyShader.copyToContext(pg)
. The shader can also be copied from a\np5.Graphics object to the main canvas using\nthe window
variable, as in myShader.copyToContext(window)
.
Note: A p5.Shader object created with\ncreateShader(),\ncreateFilterShader(), or\nloadShader()\ncan be used directly with a p5.Framebuffer\nobject created with\ncreateFramebuffer(). Both objects\nhave the same context as the main canvas.
\n", "itemtype": "method", "name": "copyToContext", @@ -25759,7 +25422,7 @@ }, { "file": "src/webgl/p5.Shader.js", - "line": 993, + "line": 990, "description": "Sets the shader’s uniform (global) variables.
\nShader programs run on the computer’s graphics processing unit (GPU).\nThey live in part of the computer’s memory that’s completely separate\nfrom the sketch that runs them. Uniforms are global variables within a\nshader program. They provide a way to pass values from a sketch running\non the CPU to a shader program running on the GPU.
\nThe first parameter, uniformName
, is a string with the uniform’s name.\nFor the shader above, uniformName
would be 'r'
.
The second parameter, data
, is the value that should be used to set the\nuniform. For example, calling myShader.setUniform('r', 0.5)
would set\nthe r
uniform in the shader above to 0.5
. data should match the\nuniform’s type. Numbers, strings, booleans, arrays, and many types of\nimages can all be passed to a shader with setUniform()
.
p5.sound \nhttps://p5js.org/reference/libraries/p5.sound
\nFrom the Processing Foundation and contributors\nhttps://github.com/processing/p5.js-sound/graphs/contributors
\nMIT License (MIT)\nhttps://github.com/processing/p5.js-sound/blob/master/LICENSE
\nSome of the many audio libraries & resources that inspire p5.sound:
\nWeb Audio API: http://w3.org/TR/webaudio/
\n", + "description": "p5.sound \nhttps://p5js.org/reference/#/libraries/p5.sound
\nFrom the Processing Foundation and contributors\nhttps://github.com/processing/p5.js-sound/graphs/contributors
\nMIT License (MIT)\nhttps://github.com/processing/p5.js-sound/blob/master/LICENSE
\nSome of the many audio libraries & resources that inspire p5.sound:
\nWeb Audio API: http://w3.org/TR/webaudio/
\n", "class": "p5.sound", "module": "p5.sound", "submodule": "p5.sound" @@ -26014,7 +25677,7 @@ { "file": "lib/addons/p5.sound.js", "line": 1145, - "description": "Save a p5.SoundFile as a .wav file. The browser will prompt the user\nto download the file to their device.\nFor uploading audio to a server, use\np5.SoundFile.saveBlob
.
Save a p5.SoundFile as a .wav file. The browser will prompt the user\nto download the file to their device.\nFor uploading audio to a server, use\np5.SoundFile.saveBlob
.
Save a p5.SoundFile as a .wav file. The browser will prompt the user\nto download the file to their device. To upload a file to a server, see\ngetBlob
\n", + "description": "Save a p5.SoundFile as a .wav file. The browser will prompt the user\nto download the file to their device. To upload a file to a server, see\ngetBlob
\n", "itemtype": "method", "name": "save", "params": [ @@ -26647,7 +26310,7 @@ { "file": "lib/addons/p5.sound.js", "line": 2882, - "description": "This method is useful for sending a SoundFile to a server. It returns the\n.wav-encoded audio data as a \"Blob\".\nA Blob is a file-like data object that can be uploaded to a server\nwith an http request. We'll\nuse the httpDo
options object to send a POST request with some\nspecific options: we encode the request as multipart/form-data
,\nand attach the blob as one of the form values using FormData
.
This method is useful for sending a SoundFile to a server. It returns the\n.wav-encoded audio data as a \"Blob\".\nA Blob is a file-like data object that can be uploaded to a server\nwith an http request. We'll\nuse the httpDo
options object to send a POST request with some\nspecific options: we encode the request as multipart/form-data
,\nand attach the blob as one of the form values using FormData
.
0.0 < smoothing < 1.0.\n Defaults to 0.8.
\n", + "description": "0.0 < smoothing < 1.0.\n Defaults to 0.8.
\n", "type": "Number" } ], @@ -28269,7 +27932,7 @@ { "file": "lib/addons/p5.sound.js", "line": 7198, - "description": "The p5.EQ is built with abstracted p5.Filter objects.\nTo modify any bands, use methods of the \np5.Filter API, especially gain
and freq
.\nBands are stored in an array, with indices 0 - 3, or 0 - 7
The p5.EQ is built with abstracted p5.Filter objects.\nTo modify any bands, use methods of the \np5.Filter API, especially gain
and freq
.\nBands are stored in an array, with indices 0 - 3, or 0 - 7
\nlet osc, delay, env;\n\nfunction setup() {\n let cnv = createCanvas(100, 100);\n background(220);\n textAlign(CENTER);\n textSize(9);\n text('click and drag mouse', width/2, height/2);\n\n osc = new p5.Oscillator('sawtooth');\n osc.amp(0.74);\n env = new p5.Envelope(0.01);\n delay = new p5.Delay(0.12, 0.7);\n \n osc.disconnect();\n osc.connect(env);\n env.disconnect();\n env.connect(delay);\n\n cnv.mousePressed(oscStart);\n cnv.mouseReleased(oscStop);\n cnv.mouseOut(oscStop);\n describe('Tap to play a square wave with delay effect.');\n}\n\nfunction oscStart() {\n background(0, 255, 255);\n text('release to hear delay', width/2, height/2);\n osc.start();\n env.triggerAttack();\n}\n\nfunction oscStop() {\n background(220);\n text('click and drag mouse', width/2, height/2);\n env.triggerRelease();\n} \n \nfunction draw() {\n \n let dtime = map(mouseX, 0, width, 0.1, 0.5);\n delay.delayTime(dtime);\n}"
- ],
- "class": "p5.Delay",
- "module": "p5.sound",
- "submodule": "p5.sound"
+ "message": "Missing item type",
+ "line": " src/image/loading_displaying.js:794"
},
{
- "file": "src/Delay.js",
- "line": 122,
- "description": "The amount of feedback in the delay line.",
- "itemtype": "method",
- "name": "feedback",
- "params": [
- {
- "name": "feedbackAmount",
- "description": "A number between 0 and 0.99.",
- "type": "Number"
- }
- ],
- "class": "p5.Delay",
- "module": "p5.sound",
- "submodule": "p5.sound"
+ "message": "Missing item type",
+ "line": " src/image/loading_displaying.js:828"
},
{
- "file": "src/Delay.js",
- "line": 132,
- "description": "Process an input signal with a delay effect.",
- "itemtype": "method",
- "name": "process",
- "params": [
- {
- "name": "unit",
- "description": "A p5.sound source such as an Oscillator, Soundfile, or AudioIn object.",
- "type": "Object"
- },
- {
- "name": "delayTime",
- "description": "The amount of delay in seconds. A number between 0 and 1.",
- "type": "Number"
- },
- {
- "name": "feedback",
- "description": "The amount of feedback. A number between 0 and 1.",
- "type": "Number"
- }
- ],
- "class": "p5.Delay",
- "module": "p5.sound",
- "submodule": "p5.sound"
+ "message": "Missing item type\nValidates clipping params. Per drawImage spec sWidth and sHight cannot be\nnegative or greater than image intrinsic width and height",
+ "line": " src/image/loading_displaying.js:871"
},
{
- "file": "src/Delay.js",
- "line": 146,
- "description": "Adjust the amplitude of the delay effect.",
- "itemtype": "method",
- "name": "amp",
- "params": [
- {
- "name": "amplitudeAmount",
- "description": "An amplitude value between 0 and 1.",
- "type": "Number"
- }
- ],
- "class": "p5.Delay",
- "module": "p5.sound",
- "submodule": "p5.sound"
+ "message": "Missing item type\nApply the current tint color to the input image, return the resulting\ncanvas.",
+ "line": " src/image/loading_displaying.js:1384"
},
{
- "file": "src/Envelope.js",
- "line": 41,
- "description": "Trigger the envelope and release it after the sustain time.",
- "itemtype": "method",
- "name": "play",
- "class": "p5.Envelope",
- "module": "p5.sound",
- "submodule": "p5.sound"
+ "message": "Missing item type\nThis module defines the p5.Image class and P5 methods for\ndrawing images to the main display canvas.",
+ "line": " src/image/p5.Image.js:9"
},
{
- "file": "src/Envelope.js",
- "line": 50,
- "description": "Trigger the Attack, and Decay portion of the Envelope. Similar to holding\ndown a key on a piano, but it will hold the sustain level until you let go.",
- "itemtype": "method",
- "name": "triggerAttack",
- "example": [
- "\n\n\nlet osc, env;\n\nfunction setup() {\n let cnv = createCanvas(100, 100);\n background(220);\n cnv.mousePressed(playSound);\n cnv.mouseReleased(stopSound);\n textAlign(CENTER);\n textSize(10);\n text('tap to triggerAttack', width/2, height/2);\n\n osc = new p5.Oscillator();\n osc.disconnect();\n env = new p5.Envelope();\n osc.connect(env);\n}\n\nfunction playSound() {\n background(0, 255, 255);\n text('release to release', width/2, height/2);\n osc.start();\n env.attackTime(random(0.00, 0.25));\n env.triggerAttack(0.5);\n}\n\nfunction stopSound() {\n background(220);\n text('tap to triggerAttack', width/2, height/2);\n env.releaseTime(random(0.1, 0.3));\n env.triggerRelease();\n}\n
\n"
- ],
- "class": "p5.Envelope",
- "module": "p5.sound",
- "submodule": "p5.sound"
+ "message": "Missing item type\nHelper function for animating GIF-based images with time",
+ "line": " src/image/p5.Image.js:342"
},
{
- "file": "src/Envelope.js",
- "line": 96,
- "description": "Trigger the Release of the envelope. Similar to releasing the key on \na piano and letting the sound fade according to the release level and \nrelease time.",
- "itemtype": "method",
- "name": "triggerRelease",
- "example": [
- "\n\n\nlet osc, env;\n\nfunction setup() {\n let cnv = createCanvas(100, 100);\n background(220);\n cnv.mousePressed(playSound);\n cnv.mouseReleased(stopSound);\n textAlign(CENTER);\n textSize(10);\n text('tap to triggerAttack', width/2, height/2);\n\n osc = new p5.Oscillator();\n osc.disconnect();\n env = new p5.Envelope();\n osc.connect(env);\n}\n\nfunction playSound() {\n background(0, 255, 255);\n text('release to release', width/2, height/2);\n osc.start();\n env.attackTime(random(0.00, 0.25));\n env.triggerAttack(0.5);\n}\n\nfunction stopSound() {\n background(220);\n text('tap to triggerAttack', width/2, height/2);\n env.releaseTime(random(0.1, 0.3));\n env.triggerRelease();\n}\n
\n"
- ],
- "class": "p5.Envelope",
- "module": "p5.sound",
- "submodule": "p5.sound"
+ "message": "Missing item type\nHelper fxn for sharing pixel methods",
+ "line": " src/image/p5.Image.js:373"
},
{
- "file": "src/Envelope.js",
- "line": 143,
- "itemtype": "method",
- "name": "setInput",
- "params": [
- {
- "name": "unit",
- "description": "A p5.sound Object",
- "type": "Object"
- }
- ],
- "class": "p5.Envelope",
- "module": "p5.sound",
- "submodule": "p5.sound"
+ "message": "Missing item type\nGenerate a blob of file data as a url to prepare for download.\nAccepts an array of data, a filename, and an extension (optional).\nThis is a private function because it does not do any formatting,\nbut it is used by saveStrings, saveJSON, saveTable etc.",
+ "line": " src/io/files.js:2407"
},
{
- "file": "src/Envelope.js",
- "line": 152,
- "description": "Sets the attack, decay, sustain, and release times of the envelope.",
- "itemtype": "method",
- "name": "setADSR",
- "params": [
- {
- "name": "attack",
- "description": "how quickly the envelope reaches the maximum level",
- "type": "Number"
- },
- {
- "name": "decay",
- "description": "how quickly the envelope reaches the sustain level",
- "type": "Number"
- },
- {
- "name": "sustain",
- "description": "how long the envelope stays at the decay level",
- "type": "Number"
- },
- {
- "name": "release",
- "description": "how quickly the envelope fades out after the sustain level",
- "type": "Number"
- }
- ],
- "class": "p5.Envelope",
- "module": "p5.sound",
- "submodule": "p5.sound"
+ "message": "Missing item type\nReturns a file extension, or another string\nif the provided parameter has no extension.",
+ "line": " src/io/files.js:2475"
+ },
+ {
+ "message": "Missing item type\nReturns true if the browser is Safari, false if not.\nSafari makes trouble for downloading files.",
+ "line": " src/io/files.js:2508"
+ },
+ {
+ "message": "Missing item type\nHelper function, a callback for download that deletes\nan invisible anchor element from the DOM once the file\nhas been automatically downloaded.",
+ "line": " src/io/files.js:2519"
+ },
+ {
+ "message": "Missing item type\nTable Options\nGeneric class for handling tabular data, typically from a\nCSV, TSV, or other sort of spreadsheet file.\nCSV files are\n\ncomma separated values, often with the data in quotes. TSV\nfiles use tabs as separators, and usually don't bother with the\nquotes.\nFile names should end with .csv if they're comma separated.\nA rough \"spec\" for CSV can be found\nhere.\nTo load files, use the loadTable method.\nTo save tables to your computer, use the save method\n or the saveTable method.\n\nPossible options include:\n\n- csv - parse the table as comma-separated values\n
- tsv - parse the table as tab-separated values\n
- header - this table has a header (title) row\n
",
+ "line": " src/io/p5.Table.js:9"
+ },
+ {
+ "message": "Missing item type",
+ "line": " src/math/p5.Vector.js:435"
+ },
+ {
+ "message": "Missing item type",
+ "line": " src/math/p5.Vector.js:449"
+ },
+ {
+ "message": "Missing item type\nMultiplies a vector by a scalar and returns a new vector.",
+ "line": " src/math/p5.Vector.js:3431"
+ },
+ {
+ "message": "Missing item type\nRotates the vector (only 2D vectors) by the given angle; magnitude remains the same. Returns a new vector.",
+ "line": " src/math/p5.Vector.js:3487"
+ },
+ {
+ "message": "Missing item type\nDivides a vector by a scalar and returns a new vector.",
+ "line": " src/math/p5.Vector.js:3516"
+ },
+ {
+ "message": "Missing item type\nCalculates the dot product of two vectors.",
+ "line": " src/math/p5.Vector.js:3573"
+ },
+ {
+ "message": "Missing item type\nCalculates the cross product of two vectors.",
+ "line": " src/math/p5.Vector.js:3587"
+ },
+ {
+ "message": "Missing item type\nCalculates the Euclidean distance between two points (considering a\npoint as a vector object).",
+ "line": " src/math/p5.Vector.js:3601"
+ },
+ {
+ "message": "Missing item type\nLinear interpolate a vector to another vector and return the result as a\nnew vector.",
+ "line": " src/math/p5.Vector.js:3616"
+ },
+ {
+ "message": "Missing item type\nPerforms spherical linear interpolation with the other vector\nand returns the resulting vector.\nThis works in both 3D and 2D. As for 2D, the result of slerping\nbetween 2D vectors is always a 2D vector.",
+ "line": " src/math/p5.Vector.js:3646"
+ },
+ {
+ "message": "Missing item type\nCalculates the magnitude (length) of the vector and returns the result as\na float (this is simply the equation `sqrt(x*x + y*y + z*z)`.)",
+ "line": " src/math/p5.Vector.js:3678"
+ },
+ {
+ "message": "Missing item type\nCalculates the squared magnitude of the vector and returns the result\nas a float (this is simply the equation (x\\*x + y\\*y + z\\*z).)\nFaster if the real length is not required in the\ncase of comparing vectors, etc.",
+ "line": " src/math/p5.Vector.js:3692"
+ },
+ {
+ "message": "Missing item type\nNormalize the vector to length 1 (make it a unit vector).",
+ "line": " src/math/p5.Vector.js:3708"
+ },
+ {
+ "message": "Missing item type\nLimit the magnitude of the vector to the value used for the max\nparameter.",
+ "line": " src/math/p5.Vector.js:3734"
+ },
+ {
+ "message": "Missing item type\nSet the magnitude of the vector to the value used for the len\nparameter.",
+ "line": " src/math/p5.Vector.js:3762"
+ },
+ {
+ "message": "Missing item type\nCalculate the angle of rotation for this vector (only 2D vectors).\np5.Vectors created using createVector()\nwill take the current angleMode into\nconsideration, and give the angle in radians or degrees accordingly.",
+ "line": " src/math/p5.Vector.js:3790"
+ },
+ {
+ "message": "Missing item type\nCalculates and returns the angle between two vectors. This function will take\nthe angleMode on v1 into consideration, and\ngive the angle in radians or degrees accordingly.",
+ "line": " src/math/p5.Vector.js:3806"
+ },
+ {
+ "message": "Missing item type\nReflect a vector about a normal to a line in 2D, or about a normal to a\nplane in 3D.",
+ "line": " src/math/p5.Vector.js:3822"
+ },
+ {
+ "message": "Missing item type\nReturn a representation of this vector as a float array. This is only\nfor temporary use. If used in any other fashion, the contents should be\ncopied by using the p5.Vector.copy()\nmethod to copy into your own vector.",
+ "line": " src/math/p5.Vector.js:3850"
+ },
+ {
+ "message": "Missing item type\nEquality check against a p5.Vector",
+ "line": " src/math/p5.Vector.js:3866"
+ },
+ {
+ "message": "Missing item type\nHelper function for clampToZero",
+ "line": " src/math/p5.Vector.js:3912"
+ },
+ {
+ "message": "Missing item type\nHelper function to measure ascent and descent.",
+ "line": " src/typography/attributes.js:455"
+ },
+ {
+ "message": "Missing item type\nReturns the set of opentype glyphs for the supplied string.\n\nNote that there is not a strict one-to-one mapping between characters\nand glyphs, so the list of returned glyphs can be larger or smaller\n than the length of the given string.",
+ "line": " src/typography/p5.Font.js:403"
+ },
+ {
+ "message": "Missing item type\nReturns an opentype path for the supplied string and position.",
+ "line": " src/typography/p5.Font.js:418"
+ },
+ {
+ "message": "Missing item type",
+ "line": " src/webgl/3d_primitives.js:1359"
+ },
+ {
+ "message": "Missing item type\nDraws a point, a coordinate in space at the dimension of one pixel,\ngiven x, y and z coordinates. The color of the point is determined\nby the current stroke, while the point size is determined by current\nstroke weight.",
+ "line": " src/webgl/3d_primitives.js:2411"
+ },
+ {
+ "message": "Missing item type\nDraw a line given two points",
+ "line": " src/webgl/3d_primitives.js:2923"
+ },
+ {
+ "message": "Missing item type",
+ "line": " src/webgl/GeometryBuilder.js:4"
+ },
+ {
+ "message": "Missing item type",
+ "line": " src/webgl/GeometryBuilder.js:21"
+ },
+ {
+ "message": "Missing item type",
+ "line": " src/webgl/GeometryBuilder.js:31"
+ },
+ {
+ "message": "Missing item type",
+ "line": " src/webgl/GeometryBuilder.js:43"
+ },
+ {
+ "message": "Missing item type\nAdds geometry from the renderer's immediate mode into the builder's\ncombined geometry.",
+ "line": " src/webgl/GeometryBuilder.js:80"
+ },
+ {
+ "message": "Missing item type\nAdds geometry from the renderer's retained mode into the builder's\ncombined geometry.",
+ "line": " src/webgl/GeometryBuilder.js:114"
+ },
+ {
+ "message": "Missing item type\nCleans up the state of the renderer and returns the combined geometry that\nwas built.",
+ "line": " src/webgl/GeometryBuilder.js:122"
+ },
+ {
+ "message": "Missing item type\nKeeps track of how many custom geometry objects have been made so that each\ncan be assigned a unique ID.",
+ "line": " src/webgl/GeometryBuilder.js:133"
+ },
+ {
+ "message": "Missing item type\nParse OBJ lines into model. For reference, this is what a simple model of a\nsquare might look like:\n\nv -0.5 -0.5 0.5\nv -0.5 -0.5 -0.5\nv -0.5 0.5 -0.5\nv -0.5 0.5 0.5\n\nf 4 3 2 1",
+ "line": " src/webgl/loading.js:551"
+ },
+ {
+ "message": "Missing item type\nSTL files can be of two types, ASCII and Binary,\n\nWe need to convert the arrayBuffer to an array of strings,\nto parse it as an ASCII file.",
+ "line": " src/webgl/loading.js:695"
+ },
+ {
+ "message": "Missing item type\nThis function checks if the file is in ASCII format or in Binary format\n\nIt is done by searching keyword `solid` at the start of the file.\n\nAn ASCII STL data must begin with `solid` as the first six bytes.\nHowever, ASCII STLs lacking the SPACE after the `d` are known to be\nplentiful. So, check the first 5 bytes for `solid`.\n\nSeveral encodings, such as UTF-8, precede the text with up to 5 bytes:\nhttps://en.wikipedia.org/wiki/Byte_order_mark#Byte_order_marks_by_encoding\nSearch for `solid` to start anywhere after those prefixes.",
+ "line": " src/webgl/loading.js:722"
+ },
+ {
+ "message": "Missing item type\nThis function matches the `query` at the provided `offset`",
+ "line": " src/webgl/loading.js:749"
+ },
+ {
+ "message": "Missing item type\nThis function parses the Binary STL files.\nhttps://en.wikipedia.org/wiki/STL_%28file_format%29#Binary_STL\n\nCurrently there is no support for the colors provided in STL files.",
+ "line": " src/webgl/loading.js:761"
+ },
+ {
+ "message": "Missing item type\nASCII STL file starts with `solid 'nameOfFile'`\nThen contain the normal of the face, starting with `facet normal`\nNext contain a keyword indicating the start of face vertex, `outer loop`\nNext comes the three vertex, starting with `vertex x y z`\nVertices ends with `endloop`\nFace ends with `endfacet`\nNext face starts with `facet normal`\nThe end of the file is indicated by `endsolid`",
+ "line": " src/webgl/loading.js:849"
+ },
+ {
+ "message": "Missing item type",
+ "line": " src/webgl/material.js:3185"
+ },
+ {
+ "message": "Missing item type",
+ "line": " src/webgl/material.js:3225"
+ },
+ {
+ "message": "Missing item type\nAn internal class to store data that will be sent to a p5.RenderBuffer.\nThose need to eventually go into a Float32Array, so this class provides a\nvariable-length array container backed by a Float32Array so that it can be\nsent to the GPU without allocating a new array each frame.\n\nLike a C++ vector, its fixed-length Float32Array backing its contents will\ndouble in size when it goes over its capacity.",
+ "line": " src/webgl/p5.DataArray.js:3"
+ },
+ {
+ "message": "Missing item type\nReturns a Float32Array window sized to the exact length of the data",
+ "line": " src/webgl/p5.DataArray.js:35"
+ },
+ {
+ "message": "Missing item type\nA \"soft\" clear, which keeps the underlying storage size the same, but\nempties the contents of its dataArray()",
+ "line": " src/webgl/p5.DataArray.js:42"
+ },
+ {
+ "message": "Missing item type\nCan be used to scale a DataArray back down to fit its contents.",
+ "line": " src/webgl/p5.DataArray.js:50"
+ },
+ {
+ "message": "Missing item type\nA full reset, which allocates a new underlying Float32Array at its initial\nlength",
+ "line": " src/webgl/p5.DataArray.js:63"
+ },
+ {
+ "message": "Missing item type\nAdds values to the DataArray, expanding its internal storage to\naccommodate the new items.",
+ "line": " src/webgl/p5.DataArray.js:72"
+ },
+ {
+ "message": "Missing item type\nReturns a copy of the data from the index `from`, inclusive, to the index\n`to`, exclusive",
+ "line": " src/webgl/p5.DataArray.js:82"
+ },
+ {
+ "message": "Missing item type\nReturns a mutable Float32Array window from the index `from`, inclusive, to\nthe index `to`, exclusive",
+ "line": " src/webgl/p5.DataArray.js:90"
+ },
+ {
+ "message": "Missing item type\nExpand capacity of the internal storage until it can fit a target size",
+ "line": " src/webgl/p5.DataArray.js:98"
+ },
+ {
+ "message": "Missing item type\nChecks the capabilities of the current WebGL environment to see if the\nsettings supplied by the user are capable of being fulfilled. If they\nare not, warnings will be logged and the settings will be changed to\nsomething close that can be fulfilled.",
+ "line": " src/webgl/p5.Framebuffer.js:471"
+ },
+ {
+ "message": "Missing item type\nCreates new textures and renderbuffers given the current size of the\nframebuffer.",
+ "line": " src/webgl/p5.Framebuffer.js:568"
+ },
+ {
+ "message": "Missing item type\nTo create a WebGL texture, one needs to supply three pieces of information:\nthe type (the data type each channel will be stored as, e.g. int or float),\nthe format (the color channels that will each be stored in the previously\nspecified type, e.g. rgb or rgba), and the internal format (the specifics\nof how data for each channel, in the aforementioned type, will be packed\ntogether, such as how many bits to use, e.g. RGBA32F or RGB565.)\n\nThe format and channels asked for by the user hint at what these values\nneed to be, and the WebGL version affects what options are avaiable.\nThis method returns the values for these three properties, given the\nframebuffer's settings.",
+ "line": " src/webgl/p5.Framebuffer.js:719"
+ },
+ {
+ "message": "Missing item type\nTo create a WebGL texture, one needs to supply three pieces of information:\nthe type (the data type each channel will be stored as, e.g. int or float),\nthe format (the color channels that will each be stored in the previously\nspecified type, e.g. rgb or rgba), and the internal format (the specifics\nof how data for each channel, in the aforementioned type, will be packed\ntogether, such as how many bits to use, e.g. RGBA32F or RGB565.)\n\nThis method takes into account the settings asked for by the user and\nreturns values for these three properties that can be used for the\ntexture storing depth information.",
+ "line": " src/webgl/p5.Framebuffer.js:780"
+ },
+ {
+ "message": "Missing item type\nA method that will be called when recreating textures. If the framebuffer\nis auto-sized, it will update its width, height, and density properties.",
+ "line": " src/webgl/p5.Framebuffer.js:841"
+ },
+ {
+ "message": "Missing item type\nCalled when the canvas that the framebuffer is attached to resizes. If the\nframebuffer is auto-sized, it will update its textures to match the new\nsize.",
+ "line": " src/webgl/p5.Framebuffer.js:855"
},
{
- "file": "src/Envelope.js",
- "line": 168,
- "description": "Sets the release time of the envelope.",
- "itemtype": "method",
- "name": "releaseTime",
- "params": [
- {
- "name": "releaseTime",
- "description": "the release time in seconds",
- "type": "Number"
- }
- ],
- "class": "p5.Envelope",
- "module": "p5.sound",
- "submodule": "p5.sound"
+ "message": "Missing item type\nCalled when the size of the framebuffer has changed (either by being\nmanually updated or from auto-size updates when its canvas changes size.)\nOld textures and renderbuffers will be deleted, and then recreated with the\nnew size.",
+ "line": " src/webgl/p5.Framebuffer.js:868"
},
{
- "file": "src/Envelope.js",
- "line": 178,
- "description": "Sets the attack time of the envelope.",
- "itemtype": "method",
- "name": "attackTime",
- "params": [
- {
- "name": "attackTime",
- "description": "the attack time in seconds",
- "type": "Number"
- }
- ],
- "class": "p5.Envelope",
- "module": "p5.sound",
- "submodule": "p5.sound"
+ "message": "Missing item type\nGiven a raw texture wrapper, delete its stored texture from WebGL memory,\nand remove it from p5's list of active textures.",
+ "line": " src/webgl/p5.Framebuffer.js:1017"
},
{
- "file": "src/FFT.js",
- "line": 84,
- "description": "Returns the frequency spectrum of the input signal.",
- "itemtype": "method",
- "name": "analyze",
- "return": {
- "description": "Array of amplitude values from 0 to 1.",
- "type": "Array"
- },
- "class": "p5.FFT",
- "module": "p5.sound",
- "submodule": "p5.sound"
+ "message": "Missing item type\nAverages the vertex normals. Used in curved\nsurfaces",
+ "line": " src/webgl/p5.Geometry.js:1891"
},
{
- "file": "src/FFT.js",
- "line": 94,
- "description": "Returns an array of sample values from the input audio.",
- "itemtype": "method",
- "name": "waveform",
- "return": {
- "description": "Array of sample values from -1 to -1.",
- "type": "Array"
- },
- "class": "p5.FFT",
- "module": "p5.sound",
- "submodule": "p5.sound"
+ "message": "Missing item type\nAverages pole normals. Used in spherical primitives",
+ "line": " src/webgl/p5.Geometry.js:1912"
},
{
- "file": "src/Gain.js",
- "line": 57,
- "description": "Adjust the amplitude of the soundfile.",
- "itemtype": "method",
- "name": "amp",
- "params": [
- {
- "name": "amplitude",
- "description": "amplitude value between 0 and 1, or an audio rate signal such as an LFO.",
- "type": "Number, Object"
- }
- ],
- "class": "p5.Gain",
- "module": "p5.sound",
- "submodule": "p5.sound"
+ "message": "Missing item type\nCreate a 2D array for establishing stroke connections",
+ "line": " src/webgl/p5.Geometry.js:1950"
},
{
- "file": "src/Noise.js",
- "line": 57,
- "itemtype": "method",
- "name": "type",
- "params": [
- {
- "name": "type",
- "description": "- the type of noise (white, pink, brown)",
- "type": "String"
- }
- ],
- "class": "p5.Noise",
- "module": "p5.sound",
- "submodule": "p5.sound"
+ "message": "Missing item type\nConverts each line segment into the vertices and vertex attributes needed\nto turn the line into a polygon on screen. This will include:\n- Two triangles line segment to create a rectangle\n- Two triangles per endpoint to create a stroke cap rectangle. A fragment\n shader is responsible for displaying the appropriate cap style within\n that rectangle.\n- Four triangles per join between adjacent line segments, creating a quad on\n either side of the join, perpendicular to the lines. A vertex shader will\n discard the quad in the \"elbow\" of the join, and a fragment shader will\n display the appropriate join style within the remaining quad.",
+ "line": " src/webgl/p5.Geometry.js:1967"
},
{
- "file": "src/Noise.js",
- "line": 66,
- "description": "Adjust the amplitude of the noise source.",
- "itemtype": "method",
- "name": "amp",
- "params": [
- {
- "name": "amplitude",
- "description": "Set the amplitude between 0 and 1.0. Or, pass in an object such as an oscillator to modulate amplitude with an audio signal.",
- "type": "Number"
- }
- ],
- "class": "p5.Noise",
- "module": "p5.sound",
- "submodule": "p5.sound"
+ "message": "Missing item type\nAdds the vertices and vertex attributes for two triangles making a rectangle\nfor a straight line segment. A vertex shader is responsible for picking\nproper coordinates on the screen given the centerline positions, the tangent,\nand the side of the centerline each vertex belongs to. Sides follow the\nfollowing scheme:\n\n -1 -1\n o-------------o\n | |\n o-------------o\n 1 1",
+ "line": " src/webgl/p5.Geometry.js:2111"
},
{
- "file": "src/Noise.js",
- "line": 81,
- "description": "Starts the noise source.",
- "itemtype": "method",
- "name": "start",
- "class": "p5.Noise",
- "module": "p5.sound",
- "submodule": "p5.sound"
+ "message": "Missing item type\nAdds the vertices and vertex attributes for two triangles representing the\nstroke cap of a line. A fragment shader is responsible for displaying the\nappropriate cap style within the rectangle they make.\n\nThe lineSides buffer will include the following values for the points on\nthe cap rectangle:\n\n -1 -2\n-----------o---o\n | |\n-----------o---o\n 1 2",
+ "line": " src/webgl/p5.Geometry.js:2155"
},
{
- "file": "src/Noise.js",
- "line": 90,
- "description": "Stops the noise source.",
- "itemtype": "method",
- "name": "stop",
- "class": "p5.Noise",
- "module": "p5.sound",
- "submodule": "p5.sound"
+ "message": "Missing item type\nAdds the vertices and vertex attributes for four triangles representing a\njoin between two adjacent line segments. This creates a quad on either side\nof the shared vertex of the two line segments, with each quad perpendicular\nto the lines. A vertex shader will discard all but the quad in the \"elbow\" of\nthe join, and a fragment shader will display the appropriate join style\nwithin the remaining quad.\n\nThe lineSides buffer will include the following values for the points on\nthe join rectangles:\n\n -1 -2\n-------------o----o\n | |\n 1 o----o----o -3\n | | 0 |\n--------o----o |\n 2| 3 |\n | |\n | |",
+ "line": " src/webgl/p5.Geometry.js:2185"
},
{
- "file": "src/Oscillator.js",
- "line": 84,
- "description": "Adjusts the frequency of the oscillator.",
- "itemtype": "method",
- "name": "freq",
- "params": [
- {
- "name": "frequency",
- "description": "frequency of the oscillator in Hz (cycles per second).",
- "type": "Number"
- },
- {
- "name": "rampTime",
- "description": "the time in seconds it takes to ramp to the new frequency (defaults to 0).",
- "type": "Number",
- "optional": true
- }
- ],
- "class": "p5.Oscillator",
- "module": "p5.sound",
- "submodule": "p5.sound"
+ "message": "Missing item type",
+ "line": " src/webgl/p5.Matrix.js:1"
},
{
- "file": "src/Oscillator.js",
- "line": 95,
- "description": "Adjusts the phase of the oscillator.",
- "itemtype": "method",
- "name": "phase",
- "params": [
- {
- "name": "phase",
- "description": "phase of the oscillator in degrees (0-360).",
- "type": "Number"
- }
- ],
- "class": "p5.Oscillator",
- "module": "p5.sound",
- "submodule": "p5.sound"
+ "message": "Missing item type\nPRIVATE",
+ "line": " src/webgl/p5.Matrix.js:962"
},
{
- "file": "src/Oscillator.js",
- "line": 105,
- "description": "Sets the type of the oscillator.",
- "itemtype": "method",
- "name": "setType",
- "params": [
- {
- "name": "type",
- "description": "type of the oscillator. Options:\n 'sine' (default), 'triangle',\n 'sawtooth', 'square'",
- "type": "String"
- }
- ],
- "class": "p5.Oscillator",
- "module": "p5.sound",
- "submodule": "p5.sound"
+ "message": "Missing item type\nThis is similar to quaternion multiplication\nbut when multipying vector with quaternion\nthe multiplication can be simplified to the below formula.\nThis was taken from the below stackexchange link\nhttps://gamedev.stackexchange.com/questions/28395/rotating-vector3-by-a-quaternion/50545#50545",
+ "line": " src/webgl/p5.Quat.js:65"
},
{
- "file": "src/Oscillator.js",
- "line": 117,
- "description": "Adjust the amplitude of the Oscillator.",
- "itemtype": "method",
- "name": "amp",
- "params": [
- {
- "name": "amplitude",
- "description": "Set the amplitude between 0 and 1.0. Or, pass in an object such as an oscillator to modulate amplitude with an audio signal.",
- "type": "Number"
- }
- ],
- "example": [
- "\n\n\nlet osc, lfo;\nlet cnv;\n\nfunction setup() {\n describe(\"a sketch that demonstrates amplitude modulation with an LFO and sine tone\");\n cnv = createCanvas(100, 100);\n cnv.mousePressed(startSound);\n textAlign(CENTER);\n textWrap(WORD);\n textSize(10);\n \n osc = new p5.Oscillator('sine');\n lfo = new p5.Oscillator(1);\n lfo.disconnect();\n osc.amp(lfo);\n}\n\nfunction startSound() {\n lfo.start();\n osc.start();\n}\n\nfunction draw(){\n background(220);\n text('click to play sound', 0, height/2 - 20, 100);\n text('control lfo with mouseX position', 0, height/2, 100);\n\n let freq = map(mouseX, 0, width, 0, 10);\n lfo.freq(freq);\n}\n
\n"
- ],
- "class": "p5.Oscillator",
- "module": "p5.sound",
- "submodule": "p5.sound"
+ "message": "Missing item type\nEnables and binds the buffers used by shader when the appropriate data exists in geometry.\nMust always be done prior to drawing geometry in WebGL.",
+ "line": " src/webgl/p5.RenderBuffer.js:13"
},
{
- "file": "src/Oscillator.js",
- "line": 168,
- "description": "Starts the oscillator. Usually from user gesture.",
- "itemtype": "method",
- "name": "start",
- "example": [
- "\n\n\nlet osc;\n\nfunction setup() {\n let cnv = createCanvas(100, 100);\n cnv.mousePressed(startOscillator);\n osc = new p5.Oscillator();\n}\n\nfunction startOscillator() {\n osc.start();\n}\n
\n"
- ],
- "class": "p5.Oscillator",
- "module": "p5.sound",
- "submodule": "p5.sound"
+ "message": "Missing item type\nWelcome to RendererGL Immediate Mode.\nImmediate mode is used for drawing custom shapes\nfrom a set of vertices. Immediate Mode is activated\nwhen you call beginShape() & de-activated when you call endShape().\nImmediate mode is a style of programming borrowed\nfrom OpenGL's (now-deprecated) immediate mode.\nIt differs from p5.js' default, Retained Mode, which caches\ngeometries and buffers on the CPU to reduce the number of webgl\ndraw calls. Retained mode is more efficient & performative,\nhowever, Immediate Mode is useful for sketching quick\ngeometric ideas.",
+ "line": " src/webgl/p5.RendererGL.Immediate.js:1"
},
{
- "file": "src/Oscillator.js",
- "line": 193,
- "description": "Stops the oscillator.",
- "itemtype": "method",
- "name": "stop",
- "class": "p5.Oscillator",
- "module": "p5.sound",
- "submodule": "p5.sound"
+ "message": "Missing item type\nEnd shape drawing and render vertices to screen.",
+ "line": " src/webgl/p5.RendererGL.Immediate.js:191"
},
{
- "file": "src/Panner.js",
- "line": 53,
- "description": "Pan a sound source left or right.",
- "itemtype": "method",
- "name": "pan",
- "params": [
- {
- "name": "panAmount",
- "description": "Sets the pan position of the sound source. Can be a value between -1 and 1 or a an audio rate signal such as an LFO.",
- "type": "Number, Object"
- }
- ],
- "class": "p5.Panner",
- "module": "p5.sound",
- "submodule": "p5.sound"
+ "message": "Missing item type\nCalled from endShape(). This function calculates the stroke vertices for custom shapes and\ntesselates shapes when applicable.",
+ "line": " src/webgl/p5.RendererGL.Immediate.js:274"
},
{
- "file": "src/Panner3D.js",
- "line": 116,
- "description": "Connects an input source to the 3D panner.",
- "itemtype": "method",
- "name": "process",
- "params": [
- {
- "name": "input",
- "description": "an input source to process with the 3D panner.",
- "type": "Object"
- }
- ],
- "class": "p5.Panner3D",
- "module": "p5.sound",
- "submodule": "p5.sound"
+ "message": "Missing item type\nCalled from _processVertices(). This function calculates the stroke vertices for custom shapes and\ntesselates shapes when applicable.",
+ "line": " src/webgl/p5.RendererGL.Immediate.js:320"
},
{
- "file": "src/Panner3D.js",
- "line": 126,
- "description": "Set the x, y, and z position of the 3D panner.",
- "itemtype": "method",
- "name": "set",
- "params": [
- {
- "name": "xPosition",
- "description": "the x coordinate of the panner.",
- "type": "Number"
- },
- {
- "name": "yPosition",
- "description": "the y coordinate of the panner.",
- "type": "Number"
- },
- {
- "name": "zPosition",
- "description": "the z coordinate of the panner.",
- "type": "Number"
- }
- ],
- "class": "p5.Panner3D",
- "module": "p5.sound",
- "submodule": "p5.sound"
+ "message": "Missing item type\nCalled from _processVertices() when applicable. This function tesselates immediateMode.geometry.",
+ "line": " src/webgl/p5.RendererGL.Immediate.js:408"
},
{
- "file": "src/Panner3D.js",
- "line": 140,
- "description": "The rolloff rate of the panner.",
- "itemtype": "method",
- "name": "setFalloff",
- "params": [
- {
- "name": "rolloffFactor",
- "description": "",
- "type": "Number"
- },
- {
- "name": "maxDistance",
- "description": "",
- "type": "Number"
- }
- ],
- "class": "p5.Panner3D",
- "module": "p5.sound",
- "submodule": "p5.sound"
+ "message": "Missing item type\nCalled from endShape(). Responsible for calculating normals, setting shader uniforms,\nenabling all appropriate buffers, applying color blend, and drawing the fill geometry.",
+ "line": " src/webgl/p5.RendererGL.Immediate.js:505"
},
{
- "file": "src/Panner3D.js",
- "line": 152,
- "description": "Set the maximum distance of the panner.",
- "itemtype": "method",
- "name": "maxDist",
- "params": [
- {
- "name": "distance",
- "description": "the maximum distance that the sound source can be heard from.",
- "type": "Number"
- }
- ],
- "class": "p5.Panner3D",
- "module": "p5.sound",
- "submodule": "p5.sound"
+ "message": "Missing item type\nCalled from endShape(). Responsible for calculating normals, setting shader uniforms,\nenabling all appropriate buffers, applying color blend, and drawing the stroke geometry.",
+ "line": " src/webgl/p5.RendererGL.Immediate.js:552"
},
{
- "file": "src/Panner3D.js",
- "line": 162,
- "description": "Set the rolloff rate of the panner.",
- "itemtype": "method",
- "name": "rolloff",
- "params": [
- {
- "name": "r",
- "description": "the rolloff rate of the panner.",
- "type": "Number"
- }
- ],
- "class": "p5.Panner3D",
- "module": "p5.sound",
- "submodule": "p5.sound"
+ "message": "Missing item type",
+ "line": " src/webgl/p5.RendererGL.Retained.js:8"
},
{
- "file": "src/Panner3D.js",
- "line": 172,
- "description": "Set the X position of the sound source.",
- "itemtype": "method",
- "name": "positionX",
- "params": [
- {
- "name": "positionX",
- "description": "the x position of the sound source.",
- "type": "Number"
- }
- ],
- "class": "p5.Panner3D",
- "module": "p5.sound",
- "submodule": "p5.sound"
+ "message": "Missing item type\ninitializes buffer defaults. runs each time a new geometry is\nregistered",
+ "line": " src/webgl/p5.RendererGL.Retained.js:19"
},
{
- "file": "src/Panner3D.js",
- "line": 182,
- "description": "Set the Y position of the sound source.",
- "itemtype": "method",
- "name": "positionY",
- "params": [
- {
- "name": "positionY",
- "description": "the y position of the sound source.",
- "type": "Number"
- }
- ],
- "class": "p5.Panner3D",
- "module": "p5.sound",
- "submodule": "p5.sound"
+ "message": "Missing item type\ncreates a buffers object that holds the WebGL render buffers\nfor a geometry.",
+ "line": " src/webgl/p5.RendererGL.Retained.js:67"
+ },
+ {
+ "message": "Missing item type\nDraws buffers given a geometry key ID",
+ "line": " src/webgl/p5.RendererGL.Retained.js:120"
+ },
+ {
+ "message": "Missing item type",
+ "line": " src/webgl/p5.RendererGL.js:318"
+ },
+ {
+ "message": "Missing item type",
+ "line": " src/webgl/p5.RendererGL.js:389"
+ },
+ {
+ "message": "Missing item type\nmodel view, projection, & normal\nmatrices",
+ "line": " src/webgl/p5.RendererGL.js:535"
+ },
+ {
+ "message": "Missing item type\n[background description]",
+ "line": " src/webgl/p5.RendererGL.js:933"
+ },
+ {
+ "message": "Missing item type",
+ "line": " src/webgl/p5.RendererGL.js:1418"
},
{
- "file": "src/Panner3D.js",
- "line": 192,
- "description": "Set the Z position of the sound source.",
- "itemtype": "method",
- "name": "positionZ",
- "params": [
- {
- "name": "positionZ",
- "description": "the z position of the sound source.",
- "type": "Number"
- }
- ],
- "class": "p5.Panner3D",
- "module": "p5.sound",
- "submodule": "p5.sound"
+ "message": "Missing item type\n[resize description]",
+ "line": " src/webgl/p5.RendererGL.js:1451"
},
{
- "file": "src/PitchShifter.js",
- "line": 55,
- "description": "Shift the pitch of the source audio.",
- "itemtype": "method",
- "name": "shift",
- "params": [
- {
- "name": "pitchValue",
- "description": "amount of semitones to shift the pitch",
- "type": "Number"
- }
- ],
- "class": "p5.PitchShifter",
- "module": "p5.sound",
- "submodule": "p5.sound"
+ "message": "Missing item type\nclears color and depth buffers\nwith r,g,b,a",
+ "line": " src/webgl/p5.RendererGL.js:1488"
},
{
- "file": "src/Reverb.js",
- "line": 56,
- "description": "Set the decay time of the reverb.",
- "itemtype": "method",
- "name": "set",
- "params": [
- {
- "name": "time",
- "description": "Decay time of the reverb in seconds.",
- "type": "Number"
- }
- ],
- "class": "p5.Reverb",
- "module": "p5.sound",
- "submodule": "p5.sound"
+ "message": "Missing item type\nResets all depth information so that nothing previously drawn will\nocclude anything subsequently drawn.",
+ "line": " src/webgl/p5.RendererGL.js:1523"
},
{
- "file": "src/Reverb.js",
- "line": 66,
- "description": "Adjust the dry/wet value.",
- "itemtype": "method",
- "name": "drywet",
- "params": [
- {
- "name": "mix",
- "description": "The desired mix between the original and the affected signal. A number between 0 and 1. 0 is all dry, 1 is completely affected.",
- "type": "Number"
- }
- ],
- "class": "p5.Reverb",
- "module": "p5.sound",
- "submodule": "p5.sound"
+ "message": "Missing item type\n[translate description]",
+ "line": " src/webgl/p5.RendererGL.js:1545"
},
{
- "file": "src/SoundFile.js",
- "line": 12,
- "description": "loadSound() returns a new SoundFile from a specified\npath. If called during preload(), the SoundFile will be ready\nto play in time for setup() and draw(). If called outside of\npreload, the SoundFile will not be ready immediately, so\nloadSound accepts a callback as the second parameter. Using a\n\nlocal server is recommended when loading external files.",
- "itemtype": "method",
- "name": "loadSound",
- "params": [
- {
- "name": "path",
- "description": "Path to the sound file, or an array with\n paths to soundfiles in multiple formats\n i.e. ['sound.ogg', 'sound.mp3'].\n Alternately, accepts an object: either\n from the HTML5 File API, or a p5.File.",
- "type": "String|Array"
- }
- ],
- "return": {
- "description": "Returns a SoundFile",
- "type": "SoundFile"
- },
- "example": [
- "\n\nlet mySound;\nfunction preload() {\n mySound = loadSound('/assets/doorbell.mp3');\n}\n\nfunction setup() {\n let cnv = createCanvas(100, 100);\n cnv.mousePressed(canvasPressed);\n background(220);\n text('tap here to play', 10, 20);\n}\n\nfunction canvasPressed() {\n // playing a sound file on a user gesture\n // is equivalent to `userStartAudio()`\n mySound.play();\n}\n
"
- ],
- "class": "p5.sound",
- "module": "p5.sound",
- "submodule": "SoundFile"
+ "message": "Missing item type\nScales the Model View Matrix by a vector",
+ "line": " src/webgl/p5.RendererGL.js:1564"
},
{
- "file": "src/SoundFile.js",
- "line": 111,
- "description": "Start the soundfile.",
- "itemtype": "method",
- "name": "start",
- "class": "p5.SoundFile",
- "module": "p5.sound",
- "submodule": "SoundFile"
+ "message": "Missing item type\nTODO(dave): un-private this when there is a way to actually override the\nshader used for points\n\nGet the shader used when drawing points with `point()`.\n\nYou can call `pointShader().modify()`\nand change any of the following hooks:\n- `void beforeVertex`: Called at the start of the vertex shader.\n- `vec3 getLocalPosition`: Update the position of vertices before transforms are applied. It takes in `vec3 position` and must return a modified version.\n- `vec3 getWorldPosition`: Update the position of vertices after transforms are applied. It takes in `vec3 position` and pust return a modified version.\n- `float getPointSize`: Update the size of the point. It takes in `float size` and must return a modified version.\n- `void afterVertex`: Called at the end of the vertex shader.\n- `void beforeFragment`: Called at the start of the fragment shader.\n- `bool shouldDiscard`: Points are drawn inside a square, with the corners discarded in the fragment shader to create a circle. Use this to change this logic. It takes in a `bool willDiscard` and must return a modified version.\n- `vec4 getFinalColor`: Update the final color after mixing. It takes in a `vec4 color` and must return a modified version.\n- `void afterFragment`: Called at the end of the fragment shader.\n\nCall `pointShader().inspectHooks()` to see all the possible hooks and\ntheir default implementations.",
+ "line": " src/webgl/p5.RendererGL.js:1947"
},
{
- "file": "src/SoundFile.js",
- "line": 124,
- "description": "Start the soundfile.",
- "itemtype": "method",
- "name": "play",
- "class": "p5.SoundFile",
- "module": "p5.sound",
- "submodule": "SoundFile"
+ "message": "Missing item type\nturn a two dimensional array into one dimensional array",
+ "line": " src/webgl/p5.RendererGL.js:2384"
},
{
- "file": "src/SoundFile.js",
- "line": 137,
- "description": "Stop the soundfile.",
- "itemtype": "method",
- "name": "stop",
- "class": "p5.SoundFile",
- "module": "p5.sound",
- "submodule": "SoundFile"
+ "message": "Missing item type\nturn a p5.Vector Array into a one dimensional number array",
+ "line": " src/webgl/p5.RendererGL.js:2395"
},
{
- "file": "src/SoundFile.js",
- "line": 147,
- "description": "Pause the soundfile.",
- "itemtype": "method",
- "name": "pause",
- "example": [
- "\n\n\nlet player;\n\nfunction preload() {\n player = loadSound('/assets/Damscray_DancingTiger.mp3');\n}\n\nfunction setup() {\n describe('A sketch that pauses and resumes sound file playback.');\n let cnv = createCanvas(100, 100);\n cnv.mousePressed(playSound);\n background(220);\n textAlign(CENTER);\n textWrap(WORD);\n textSize(10);\n background(220);\n text('click to play', 0, 20, 100);\n \n player.loop();\n}\n\nfunction playSound() {\n if (!player.isPlaying()) {\n player.play();\n background(220);\n text('click to pause', 0, 20, 100);\n }\n else {\n player.pause();\n background(220);\n text('click to play', 0, 20, 100);\n }\n}\n
\n"
- ],
- "class": "p5.SoundFile",
- "module": "p5.sound",
- "submodule": "SoundFile"
+ "message": "Missing item type\nensures that p5 is using a 3d renderer. throws an error if not.",
+ "line": " src/webgl/p5.RendererGL.js:2534"
},
{
- "file": "src/SoundFile.js",
- "line": 196,
- "description": "Loop the soundfile.",
- "itemtype": "method",
- "name": "loop",
- "params": [
- {
- "name": "loopState",
- "description": "Set to True or False in order to set the loop state.",
- "type": "Boolean"
- }
- ],
- "class": "p5.SoundFile",
- "module": "p5.sound",
- "submodule": "SoundFile"
+ "message": "Missing item type\nShaders are written in GLSL, but\nthere are different versions of GLSL that it might be written in.\n\nCalling this method on a `p5.Shader` will return the GLSL version it uses, either `100 es` or `300 es`.\nWebGL 1 shaders will only use `100 es`, and WebGL 2 shaders may use either.",
+ "line": " src/webgl/p5.Shader.js:233"
},
{
- "file": "src/SoundFile.js",
- "line": 206,
- "description": "Set a loop region, and optionally a playback rate, and amplitude for the soundfile.",
- "itemtype": "method",
- "name": "setLoop",
- "params": [
- {
- "name": "startTime",
- "description": "Set to True or False in order to set the loop state.",
- "type": "Number",
- "optional": true
- },
- {
- "name": "rate",
- "description": "Set to True or False in order to set the loop state.",
- "type": "Number",
- "optional": true
- },
- {
- "name": "amp",
- "description": "Set to True or False in order to set the loop state.",
- "type": "Number",
- "optional": true
- },
- {
- "name": "duration",
- "description": "Set to True or False in order to set the loop state.",
- "type": "Number",
- "optional": true
- }
- ],
- "class": "p5.SoundFile",
- "module": "p5.sound",
- "submodule": "SoundFile"
+ "message": "Missing item type",
+ "line": " src/webgl/p5.Shader.js:554"
},
{
- "file": "src/SoundFile.js",
- "line": 220,
- "description": "Adjust the amplitude of the soundfile.",
- "itemtype": "method",
- "name": "amp",
- "params": [
- {
- "name": "amplitude",
- "description": "amplitude value between 0 and 1.",
- "type": "Number"
- }
- ],
- "class": "p5.SoundFile",
- "module": "p5.sound",
- "submodule": "SoundFile"
+ "message": "Missing item type",
+ "line": " src/webgl/p5.Shader.js:764"
},
{
- "file": "src/SoundFile.js",
- "line": 231,
- "description": "Change the path for the soundfile.",
- "itemtype": "method",
- "name": "setPath",
- "params": [
- {
- "name": "path",
- "description": "Path to the sound file.",
- "type": "String"
- },
- {
- "name": "successCallback",
- "description": "Function to call when the sound file is loaded.",
- "type": "Function",
- "optional": true
- }
- ],
- "example": [
- "\n\n\nlet soundSource, cnv, btn;\n\nfunction preload() {\n soundSource = loadSound('/assets/Damscray_-_Dancing_Tiger_01.mp3');\n}\n\nfunction setup() {\n describe(\n 'a sketch that says click to play sound. there is a button that says load sound. when you click the button, the path of the sound file player changes and the new sound plays.');\n cnv = createCanvas(100, 100);\n cnv.mousePressed(playSound);\n background(220);\n textAlign(CENTER);\n textWrap(WORD);\n textSize(10);\n text('click to play sound or the button to load a new sound', 0, 20, 100);\n btn = createButton('New Sound');\n btn.mousePressed(setNewPath);\n soundSource.loop(); \n}\n\nfunction playSound() {\n soundSource.play();\n}\n\nfunction setNewPath() {\n background(220);\n text('a new sound was loaded', 0, 20, 100);\n soundSource.setPath('/assets/Damscray_-_Dancing_Tiger_02.mp3', playSound); \n}\n
\n"
- ],
- "class": "p5.SoundFile",
- "module": "p5.sound",
- "submodule": "SoundFile"
+ "message": "Missing item type",
+ "line": " lib/addons/p5.sound.js:1"
},
{
- "file": "src/SoundFile.js",
- "line": 286,
- "description": "Set the playback rate of the soundfile.",
- "itemtype": "method",
- "name": "rate",
- "params": [
- {
- "name": "rate",
- "description": "1 is normal speed, 2 is double speed. Negative values plays the soundfile backwards.",
- "type": "Number"
- }
- ],
- "class": "p5.SoundFile",
- "module": "p5.sound",
- "submodule": "SoundFile"
+ "message": "Missing item type\np5.sound \nhttps://p5js.org/reference/#/libraries/p5.sound\n\nFrom the Processing Foundation and contributors\nhttps://github.com/processing/p5.js-sound/graphs/contributors\n\nMIT License (MIT)\nhttps://github.com/processing/p5.js-sound/blob/master/LICENSE\n\nSome of the many audio libraries & resources that inspire p5.sound:\n - TONE.js (c) Yotam Mann. Licensed under The MIT License (MIT). https://github.com/TONEnoTONE/Tone.js\n - buzz.js (c) Jay Salvat. Licensed under The MIT License (MIT). http://buzz.jaysalvat.com/\n - Boris Smus Web Audio API book, 2013. Licensed under the Apache License http://www.apache.org/licenses/LICENSE-2.0\n - wavesurfer.js https://github.com/katspaugh/wavesurfer.js\n - Web Audio Components by Jordan Santell https://github.com/web-audio-components\n - Wilm Thoben's Sound library for Processing https://github.com/processing/processing/tree/master/java/libraries/sound\n\n Web Audio API: http://w3.org/TR/webaudio/",
+ "line": " lib/addons/p5.sound.js:52"
},
{
- "file": "src/SoundFile.js",
- "line": 301,
- "description": "Returns the duration of a sound file in seconds.",
- "itemtype": "method",
- "name": "duration",
- "return": {
- "description": "duration",
- "type": "Number"
- },
- "class": "p5.SoundFile",
- "module": "p5.sound",
- "submodule": "SoundFile"
+ "message": "Missing item type\nThis module has shims",
+ "line": " lib/addons/p5.sound.js:401"
},
{
- "file": "src/SoundFile.js",
- "line": 311,
- "description": "Return the sample rate of the sound file.",
- "itemtype": "method",
- "name": "sampleRate",
- "return": {
- "description": "sampleRate",
- "type": "Number"
- },
- "class": "p5.SoundFile",
- "module": "p5.sound",
- "submodule": "SoundFile"
+ "message": "Missing item type\nDetermine which filetypes are supported (inspired by buzz.js)\nThe audio element (el) will only be used to test browser support for various audio formats",
+ "line": " lib/addons/p5.sound.js:536"
},
{
- "file": "src/SoundFile.js",
- "line": 321,
- "description": "Move the playhead of a soundfile that is currently playing to a new position.",
- "itemtype": "method",
- "name": "jump",
- "params": [
- {
- "name": "timePoint",
- "description": "Time to jump to in seconds.",
- "type": "Number"
- }
- ],
- "class": "p5.SoundFile",
- "module": "p5.sound",
- "submodule": "SoundFile"
+ "message": "Missing item type",
+ "line": " lib/addons/p5.sound.js:807"
},
{
- "file": "src/SoundFile.js",
- "line": 331,
- "description": "Return the playback state of the soundfile.",
- "itemtype": "method",
- "name": "isPlaying",
- "return": {
- "description": "Playback state, true or false.",
- "type": "Boolean"
- },
- "class": "p5.SoundFile",
- "module": "p5.sound",
- "submodule": "SoundFile"
+ "message": "Missing item type\nUsed by Osc and Envelope to chain signal math",
+ "line": " lib/addons/p5.sound.js:1040"
},
{
- "file": "src/SoundFile.js",
- "line": 341,
- "description": "Return the playback state of the soundfile.",
- "itemtype": "method",
- "name": "isLooping",
- "return": {
- "description": "Looping State, true or false.",
- "type": "Boolean"
- },
- "class": "p5.SoundFile",
- "module": "p5.sound",
- "submodule": "SoundFile"
+ "message": "Missing item type\nThis is a helper function that the p5.SoundFile calls to load\nitself. Accepts a callback (the name of another function)\nas an optional parameter.",
+ "line": " lib/addons/p5.sound.js:1542"
},
{
- "file": "src/SoundFile.js",
- "line": 351,
- "description": "Define a function to call when the soundfile is done playing.",
- "itemtype": "method",
- "name": "onended",
- "params": [
- {
- "name": "callback",
- "description": "Name of a function that will be called when the soundfile is done playing.",
- "type": "Function"
- }
- ],
- "example": [
- "\n\n\nlet player;\n\nfunction preload() {\n player = loadSound('/assets/lucky_dragons_-_power_melody.mp3');\n}\n\nfunction setup() {\n let cnv = createCanvas(100, 100);\n background(220);\n textAlign(CENTER);\n textSize(10);\n text('click to play', width/2, height/2);\n cnv.mousePressed(playSound);\n player.onended(coolFunction);\n}\n\nfunction coolFunction() {\n background(220);\n text('sound is done', width/2, height/2);\n}\n\nfunction playSound() {\n background(0, 255, 255);\n text('sound is playing', width/2, height/2);\n if (!player.isPlaying()) {\n player.play();\n }\n}\n
\n"
- ],
- "class": "p5.SoundFile",
- "module": "p5.sound",
- "submodule": "SoundFile"
+ "message": "Missing item type\nStop playback on all of this soundfile's sources.",
+ "line": " lib/addons/p5.sound.js:2056"
},
{
- "file": "src/SoundFile.js",
- "line": 394,
- "description": "Return the number of samples in a sound file.",
- "itemtype": "method",
- "name": "frames",
- "return": {
- "description": "The number of samples in the sound file.",
- "type": "Number"
- },
- "example": [
- "\n\n\nlet player;\n\nfunction preload() {\n player = loadSound('/assets/lucky_dragons_-_power_melody.mp3');\n}\n\nfunction setup() {\n describe('A sketch that calculates and displays the length of a sound file using number of samples and sample rate.');\n createCanvas(100, 100);\n background(220);\n textAlign(CENTER);\n textWrap(WORD);\n textSize(10);\n frames = player.frames();\n sampleRate = player.sampleRate();\n sampleLength = round((frames / sampleRate), 2);\n info = `sample is ${sampleLength} seconds long`;\n text(info, 0, 20, 100);\n}\n
\n"
- ],
- "class": "p5.SoundFile",
- "module": "p5.sound",
- "submodule": "SoundFile"
+ "message": "Missing item type",
+ "line": " lib/addons/p5.sound.js:2604"
},
{
- "file": "src/SoundFile.js",
- "line": 428,
- "description": "Gets the number of channels in the sound file.",
- "itemtype": "method",
- "name": "sampleRate",
- "return": {
- "description": "Returns the sample rate of the sound file."
- },
- "class": "p5.SoundFile",
- "module": "p5.sound",
- "submodule": "SoundFile"
+ "message": "Missing item type\nThe p5.Effect class is built\n \tusing Tone.js CrossFade",
+ "line": " lib/addons/p5.sound.js:6455"
},
{
- "file": "src/SoundFile.js",
- "line": 438,
- "description": "Gets the number of channels in the sound file.",
- "itemtype": "method",
- "name": "channels",
- "return": {
- "description": "Returns the number of channels in the sound file."
- },
- "class": "p5.SoundFile",
- "module": "p5.sound",
- "submodule": "SoundFile"
+ "message": "Missing item type\nIn classes that extend\np5.Effect, connect effect nodes\nto the wet parameter",
+ "line": " lib/addons/p5.sound.js:6462"
},
{
- "file": "src/Utils.js",
- "line": 14,
- "description": "Get the window's audio context.",
- "itemtype": "method",
- "name": "getAudioContext",
- "return": {
- "description": "the audio context",
- "type": "AudioContext"
- },
- "class": "p5.sound",
- "module": "Sound",
- "submodule": "Sound Utilities"
+ "message": "Missing item type\nEQFilter extends p5.Filter with constraints\nnecessary for the p5.EQ",
+ "line": " lib/addons/p5.sound.js:7009"
},
{
- "file": "src/Utils.js",
- "line": 26,
- "description": "Sets the AudioContext to a specified context to enable cross library compatibility.",
- "itemtype": "method",
- "name": "setAudioContext",
- "params": [
- {
- "name": "the",
- "description": "desired AudioContext.",
- "type": "AudioContext"
- }
- ],
- "class": "p5.sound",
- "module": "Sound",
- "submodule": "Sound Utilities"
+ "message": "Missing item type\nInspired by Simple Reverb by Jordan Santell\nhttps://github.com/web-audio-components/simple-reverb/blob/master/index.js\n\nUtility function for building an impulse response\nbased on the module parameters.",
+ "line": " lib/addons/p5.sound.js:8508"
},
{
- "file": "src/Utils.js",
- "line": 35,
- "description": "userStartAudio() starts the AudioContext on a user gesture. It can be placed in a specific interaction function, such as mousePressed().",
- "itemtype": "method",
- "name": "userStartAudio",
- "class": "p5.sound",
- "module": "Sound",
- "submodule": "Sound Utilities"
+ "message": "Missing item type\nPrivate method to load a buffer as an Impulse Response,\nassign it to the convolverNode, and add to the Array of .impulses.",
+ "line": " lib/addons/p5.sound.js:8659"
},
{
- "file": "src/Utils.js",
- "line": 43,
- "description": "userStopAudio() stops the AudioContext on a user gesture.",
- "itemtype": "method",
- "name": "userStopAudio",
- "class": "p5.sound",
- "module": "Sound",
- "submodule": "Sound Utilities"
+ "message": "Missing item type\nmusicalTimeMode variables\nmodify these only when the interval is specified in musicalTime format as a string",
+ "line": " lib/addons/p5.sound.js:9808"
+ },
+ {
+ "message": "Missing item type\nDo not initiate the callback if timeFromNow is < 0\nThis ususually occurs for a few milliseconds when the page\nis not fully loaded\n\nThe callback should only be called until maxIterations is reached",
+ "line": " lib/addons/p5.sound.js:9826"
+ },
+ {
+ "message": "Missing item type\ncallback invoked when the recording is over",
+ "line": " lib/addons/p5.sound.js:10660"
+ },
+ {
+ "message": "Missing item type\nPrivate method to ensure accurate values of this._voicesInUse\nAny time a new value is scheduled, it is necessary to increment all subsequent\nscheduledValues after attack, and decrement all subsequent\nscheduledValues after release",
+ "line": " lib/addons/p5.sound.js:11995"
+ },
+ {
+ "message": "Missing item type",
+ "line": " lib/addons/p5.sound.min.js:1"
}
],
"consts": {
diff --git a/src/content/reference/config.ts b/src/content/reference/config.ts
index fb6207c9ff..b5c61a4f8e 100644
--- a/src/content/reference/config.ts
+++ b/src/content/reference/config.ts
@@ -64,7 +64,9 @@ export const referenceSchema = z.object({
submodule: z.string().optional(),
file: z.string(),
description: z.string().optional(),
- deprecated: z.string().optional(),
+ deprecated: z.string().or(
+ z.boolean().transform(() => 'This will be removed in a future version of p5.js.')
+ ).optional(),
line: z.number().or(z.string().transform((v) => parseInt(v, 10))),
params: z.array(paramSchema).optional(),
overloads: z.array(z.object({ params: z.array(paramSchema) })).optional(),
diff --git a/src/content/reference/en/p5.Amplitude/getLevel.mdx b/src/content/reference/en/p5.Amplitude/getLevel.mdx
index 173abf925e..0da0e343be 100644
--- a/src/content/reference/en/p5.Amplitude/getLevel.mdx
+++ b/src/content/reference/en/p5.Amplitude/getLevel.mdx
@@ -2,14 +2,54 @@
title: getLevel
module: p5.sound
submodule: p5.sound
-file: src/Amplitude.js
-description: Get the current amplitude value of a sound.
-line: 63
+file: lib/addons/p5.sound.js
+description: |
+ Returns a single Amplitude reading at the moment it is called.
+ For continuous readings, run in the draw loop.
+line: 3209
isConstructor: false
itemtype: method
+example:
+ - |-
+
+
+ function preload(){
+ sound = loadSound('/assets/beat.mp3');
+ }
+
+ function setup() {
+ let cnv = createCanvas(100, 100);
+ cnv.mouseClicked(toggleSound);
+ amplitude = new p5.Amplitude();
+ }
+
+ function draw() {
+ background(220, 150);
+ textAlign(CENTER);
+ text('tap to play', width/2, 20);
+
+ let level = amplitude.getLevel();
+ let size = map(level, 0, 1, 0, 200);
+ ellipse(width/2, height/2, size, size);
+ }
+
+ function toggleSound(){
+ if (sound.isPlaying()) {
+ sound.stop();
+ } else {
+ sound.play();
+ }
+ }
+
class: p5.Amplitude
+params:
+ - name: channel
+ description: |
+ Optionally return only channel 0 (left) or 1 (right)
+ type: Number
+ optional: true
return:
- description: Amplitude level (volume) of a sound.
+ description: Amplitude as a number between 0.0 and 1.0
type: Number
chainable: false
---
diff --git a/src/content/reference/en/p5.Amplitude/setInput.mdx b/src/content/reference/en/p5.Amplitude/setInput.mdx
index 118e9d3b5d..0b23ef10a6 100644
--- a/src/content/reference/en/p5.Amplitude/setInput.mdx
+++ b/src/content/reference/en/p5.Amplitude/setInput.mdx
@@ -2,16 +2,63 @@
title: setInput
module: p5.sound
submodule: p5.sound
-file: src/Amplitude.js
-description: Connect an audio source to the amplitude object.
-line: 53
+file: lib/addons/p5.sound.js
+description: |
+ Connects to the p5sound instance (main output) by default.
+ Optionally, you can pass in a specific source (i.e. a soundfile).
+line: 3117
isConstructor: false
itemtype: method
+example:
+ - |-
+
+
+ function preload(){
+ sound1 = loadSound('/assets/beat.mp3');
+ sound2 = loadSound('/assets/drum.mp3');
+ }
+ function setup(){
+ cnv = createCanvas(100, 100);
+ cnv.mouseClicked(toggleSound);
+
+ amplitude = new p5.Amplitude();
+ amplitude.setInput(sound2);
+ }
+
+ function draw() {
+ background(220);
+ text('tap to play', 20, 20);
+
+ let level = amplitude.getLevel();
+ let size = map(level, 0, 1, 0, 200);
+ ellipse(width/2, height/2, size, size);
+ }
+
+ function toggleSound(){
+ if (sound1.isPlaying() && sound2.isPlaying()) {
+ sound1.stop();
+ sound2.stop();
+ } else {
+ sound1.play();
+ sound2.play();
+ }
+ }
+
class: p5.Amplitude
params:
- - name: input
- description: '- An object that has audio output.'
- type: Object
+ - name: snd
+ description: |
+ set the sound source
+ (optional, defaults to
+ main output)
+ type: SoundObject|undefined
+ optional: true
+ - name: smoothing
+ description: |
+ a range between 0.0 and 1.0
+ to smooth amplitude readings
+ type: Number|undefined
+ optional: true
chainable: false
---
diff --git a/src/content/reference/en/p5.Amplitude/smooth.mdx b/src/content/reference/en/p5.Amplitude/smooth.mdx
index 292746b8d8..a6b3a1be4a 100644
--- a/src/content/reference/en/p5.Amplitude/smooth.mdx
+++ b/src/content/reference/en/p5.Amplitude/smooth.mdx
@@ -2,17 +2,18 @@
title: smooth
module: p5.sound
submodule: p5.sound
-file: src/Amplitude.js
-description: Get the current amplitude value of a sound.
-line: 73
+file: lib/addons/p5.sound.js
+description: |
+ Smooth Amplitude analysis by averaging with the last analysis
+ frame. Off by default.
+line: 3293
isConstructor: false
itemtype: method
class: p5.Amplitude
params:
- - name: Smooth
- description: >-
- Amplitude analysis by averaging with the last analysis frame. Off by
- default.
+ - name: set
+ description: |
+ smoothing from 0.0 <= 1
type: Number
chainable: false
---
diff --git a/src/content/reference/en/p5.AudioIn/amp.mdx b/src/content/reference/en/p5.AudioIn/amp.mdx
index ff1ffc43fa..e37ee8c799 100644
--- a/src/content/reference/en/p5.AudioIn/amp.mdx
+++ b/src/content/reference/en/p5.AudioIn/amp.mdx
@@ -2,16 +2,23 @@
title: amp
module: p5.sound
submodule: p5.sound
-file: src/AudioIn.js
-description: Set amplitude (volume) of a mic input between 0 and 1.0.
-line: 81
+file: lib/addons/p5.sound.js
+description: |
+ Set amplitude (volume) of a mic input between 0 and 1.0.
+line: 6257
isConstructor: false
itemtype: method
class: p5.AudioIn
params:
- - name: amplitudeAmount
- description: An amplitude value between 0 and 1.
+ - name: vol
+ description: |
+ between 0 and 1.0
type: Number
+ - name: time
+ description: |
+ ramp time (optional)
+ type: Number
+ optional: true
chainable: false
---
diff --git a/src/content/reference/en/p5.AudioIn/start.mdx b/src/content/reference/en/p5.AudioIn/start.mdx
index c362f96a3f..a52ef9fd12 100644
--- a/src/content/reference/en/p5.AudioIn/start.mdx
+++ b/src/content/reference/en/p5.AudioIn/start.mdx
@@ -2,12 +2,35 @@
title: start
module: p5.sound
submodule: p5.sound
-file: src/AudioIn.js
-description: Start the audio input.
-line: 56
+file: lib/addons/p5.sound.js
+description: |
+ Start processing audio input. This enables the use of other
+ AudioIn methods like getLevel(). Note that by default, AudioIn
+ is not connected to p5.sound's output. So you won't hear
+ anything unless you use the connect() method.
+ Certain browsers limit access to the user's microphone. For example,
+ Chrome only allows access from localhost and over https. For this reason,
+ you may want to include an errorCallback—a function that is called in case
+ the browser won't provide mic access.
+line: 6114
isConstructor: false
itemtype: method
class: p5.AudioIn
+params:
+ - name: successCallback
+ description: |
+ Name of a function to call on
+ success.
+ type: Function
+ optional: true
+ - name: errorCallback
+ description: |
+ Name of a function to call if
+ there was an error. For example,
+ some browsers do not support
+ getUserMedia.
+ type: Function
+ optional: true
chainable: false
---
diff --git a/src/content/reference/en/p5.AudioIn/stop.mdx b/src/content/reference/en/p5.AudioIn/stop.mdx
index 9d73f2b98f..6cdc868de6 100644
--- a/src/content/reference/en/p5.AudioIn/stop.mdx
+++ b/src/content/reference/en/p5.AudioIn/stop.mdx
@@ -2,9 +2,11 @@
title: stop
module: p5.sound
submodule: p5.sound
-file: src/AudioIn.js
-description: Stop the audio input.
-line: 72
+file: lib/addons/p5.sound.js
+description: |
+ Turn the AudioIn off. If the AudioIn is stopped, it cannot getLevel().
+ If re-starting, the user may be prompted for permission access.
+line: 6171
isConstructor: false
itemtype: method
class: p5.AudioIn
diff --git a/src/content/reference/en/p5.Biquad/freq.mdx b/src/content/reference/en/p5.Biquad/freq.mdx
deleted file mode 100644
index 2b778dd649..0000000000
--- a/src/content/reference/en/p5.Biquad/freq.mdx
+++ /dev/null
@@ -1,19 +0,0 @@
----
-title: freq
-module: p5.sound
-submodule: p5.sound
-file: src/Biquad.js
-description: Set the cutoff frequency of the filter.
-line: 109
-isConstructor: false
-itemtype: method
-class: p5.Biquad
-params:
- - name: cutoffFrequency
- description: the cutoff frequency of the filter.
- type: Number
-chainable: false
----
-
-
-# freq
diff --git a/src/content/reference/en/p5.Biquad/gain.mdx b/src/content/reference/en/p5.Biquad/gain.mdx
deleted file mode 100644
index 5918e304c1..0000000000
--- a/src/content/reference/en/p5.Biquad/gain.mdx
+++ /dev/null
@@ -1,21 +0,0 @@
----
-title: gain
-module: p5.sound
-submodule: p5.sound
-file: src/Biquad.js
-description: The gain of the filter in dB units.
-line: 89
-isConstructor: false
-itemtype: method
-class: p5.Biquad
-params:
- - name: gain
- description: >-
- gain value in dB units. The gain is only used for lowshelf, highshelf, and
- peaking filters.
- type: Number
-chainable: false
----
-
-
-# gain
diff --git a/src/content/reference/en/p5.Biquad/res.mdx b/src/content/reference/en/p5.Biquad/res.mdx
deleted file mode 100644
index a94bfb7fbb..0000000000
--- a/src/content/reference/en/p5.Biquad/res.mdx
+++ /dev/null
@@ -1,19 +0,0 @@
----
-title: res
-module: p5.sound
-submodule: p5.sound
-file: src/Biquad.js
-description: The filter's resonance factor.
-line: 79
-isConstructor: false
-itemtype: method
-class: p5.Biquad
-params:
- - name: resonance
- description: resonance of the filter. A number between 0 and 100.
- type: Number
-chainable: false
----
-
-
-# res
diff --git a/src/content/reference/en/p5.Biquad/setType.mdx b/src/content/reference/en/p5.Biquad/setType.mdx
deleted file mode 100644
index 2e01458ab8..0000000000
--- a/src/content/reference/en/p5.Biquad/setType.mdx
+++ /dev/null
@@ -1,21 +0,0 @@
----
-title: setType
-module: p5.sound
-submodule: p5.sound
-file: src/Biquad.js
-description: Set the type of the filter.
-line: 99
-isConstructor: false
-itemtype: method
-class: p5.Biquad
-params:
- - name: type
- description: >-
- type of the filter. Options: "lowpass", "highpass", "bandpass",
- "lowshelf", "highshelf", "notch", "allpass", "peaking"
- type: String
-chainable: false
----
-
-
-# setType
diff --git a/src/content/reference/en/p5.Delay/amp.mdx b/src/content/reference/en/p5.Delay/amp.mdx
index e9df3e96c7..d3b8d8d760 100644
--- a/src/content/reference/en/p5.Delay/amp.mdx
+++ b/src/content/reference/en/p5.Delay/amp.mdx
@@ -2,16 +2,29 @@
title: amp
module: p5.sound
submodule: p5.sound
-file: src/Delay.js
-description: Adjust the amplitude of the delay effect.
-line: 146
+file: lib/addons/p5.sound.js
+description: |
+ Set the output level of the delay effect.
+line: 8223
isConstructor: false
itemtype: method
class: p5.Delay
params:
- - name: amplitudeAmount
- description: An amplitude value between 0 and 1.
+ - name: volume
+ description: |
+ amplitude between 0 and 1.0
type: Number
+ - name: rampTime
+ description: |
+ create a fade that lasts rampTime
+ type: Number
+ optional: true
+ - name: timeFromNow
+ description: |
+ schedule this event to happen
+ seconds from now
+ type: Number
+ optional: true
chainable: false
---
diff --git a/src/content/reference/en/p5.Delay/delayTime.mdx b/src/content/reference/en/p5.Delay/delayTime.mdx
index 811e1c5ea5..5d427eca0e 100644
--- a/src/content/reference/en/p5.Delay/delayTime.mdx
+++ b/src/content/reference/en/p5.Delay/delayTime.mdx
@@ -2,71 +2,19 @@
title: delayTime
module: p5.sound
submodule: p5.sound
-file: src/Delay.js
-description: Set the delay time in seconds.
-line: 57
+file: lib/addons/p5.sound.js
+description: |
+ Set the delay (echo) time, in seconds. Usually this value will be
+ a floating point number between 0.0 and 1.0.
+line: 8094
isConstructor: false
itemtype: method
-example:
- - |-
-
-
-
- let osc, delay, env;
-
- function setup() {
- let cnv = createCanvas(100, 100);
- background(220);
- textAlign(CENTER);
- textSize(9);
- text('click and drag mouse', width/2, height/2);
-
- osc = new p5.Oscillator('sawtooth');
- osc.amp(0.74);
- env = new p5.Envelope(0.01);
- delay = new p5.Delay(0.12, 0.7);
-
- osc.disconnect();
- osc.connect(env);
- env.disconnect();
- env.connect(delay);
-
- cnv.mousePressed(oscStart);
- cnv.mouseReleased(oscStop);
- cnv.mouseOut(oscStop);
- describe('Tap to play a square wave with delay effect.');
- }
-
- function oscStart() {
- background(0, 255, 255);
- text('release to hear delay', width/2, height/2);
- osc.start();
- env.triggerAttack();
- }
-
- function oscStop() {
- background(220);
- text('click and drag mouse', width/2, height/2);
- env.triggerRelease();
- }
-
- function draw() {
-
- let dtime = map(mouseX, 0, width, 0.1, 0.5);
- delay.delayTime(dtime);
- }
class: p5.Delay
params:
- name: delayTime
- description: The delay time in seconds.
- type: Number
- - name: rampTime
- description: |-
- The time in seconds it takes to ramp to the new delay time.
- By default it is 0.1 seconds. Setting it to 0 will change
- the delay time immediately and demonstrate legacy behavior.
+ description: |
+ Time (in seconds) of the delay
type: Number
- optional: true
chainable: false
---
diff --git a/src/content/reference/en/p5.Delay/feedback.mdx b/src/content/reference/en/p5.Delay/feedback.mdx
index ee4efdcd84..fbe8f37acb 100644
--- a/src/content/reference/en/p5.Delay/feedback.mdx
+++ b/src/content/reference/en/p5.Delay/feedback.mdx
@@ -2,16 +2,27 @@
title: feedback
module: p5.sound
submodule: p5.sound
-file: src/Delay.js
-description: The amount of feedback in the delay line.
-line: 122
+file: lib/addons/p5.sound.js
+description: |
+ Feedback occurs when Delay sends its signal back through its input
+ in a loop. The feedback amount determines how much signal to send each
+ time through the loop. A feedback greater than 1.0 is not desirable because
+ it will increase the overall output each time through the loop,
+ creating an infinite feedback loop. The default value is 0.5
+line: 8116
isConstructor: false
itemtype: method
class: p5.Delay
params:
- - name: feedbackAmount
- description: A number between 0 and 0.99.
- type: Number
+ - name: feedback
+ description: |
+ 0.0 to 1.0, or an object such as an
+ Oscillator that can be used to
+ modulate this param
+ type: Number|Object
+return:
+ description: Feedback value
+ type: Number
chainable: false
---
diff --git a/src/content/reference/en/p5.Delay/process.mdx b/src/content/reference/en/p5.Delay/process.mdx
index 034aa0371a..c7d0dcefaf 100644
--- a/src/content/reference/en/p5.Delay/process.mdx
+++ b/src/content/reference/en/p5.Delay/process.mdx
@@ -2,22 +2,40 @@
title: process
module: p5.sound
submodule: p5.sound
-file: src/Delay.js
-description: Process an input signal with a delay effect.
-line: 132
+file: lib/addons/p5.sound.js
+description: |
+ Add delay to an audio signal according to a set
+ of delay parameters.
+line: 8049
isConstructor: false
itemtype: method
class: p5.Delay
params:
- - name: unit
- description: 'A p5.sound source such as an Oscillator, Soundfile, or AudioIn object.'
+ - name: Signal
+ description: |
+ An object that outputs audio
type: Object
- name: delayTime
- description: The amount of delay in seconds. A number between 0 and 1.
+ description: |
+ Time (in seconds) of the delay/echo.
+ Some browsers limit delayTime to
+ 1 second.
type: Number
+ optional: true
- name: feedback
- description: The amount of feedback. A number between 0 and 1.
+ description: |
+ sends the delay back through itself
+ in a loop that decreases in volume
+ each time.
type: Number
+ optional: true
+ - name: lowPass
+ description: |
+ Cutoff frequency. Only frequencies
+ below the lowPass will be part of the
+ delay.
+ type: Number
+ optional: true
chainable: false
---
diff --git a/src/content/reference/en/p5.Envelope/attackTime.mdx b/src/content/reference/en/p5.Envelope/attackTime.mdx
index bd2117c699..753d106156 100644
--- a/src/content/reference/en/p5.Envelope/attackTime.mdx
+++ b/src/content/reference/en/p5.Envelope/attackTime.mdx
@@ -2,17 +2,13 @@
title: attackTime
module: p5.sound
submodule: p5.sound
-file: src/Envelope.js
-description: Sets the attack time of the envelope.
-line: 178
+file: lib/addons/p5.sound.js
+description: |
+ Time until envelope reaches attackLevel
+line: 4767
isConstructor: false
-itemtype: method
+itemtype: property
class: p5.Envelope
-params:
- - name: attackTime
- description: the attack time in seconds
- type: Number
-chainable: false
---
diff --git a/src/content/reference/en/p5.Envelope/play.mdx b/src/content/reference/en/p5.Envelope/play.mdx
index 39d0ab629d..2508ca3595 100644
--- a/src/content/reference/en/p5.Envelope/play.mdx
+++ b/src/content/reference/en/p5.Envelope/play.mdx
@@ -2,12 +2,77 @@
title: play
module: p5.sound
submodule: p5.sound
-file: src/Envelope.js
-description: Trigger the envelope and release it after the sustain time.
-line: 41
+file: lib/addons/p5.sound.js
+description: |-
+ Play tells the envelope to start acting on a given input.
+ If the input is a p5.sound object (i.e. AudioIn, Oscillator,
+ SoundFile), then Envelope will control its output volume.
+ Envelopes can also be used to control any
+ Web Audio Audio Param.
+line: 5078
isConstructor: false
itemtype: method
+example:
+ - |-
+
+
+ let attackLevel = 1.0;
+ let releaseLevel = 0;
+
+ let attackTime = 0.001;
+ let decayTime = 0.2;
+ let susPercent = 0.2;
+ let releaseTime = 0.5;
+
+ let env, triOsc;
+
+ function setup() {
+ let cnv = createCanvas(100, 100);
+ cnv.mousePressed(playEnv);
+
+ env = new p5.Envelope();
+ triOsc = new p5.Oscillator('triangle');
+ triOsc.amp(env);
+ triOsc.freq(220);
+ triOsc.start();
+ }
+
+ function draw() {
+ background(220);
+ text('tap here to play', 5, 20);
+ attackTime = map(mouseX, 0, width, 0, 1.0);
+ attackLevel = map(mouseY, height, 0, 0, 1.0);
+ text('attack time: ' + attackTime, 5, height - 40);
+ text('attack level: ' + attackLevel, 5, height - 20);
+ }
+
+ function playEnv() {
+ // ensure that audio is enabled
+ userStartAudio();
+
+ env.setADSR(attackTime, decayTime, susPercent, releaseTime);
+ env.setRange(attackLevel, releaseLevel);
+ env.play();
+ }
+
class: p5.Envelope
+params:
+ - name: unit
+ description: |
+ A p5.sound object or
+ Web Audio Param.
+ type: Object
+ - name: startTime
+ description: |
+ time from now (in seconds) at which to play
+ type: Number
+ optional: true
+ - name: sustainTime
+ description: |
+ time to sustain before releasing the envelope
+ type: Number
+ optional: true
chainable: false
---
diff --git a/src/content/reference/en/p5.Envelope/releaseTime.mdx b/src/content/reference/en/p5.Envelope/releaseTime.mdx
index 4f8fa24eb5..6d044242af 100644
--- a/src/content/reference/en/p5.Envelope/releaseTime.mdx
+++ b/src/content/reference/en/p5.Envelope/releaseTime.mdx
@@ -2,17 +2,13 @@
title: releaseTime
module: p5.sound
submodule: p5.sound
-file: src/Envelope.js
-description: Sets the release time of the envelope.
-line: 168
+file: lib/addons/p5.sound.js
+description: |
+ Duration of the release portion of the envelope.
+line: 4790
isConstructor: false
-itemtype: method
+itemtype: property
class: p5.Envelope
-params:
- - name: releaseTime
- description: the release time in seconds
- type: Number
-chainable: false
---
diff --git a/src/content/reference/en/p5.Envelope/set.mdx b/src/content/reference/en/p5.Envelope/set.mdx
index ad96533cf8..2129898428 100644
--- a/src/content/reference/en/p5.Envelope/set.mdx
+++ b/src/content/reference/en/p5.Envelope/set.mdx
@@ -9,7 +9,7 @@ line: 4833
isConstructor: false
itemtype: method
example:
- - |
+ - |-
let attackTime;
diff --git a/src/content/reference/en/p5.Envelope/setADSR.mdx b/src/content/reference/en/p5.Envelope/setADSR.mdx
index c0106c139b..a3501f1210 100644
--- a/src/content/reference/en/p5.Envelope/setADSR.mdx
+++ b/src/content/reference/en/p5.Envelope/setADSR.mdx
@@ -2,25 +2,86 @@
title: setADSR
module: p5.sound
submodule: p5.sound
-file: src/Envelope.js
-description: 'Sets the attack, decay, sustain, and release times of the envelope.'
-line: 152
+file: lib/addons/p5.sound.js
+description: >
+ Set values like a traditional
+
+
+
+ ADSR envelope
+
+ .
+line: 4895
isConstructor: false
itemtype: method
+example:
+ - |-
+
+
+ let attackLevel = 1.0;
+ let releaseLevel = 0;
+
+ let attackTime = 0.001;
+ let decayTime = 0.2;
+ let susPercent = 0.2;
+ let releaseTime = 0.5;
+
+ let env, triOsc;
+
+ function setup() {
+ let cnv = createCanvas(100, 100);
+ cnv.mousePressed(playEnv);
+
+ env = new p5.Envelope();
+ triOsc = new p5.Oscillator('triangle');
+ triOsc.amp(env);
+ triOsc.freq(220);
+ }
+
+ function draw() {
+ background(220);
+ text('tap here to play', 5, 20);
+ attackTime = map(mouseX, 0, width, 0, 1.0);
+ text('attack time: ' + attackTime, 5, height - 40);
+ }
+
+ function playEnv() {
+ triOsc.start();
+ env.setADSR(attackTime, decayTime, susPercent, releaseTime);
+ env.play();
+ }
+
class: p5.Envelope
params:
- - name: attack
- description: how quickly the envelope reaches the maximum level
+ - name: attackTime
+ description: |
+ Time (in seconds before envelope
+ reaches Attack Level
type: Number
- - name: decay
- description: how quickly the envelope reaches the sustain level
+ - name: decayTime
+ description: |
+ Time (in seconds) before envelope
+ reaches Decay/Sustain Level
type: Number
- - name: sustain
- description: how long the envelope stays at the decay level
+ optional: true
+ - name: susRatio
+ description: |
+ Ratio between attackLevel and releaseLevel, on a scale from 0 to 1,
+ where 1.0 = attackLevel, 0.0 = releaseLevel.
+ The susRatio determines the decayLevel and the level at which the
+ sustain portion of the envelope will sustain.
+ For example, if attackLevel is 0.4, releaseLevel is 0,
+ and susAmt is 0.5, the decayLevel would be 0.2. If attackLevel is
+ increased to 1.0 (using setRange
),
+ then decayLevel would increase proportionally, to become 0.5.
type: Number
- - name: release
- description: how quickly the envelope fades out after the sustain level
+ optional: true
+ - name: releaseTime
+ description: |
+ Time in seconds from now (defaults to 0)
type: Number
+ optional: true
chainable: false
---
diff --git a/src/content/reference/en/p5.Envelope/setInput.mdx b/src/content/reference/en/p5.Envelope/setInput.mdx
index 9cfae1c4fe..4e6cb069ef 100644
--- a/src/content/reference/en/p5.Envelope/setInput.mdx
+++ b/src/content/reference/en/p5.Envelope/setInput.mdx
@@ -2,16 +2,24 @@
title: setInput
module: p5.sound
submodule: p5.sound
-file: src/Envelope.js
-description: ''
-line: 143
+file: lib/addons/p5.sound.js
+description: |
+ Assign a parameter to be controlled by this envelope.
+ If a p5.Sound object is given, then the p5.Envelope will control its
+ output gain. If multiple inputs are provided, the env will
+ control all of them.
+line: 5037
isConstructor: false
itemtype: method
class: p5.Envelope
params:
- - name: unit
- description: A p5.sound Object
+ - name: inputs
+ description: |
+ A p5.sound object or
+ Web Audio Param.
type: Object
+ optional: true
+ multiple: true
chainable: false
---
diff --git a/src/content/reference/en/p5.Envelope/triggerAttack.mdx b/src/content/reference/en/p5.Envelope/triggerAttack.mdx
index fc39c6c457..e57eeaef9a 100644
--- a/src/content/reference/en/p5.Envelope/triggerAttack.mdx
+++ b/src/content/reference/en/p5.Envelope/triggerAttack.mdx
@@ -2,52 +2,70 @@
title: triggerAttack
module: p5.sound
submodule: p5.sound
-file: src/Envelope.js
-description: |-
- Trigger the Attack, and Decay portion of the Envelope. Similar to holding
- down a key on a piano, but it will hold the sustain level until you let go.
-line: 50
+file: lib/addons/p5.sound.js
+description: |
+ Trigger the Attack, and Decay portion of the Envelope.
+ Similar to holding down a key on a piano, but it will
+ hold the sustain level until you let go. Input can be
+ any p5.sound object, or a
+ Web Audio Param.
+line: 5148
isConstructor: false
itemtype: method
example:
- |-
-
-
- let osc, env;
+
+ let attackTime = 0.001;
+ let decayTime = 0.2;
+ let susPercent = 0.3;
+ let releaseTime = 0.4;
+ let env, triOsc;
function setup() {
let cnv = createCanvas(100, 100);
background(220);
- cnv.mousePressed(playSound);
- cnv.mouseReleased(stopSound);
textAlign(CENTER);
textSize(10);
text('tap to triggerAttack', width/2, height/2);
- osc = new p5.Oscillator();
- osc.disconnect();
env = new p5.Envelope();
- osc.connect(env);
+ env.setADSR(attackTime, decayTime, susPercent, releaseTime);
+ env.setRange(1.0, 0.0);
+ triOsc = new p5.Oscillator('triangle');
+ triOsc.freq(220);
+
+ cnv.mousePressed(envAttack);
}
- function playSound() {
+ function envAttack() {
background(0, 255, 255);
text('release to release', width/2, height/2);
- osc.start();
- env.attackTime(random(0.00, 0.25));
- env.triggerAttack(0.5);
+
+ // ensures audio is enabled. See also: `userStartAudio`
+ triOsc.start();
+
+ env.triggerAttack(triOsc);
}
- function stopSound() {
+ function mouseReleased() {
background(220);
text('tap to triggerAttack', width/2, height/2);
- env.releaseTime(random(0.1, 0.3));
- env.triggerRelease();
+
+ env.triggerRelease(triOsc);
}
-
-
+
class: p5.Envelope
+params:
+ - name: unit
+ description: |
+ p5.sound Object or Web Audio Param
+ type: Object
+ - name: secondsFromNow
+ description: |
+ time from now (in seconds)
+ type: Number
chainable: false
---
diff --git a/src/content/reference/en/p5.Envelope/triggerRelease.mdx b/src/content/reference/en/p5.Envelope/triggerRelease.mdx
index 8208ac9493..fec7153918 100644
--- a/src/content/reference/en/p5.Envelope/triggerRelease.mdx
+++ b/src/content/reference/en/p5.Envelope/triggerRelease.mdx
@@ -2,53 +2,67 @@
title: triggerRelease
module: p5.sound
submodule: p5.sound
-file: src/Envelope.js
-description: |-
- Trigger the Release of the envelope. Similar to releasing the key on
- a piano and letting the sound fade according to the release level and
- release time.
-line: 96
+file: lib/addons/p5.sound.js
+description: |
+ Trigger the Release of the Envelope. This is similar to releasing
+ the key on a piano and letting the sound fade according to the
+ release level and release time.
+line: 5256
isConstructor: false
itemtype: method
example:
- |-
-
-
- let osc, env;
+
+ let attackTime = 0.001;
+ let decayTime = 0.2;
+ let susPercent = 0.3;
+ let releaseTime = 0.4;
+ let env, triOsc;
function setup() {
let cnv = createCanvas(100, 100);
background(220);
- cnv.mousePressed(playSound);
- cnv.mouseReleased(stopSound);
textAlign(CENTER);
textSize(10);
text('tap to triggerAttack', width/2, height/2);
- osc = new p5.Oscillator();
- osc.disconnect();
env = new p5.Envelope();
- osc.connect(env);
+ env.setADSR(attackTime, decayTime, susPercent, releaseTime);
+ env.setRange(1.0, 0.0);
+ triOsc = new p5.Oscillator('triangle');
+ triOsc.freq(220);
+
+ cnv.mousePressed(envAttack);
}
- function playSound() {
+ function envAttack() {
background(0, 255, 255);
text('release to release', width/2, height/2);
- osc.start();
- env.attackTime(random(0.00, 0.25));
- env.triggerAttack(0.5);
+
+ // ensures audio is enabled. See also: `userStartAudio`
+ triOsc.start();
+
+ env.triggerAttack(triOsc);
}
- function stopSound() {
+ function mouseReleased() {
background(220);
text('tap to triggerAttack', width/2, height/2);
- env.releaseTime(random(0.1, 0.3));
- env.triggerRelease();
+
+ env.triggerRelease(triOsc);
}
-
-
+
class: p5.Envelope
+params:
+ - name: unit
+ description: |
+ p5.sound Object or Web Audio Param
+ type: Object
+ - name: secondsFromNow
+ description: |
+ time to trigger the release
+ type: Number
chainable: false
---
diff --git a/src/content/reference/en/p5.FFT/analyze.mdx b/src/content/reference/en/p5.FFT/analyze.mdx
index 772f144494..b9aa276730 100644
--- a/src/content/reference/en/p5.FFT/analyze.mdx
+++ b/src/content/reference/en/p5.FFT/analyze.mdx
@@ -2,14 +2,87 @@
title: analyze
module: p5.sound
submodule: p5.sound
-file: src/FFT.js
-description: Returns the frequency spectrum of the input signal.
-line: 84
+file: lib/addons/p5.sound.js
+description: |
+ Returns an array of amplitude values (between 0 and 255)
+ across the frequency spectrum. Length is equal to FFT bins
+ (1024 by default). The array indices correspond to frequencies
+ (i.e. pitches), from the lowest to the highest that humans can
+ hear. Each value represents amplitude at that slice of the
+ frequency spectrum. Must be called prior to using
+ getEnergy()
.
+line: 3553
isConstructor: false
itemtype: method
+example:
+ - |
+
+
+ let osc, fft;
+
+ function setup(){
+ let cnv = createCanvas(100,100);
+ cnv.mousePressed(startSound);
+ osc = new p5.Oscillator();
+ osc.amp(0);
+ fft = new p5.FFT();
+ }
+
+ function draw(){
+ background(220);
+
+ let freq = map(mouseX, 0, windowWidth, 20, 10000);
+ freq = constrain(freq, 1, 20000);
+ osc.freq(freq);
+
+ let spectrum = fft.analyze();
+ noStroke();
+ fill(255, 0, 255);
+ for (let i = 0; i< spectrum.length; i++){
+ let x = map(i, 0, spectrum.length, 0, width);
+ let h = -height + map(spectrum[i], 0, 255, height, 0);
+ rect(x, height, width / spectrum.length, h );
+ }
+
+ stroke(255);
+ if (!osc.started) {
+ text('tap here and drag to change frequency', 10, 20, width - 20);
+ } else {
+ text(round(freq)+'Hz', 10, 20);
+ }
+ }
+
+ function startSound() {
+ osc.start();
+ osc.amp(0.5, 0.2);
+ }
+
+ function mouseReleased() {
+ osc.amp(0, 0.2);
+ }
+
class: p5.FFT
+params:
+ - name: bins
+ description: |
+ Must be a power of two between
+ 16 and 1024. Defaults to 1024.
+ type: Number
+ optional: true
+ - name: scale
+ description: |
+ If "dB," returns decibel
+ float measurements between
+ -140 and 0 (max).
+ Otherwise returns integers from 0-255.
+ type: Number
+ optional: true
return:
- description: Array of amplitude values from 0 to 1.
+ description: |-
+ spectrum Array of energy (amplitude/volume)
+ values across the frequency spectrum.
+ Lowest energy (silence) = 0, highest
+ possible is 255.
type: Array
chainable: false
---
diff --git a/src/content/reference/en/p5.FFT/smooth.mdx b/src/content/reference/en/p5.FFT/smooth.mdx
index 72ab4d26db..a73687d845 100644
--- a/src/content/reference/en/p5.FFT/smooth.mdx
+++ b/src/content/reference/en/p5.FFT/smooth.mdx
@@ -12,7 +12,7 @@ class: p5.FFT
params:
- name: smoothing
description: |
- 0.0 < smoothing < 1.0.
+
0.0 < smoothing < 1.0.
Defaults to 0.8.
type: Number
chainable: false
diff --git a/src/content/reference/en/p5.FFT/waveform.mdx b/src/content/reference/en/p5.FFT/waveform.mdx
index 3d6b57ab89..2e56284652 100644
--- a/src/content/reference/en/p5.FFT/waveform.mdx
+++ b/src/content/reference/en/p5.FFT/waveform.mdx
@@ -2,14 +2,34 @@
title: waveform
module: p5.sound
submodule: p5.sound
-file: src/FFT.js
-description: Returns an array of sample values from the input audio.
-line: 94
+file: lib/addons/p5.sound.js
+description: |
+ Returns an array of amplitude values (between -1.0 and +1.0) that represent
+ a snapshot of amplitude readings in a single buffer. Length will be
+ equal to bins (defaults to 1024). Can be used to draw the waveform
+ of a sound.
+line: 3501
isConstructor: false
itemtype: method
class: p5.FFT
+params:
+ - name: bins
+ description: |
+ Must be a power of two between
+ 16 and 1024. Defaults to 1024.
+ type: Number
+ optional: true
+ - name: precision
+ description: |
+ If any value is provided, will return results
+ in a Float32 Array which is more precise
+ than a regular array.
+ type: String
+ optional: true
return:
- description: Array of sample values from -1 to -1.
+ description: |-
+ Array Array of amplitude values (-1 to 1)
+ over time. Array length = bins.
type: Array
chainable: false
---
diff --git a/src/content/reference/en/p5.Gain/amp.mdx b/src/content/reference/en/p5.Gain/amp.mdx
index 85ae7b1d91..d12a40eaf6 100644
--- a/src/content/reference/en/p5.Gain/amp.mdx
+++ b/src/content/reference/en/p5.Gain/amp.mdx
@@ -2,16 +2,29 @@
title: amp
module: p5.sound
submodule: p5.sound
-file: src/Gain.js
-description: Adjust the amplitude of the soundfile.
-line: 57
+file: lib/addons/p5.sound.js
+description: |
+ Set the output level of the gain node.
+line: 11098
isConstructor: false
itemtype: method
class: p5.Gain
params:
- - name: amplitude
- description: 'amplitude value between 0 and 1, or an audio rate signal such as an LFO.'
- type: 'Number, Object'
+ - name: volume
+ description: |
+ amplitude between 0 and 1.0
+ type: Number
+ - name: rampTime
+ description: |
+ create a fade that lasts rampTime
+ type: Number
+ optional: true
+ - name: timeFromNow
+ description: |
+ schedule this event to happen
+ seconds from now
+ type: Number
+ optional: true
chainable: false
---
diff --git a/src/content/reference/en/p5.Geometry/flipV.mdx b/src/content/reference/en/p5.Geometry/flipV.mdx
index 592a451f34..cdae0753d3 100644
--- a/src/content/reference/en/p5.Geometry/flipV.mdx
+++ b/src/content/reference/en/p5.Geometry/flipV.mdx
@@ -55,11 +55,11 @@ description: >
// Notice the swaps:
- // Left vertices: [0, 0] <--> [1, 0]
+ // Left vertices: [0, 0] <--> [1, 0]
- // Right vertices: [1, 0] <--> [1, 1]
+ // Right vertices: [1, 0] <--> [1, 1]
- -->-->
+
line: 1245
isConstructor: false
itemtype: method
diff --git a/src/content/reference/en/p5.Geometry/normalize.mdx b/src/content/reference/en/p5.Geometry/normalize.mdx
index 8de6d32811..c92d3e89f9 100644
--- a/src/content/reference/en/p5.Geometry/normalize.mdx
+++ b/src/content/reference/en/p5.Geometry/normalize.mdx
@@ -21,7 +21,7 @@ description: >
Note: myGeometry.normalize()
only works when called in the
setup() function.
-line: 2222
+line: 2228
isConstructor: false
itemtype: method
example:
diff --git a/src/content/reference/en/p5.MonoSynth/play.mdx b/src/content/reference/en/p5.MonoSynth/play.mdx
index 21dffe677e..5ac2a4e0ad 100644
--- a/src/content/reference/en/p5.MonoSynth/play.mdx
+++ b/src/content/reference/en/p5.MonoSynth/play.mdx
@@ -10,7 +10,7 @@ line: 11379
isConstructor: false
itemtype: method
example:
- - |
+ - |-
let monoSynth;
diff --git a/src/content/reference/en/p5.Noise/amp.mdx b/src/content/reference/en/p5.Noise/amp.mdx
deleted file mode 100644
index 7e833160aa..0000000000
--- a/src/content/reference/en/p5.Noise/amp.mdx
+++ /dev/null
@@ -1,21 +0,0 @@
----
-title: amp
-module: p5.sound
-submodule: p5.sound
-file: src/Noise.js
-description: Adjust the amplitude of the noise source.
-line: 66
-isConstructor: false
-itemtype: method
-class: p5.Noise
-params:
- - name: amplitude
- description: >-
- Set the amplitude between 0 and 1.0. Or, pass in an object such as an
- oscillator to modulate amplitude with an audio signal.
- type: Number
-chainable: false
----
-
-
-# amp
diff --git a/src/content/reference/en/p5.Noise/start.mdx b/src/content/reference/en/p5.Noise/start.mdx
deleted file mode 100644
index 5367a9f7cd..0000000000
--- a/src/content/reference/en/p5.Noise/start.mdx
+++ /dev/null
@@ -1,15 +0,0 @@
----
-title: start
-module: p5.sound
-submodule: p5.sound
-file: src/Noise.js
-description: Starts the noise source.
-line: 81
-isConstructor: false
-itemtype: method
-class: p5.Noise
-chainable: false
----
-
-
-# start
diff --git a/src/content/reference/en/p5.Noise/stop.mdx b/src/content/reference/en/p5.Noise/stop.mdx
deleted file mode 100644
index b21c3599f2..0000000000
--- a/src/content/reference/en/p5.Noise/stop.mdx
+++ /dev/null
@@ -1,15 +0,0 @@
----
-title: stop
-module: p5.sound
-submodule: p5.sound
-file: src/Noise.js
-description: Stops the noise source.
-line: 90
-isConstructor: false
-itemtype: method
-class: p5.Noise
-chainable: false
----
-
-
-# stop
diff --git a/src/content/reference/en/p5.Noise/type.mdx b/src/content/reference/en/p5.Noise/type.mdx
deleted file mode 100644
index 9c71eff2ca..0000000000
--- a/src/content/reference/en/p5.Noise/type.mdx
+++ /dev/null
@@ -1,19 +0,0 @@
----
-title: type
-module: p5.sound
-submodule: p5.sound
-file: src/Noise.js
-description: ''
-line: 57
-isConstructor: false
-itemtype: method
-class: p5.Noise
-params:
- - name: type
- description: '- the type of noise (white, pink, brown)'
- type: String
-chainable: false
----
-
-
-# type
diff --git a/src/content/reference/en/p5.NumberDict/add.mdx b/src/content/reference/en/p5.NumberDict/add.mdx
index 825ba9cc7a..3f08fbd88f 100644
--- a/src/content/reference/en/p5.NumberDict/add.mdx
+++ b/src/content/reference/en/p5.NumberDict/add.mdx
@@ -10,7 +10,7 @@ line: 439
isConstructor: false
itemtype: method
example:
- - |
+ - |-
diff --git a/src/content/reference/en/p5.NumberDict/div.mdx b/src/content/reference/en/p5.NumberDict/div.mdx
index 006e4ef694..3e79826efe 100644
--- a/src/content/reference/en/p5.NumberDict/div.mdx
+++ b/src/content/reference/en/p5.NumberDict/div.mdx
@@ -10,7 +10,7 @@ line: 516
isConstructor: false
itemtype: method
example:
- - |
+ - |-
diff --git a/src/content/reference/en/p5.NumberDict/mult.mdx b/src/content/reference/en/p5.NumberDict/mult.mdx
index fada3ff623..f304f34c5d 100644
--- a/src/content/reference/en/p5.NumberDict/mult.mdx
+++ b/src/content/reference/en/p5.NumberDict/mult.mdx
@@ -10,7 +10,7 @@ line: 489
isConstructor: false
itemtype: method
example:
- - |
+ - |-
diff --git a/src/content/reference/en/p5.NumberDict/sub.mdx b/src/content/reference/en/p5.NumberDict/sub.mdx
index 1050d8107e..84e6e9d687 100644
--- a/src/content/reference/en/p5.NumberDict/sub.mdx
+++ b/src/content/reference/en/p5.NumberDict/sub.mdx
@@ -12,7 +12,7 @@ line: 466
isConstructor: false
itemtype: method
example:
- - |
+ - |-
diff --git a/src/content/reference/en/p5.Oscillator/amp.mdx b/src/content/reference/en/p5.Oscillator/amp.mdx
index 8506ac6232..5bbfb45878 100644
--- a/src/content/reference/en/p5.Oscillator/amp.mdx
+++ b/src/content/reference/en/p5.Oscillator/amp.mdx
@@ -2,55 +2,39 @@
title: amp
module: p5.sound
submodule: p5.sound
-file: src/Oscillator.js
-description: Adjust the amplitude of the Oscillator.
-line: 117
+file: lib/addons/p5.sound.js
+description: |
+ Set the amplitude between 0 and 1.0. Or, pass in an object
+ such as an oscillator to modulate amplitude with an audio signal.
+line: 4238
isConstructor: false
itemtype: method
-example:
- - |-
-
-
-
- let osc, lfo;
- let cnv;
-
- function setup() {
- describe("a sketch that demonstrates amplitude modulation with an LFO and sine tone");
- cnv = createCanvas(100, 100);
- cnv.mousePressed(startSound);
- textAlign(CENTER);
- textWrap(WORD);
- textSize(10);
-
- osc = new p5.Oscillator('sine');
- lfo = new p5.Oscillator(1);
- lfo.disconnect();
- osc.amp(lfo);
- }
-
- function startSound() {
- lfo.start();
- osc.start();
- }
-
- function draw(){
- background(220);
- text('click to play sound', 0, height/2 - 20, 100);
- text('control lfo with mouseX position', 0, height/2, 100);
-
- let freq = map(mouseX, 0, width, 0, 10);
- lfo.freq(freq);
- }
-
-
class: p5.Oscillator
params:
- - name: amplitude
- description: >-
- Set the amplitude between 0 and 1.0. Or, pass in an object such as an
- oscillator to modulate amplitude with an audio signal.
+ - name: vol
+ description: |
+ between 0 and 1.0
+ or a modulating signal/oscillator
+ type: Number|Object
+ - name: rampTime
+ description: |
+ create a fade that lasts rampTime
+ type: Number
+ optional: true
+ - name: timeFromNow
+ description: |
+ schedule this event to happen
+ seconds from now
type: Number
+ optional: true
+return:
+ description: |-
+ gain If no value is provided,
+ returns the Web Audio API
+ AudioParam that controls
+ this oscillator's
+ gain/amplitude/volume)
+ type: AudioParam
chainable: false
---
diff --git a/src/content/reference/en/p5.Oscillator/freq.mdx b/src/content/reference/en/p5.Oscillator/freq.mdx
index 77fb69808f..f95058121f 100644
--- a/src/content/reference/en/p5.Oscillator/freq.mdx
+++ b/src/content/reference/en/p5.Oscillator/freq.mdx
@@ -2,20 +2,62 @@
title: freq
module: p5.sound
submodule: p5.sound
-file: src/Oscillator.js
-description: Adjusts the frequency of the oscillator.
-line: 84
+file: lib/addons/p5.sound.js
+description: |
+ Set frequency of an oscillator to a value. Or, pass in an object
+ such as an oscillator to modulate the frequency with an audio signal.
+line: 4285
isConstructor: false
itemtype: method
+example:
+ - |-
+
+
+ let osc;
+
+ function setup() {
+ let cnv = createCanvas(100, 100);
+ cnv.mousePressed(playOscillator);
+ osc = new p5.Oscillator(300);
+ background(220);
+ text('tap to play', 20, 20);
+ }
+
+ function playOscillator() {
+ osc.start();
+ osc.amp(0.5);
+ // start at 700Hz
+ osc.freq(700);
+ // ramp to 60Hz over 0.7 seconds
+ osc.freq(60, 0.7);
+ osc.amp(0, 0.1, 0.7);
+ }
+
class: p5.Oscillator
params:
- - name: frequency
- description: frequency of the oscillator in Hz (cycles per second).
- type: Number
+ - name: Frequency
+ description: |
+ Frequency in Hz
+ or modulating signal/oscillator
+ type: Number|Object
- name: rampTime
- description: the time in seconds it takes to ramp to the new frequency (defaults to 0).
+ description: |
+ Ramp time (in seconds)
+ type: Number
+ optional: true
+ - name: timeFromNow
+ description: |
+ Schedule this event to happen
+ at x seconds from now
type: Number
optional: true
+return:
+ description: |-
+ Frequency If no value is provided,
+ returns the Web Audio API
+ AudioParam that controls
+ this oscillator's frequency
+ type: AudioParam
chainable: false
---
diff --git a/src/content/reference/en/p5.Oscillator/phase.mdx b/src/content/reference/en/p5.Oscillator/phase.mdx
index af992f7721..618c6eee0a 100644
--- a/src/content/reference/en/p5.Oscillator/phase.mdx
+++ b/src/content/reference/en/p5.Oscillator/phase.mdx
@@ -2,15 +2,19 @@
title: phase
module: p5.sound
submodule: p5.sound
-file: src/Oscillator.js
-description: Adjusts the phase of the oscillator.
-line: 95
+file: lib/addons/p5.sound.js
+description: |
+ Set the phase of an oscillator between 0.0 and 1.0.
+ In this implementation, phase is a delay time
+ based on the oscillator's current frequency.
+line: 4494
isConstructor: false
itemtype: method
class: p5.Oscillator
params:
- name: phase
- description: phase of the oscillator in degrees (0-360).
+ description: |
+ float between 0.0 and 1.0
type: Number
chainable: false
---
diff --git a/src/content/reference/en/p5.Oscillator/setType.mdx b/src/content/reference/en/p5.Oscillator/setType.mdx
index 696d1dfead..32766a2eb5 100644
--- a/src/content/reference/en/p5.Oscillator/setType.mdx
+++ b/src/content/reference/en/p5.Oscillator/setType.mdx
@@ -2,18 +2,17 @@
title: setType
module: p5.sound
submodule: p5.sound
-file: src/Oscillator.js
-description: Sets the type of the oscillator.
-line: 105
+file: lib/addons/p5.sound.js
+description: |
+ Set type to 'sine', 'triangle', 'sawtooth' or 'square'.
+line: 4373
isConstructor: false
itemtype: method
class: p5.Oscillator
params:
- name: type
- description: |-
- type of the oscillator. Options:
- 'sine' (default), 'triangle',
- 'sawtooth', 'square'
+ description: |
+ 'sine', 'triangle', 'sawtooth' or 'square'.
type: String
chainable: false
---
diff --git a/src/content/reference/en/p5.Oscillator/start.mdx b/src/content/reference/en/p5.Oscillator/start.mdx
index ad9379de04..82301ab394 100644
--- a/src/content/reference/en/p5.Oscillator/start.mdx
+++ b/src/content/reference/en/p5.Oscillator/start.mdx
@@ -2,30 +2,27 @@
title: start
module: p5.sound
submodule: p5.sound
-file: src/Oscillator.js
-description: Starts the oscillator. Usually from user gesture.
-line: 168
+file: lib/addons/p5.sound.js
+description: |
+ Start an oscillator.
+ Starting an oscillator on a user gesture will enable audio in browsers
+ that have a strict autoplay policy, including Chrome and most mobile
+ devices. See also: userStartAudio()
.
+line: 4168
isConstructor: false
itemtype: method
-example:
- - |-
-
-
-
- let osc;
-
- function setup() {
- let cnv = createCanvas(100, 100);
- cnv.mousePressed(startOscillator);
- osc = new p5.Oscillator();
- }
-
- function startOscillator() {
- osc.start();
- }
-
-
class: p5.Oscillator
+params:
+ - name: time
+ description: |
+ startTime in seconds from now.
+ type: Number
+ optional: true
+ - name: frequency
+ description: |
+ frequency in Hz.
+ type: Number
+ optional: true
chainable: false
---
diff --git a/src/content/reference/en/p5.Oscillator/stop.mdx b/src/content/reference/en/p5.Oscillator/stop.mdx
index 11189e1015..9b9d0631ba 100644
--- a/src/content/reference/en/p5.Oscillator/stop.mdx
+++ b/src/content/reference/en/p5.Oscillator/stop.mdx
@@ -2,12 +2,20 @@
title: stop
module: p5.sound
submodule: p5.sound
-file: src/Oscillator.js
-description: Stops the oscillator.
-line: 193
+file: lib/addons/p5.sound.js
+description: |
+ Stop an oscillator. Accepts an optional parameter
+ to determine how long (in seconds from now) until the
+ oscillator stops.
+line: 4218
isConstructor: false
itemtype: method
class: p5.Oscillator
+params:
+ - name: secondsFromNow
+ description: |
+ Time, in seconds from now.
+ type: Number
chainable: false
---
diff --git a/src/content/reference/en/p5.Panner/pan.mdx b/src/content/reference/en/p5.Panner/pan.mdx
deleted file mode 100644
index e48470c1d9..0000000000
--- a/src/content/reference/en/p5.Panner/pan.mdx
+++ /dev/null
@@ -1,21 +0,0 @@
----
-title: pan
-module: p5.sound
-submodule: p5.sound
-file: src/Panner.js
-description: Pan a sound source left or right.
-line: 53
-isConstructor: false
-itemtype: method
-class: p5.Panner
-params:
- - name: panAmount
- description: >-
- Sets the pan position of the sound source. Can be a value between -1 and 1
- or a an audio rate signal such as an LFO.
- type: 'Number, Object'
-chainable: false
----
-
-
-# pan
diff --git a/src/content/reference/en/p5.Panner3D/maxDist.mdx b/src/content/reference/en/p5.Panner3D/maxDist.mdx
index 62fca1cb65..bab86d00eb 100644
--- a/src/content/reference/en/p5.Panner3D/maxDist.mdx
+++ b/src/content/reference/en/p5.Panner3D/maxDist.mdx
@@ -2,16 +2,20 @@
title: maxDist
module: p5.sound
submodule: p5.sound
-file: src/Panner3D.js
-description: Set the maximum distance of the panner.
-line: 152
+file: lib/addons/p5.sound.js
+description: |
+ Maxium distance between the source and the listener
+line: 7852
isConstructor: false
itemtype: method
class: p5.Panner3D
params:
- - name: distance
- description: the maximum distance that the sound source can be heard from.
+ - name: maxDistance
+ description: ''
type: Number
+return:
+ description: updated value
+ type: Number
chainable: false
---
diff --git a/src/content/reference/en/p5.Panner3D/positionX.mdx b/src/content/reference/en/p5.Panner3D/positionX.mdx
index 2e6c53664d..dd250e8ad3 100644
--- a/src/content/reference/en/p5.Panner3D/positionX.mdx
+++ b/src/content/reference/en/p5.Panner3D/positionX.mdx
@@ -2,16 +2,16 @@
title: positionX
module: p5.sound
submodule: p5.sound
-file: src/Panner3D.js
-description: Set the X position of the sound source.
-line: 172
+file: lib/addons/p5.sound.js
+description: |
+ Getter and setter methods for position coordinates
+line: 7687
isConstructor: false
itemtype: method
class: p5.Panner3D
-params:
- - name: positionX
- description: the x position of the sound source.
- type: Number
+return:
+ description: updated coordinate value
+ type: Number
chainable: false
---
diff --git a/src/content/reference/en/p5.Panner3D/positionY.mdx b/src/content/reference/en/p5.Panner3D/positionY.mdx
index 803f39f385..469ec09f4e 100644
--- a/src/content/reference/en/p5.Panner3D/positionY.mdx
+++ b/src/content/reference/en/p5.Panner3D/positionY.mdx
@@ -2,16 +2,16 @@
title: positionY
module: p5.sound
submodule: p5.sound
-file: src/Panner3D.js
-description: Set the Y position of the sound source.
-line: 182
+file: lib/addons/p5.sound.js
+description: |
+ Getter and setter methods for position coordinates
+line: 7694
isConstructor: false
itemtype: method
class: p5.Panner3D
-params:
- - name: positionY
- description: the y position of the sound source.
- type: Number
+return:
+ description: updated coordinate value
+ type: Number
chainable: false
---
diff --git a/src/content/reference/en/p5.Panner3D/positionZ.mdx b/src/content/reference/en/p5.Panner3D/positionZ.mdx
index 31bfce3966..254bf1e378 100644
--- a/src/content/reference/en/p5.Panner3D/positionZ.mdx
+++ b/src/content/reference/en/p5.Panner3D/positionZ.mdx
@@ -2,16 +2,16 @@
title: positionZ
module: p5.sound
submodule: p5.sound
-file: src/Panner3D.js
-description: Set the Z position of the sound source.
-line: 192
+file: lib/addons/p5.sound.js
+description: |
+ Getter and setter methods for position coordinates
+line: 7701
isConstructor: false
itemtype: method
class: p5.Panner3D
-params:
- - name: positionZ
- description: the z position of the sound source.
- type: Number
+return:
+ description: updated coordinate value
+ type: Number
chainable: false
---
diff --git a/src/content/reference/en/p5.Panner3D/process.mdx b/src/content/reference/en/p5.Panner3D/process.mdx
index b6c6522aaf..52723cbbd9 100644
--- a/src/content/reference/en/p5.Panner3D/process.mdx
+++ b/src/content/reference/en/p5.Panner3D/process.mdx
@@ -2,15 +2,17 @@
title: process
module: p5.sound
submodule: p5.sound
-file: src/Panner3D.js
-description: Connects an input source to the 3D panner.
-line: 116
+file: lib/addons/p5.sound.js
+description: |
+ Connect an audio sorce
+line: 7654
isConstructor: false
itemtype: method
class: p5.Panner3D
params:
- - name: input
- description: an input source to process with the 3D panner.
+ - name: src
+ description: |
+ Input source
type: Object
chainable: false
---
diff --git a/src/content/reference/en/p5.Panner3D/rolloff.mdx b/src/content/reference/en/p5.Panner3D/rolloff.mdx
deleted file mode 100644
index 75477279c4..0000000000
--- a/src/content/reference/en/p5.Panner3D/rolloff.mdx
+++ /dev/null
@@ -1,19 +0,0 @@
----
-title: rolloff
-module: p5.sound
-submodule: p5.sound
-file: src/Panner3D.js
-description: Set the rolloff rate of the panner.
-line: 162
-isConstructor: false
-itemtype: method
-class: p5.Panner3D
-params:
- - name: r
- description: the rolloff rate of the panner.
- type: Number
-chainable: false
----
-
-
-# rolloff
diff --git a/src/content/reference/en/p5.Panner3D/set.mdx b/src/content/reference/en/p5.Panner3D/set.mdx
index f7b2968fcc..8b8426420d 100644
--- a/src/content/reference/en/p5.Panner3D/set.mdx
+++ b/src/content/reference/en/p5.Panner3D/set.mdx
@@ -2,22 +2,29 @@
title: set
module: p5.sound
submodule: p5.sound
-file: src/Panner3D.js
-description: 'Set the x, y, and z position of the 3D panner.'
-line: 126
+file: lib/addons/p5.sound.js
+description: |
+ Set the X,Y,Z position of the Panner
+line: 7668
isConstructor: false
itemtype: method
class: p5.Panner3D
params:
- - name: xPosition
- description: the x coordinate of the panner.
+ - name: xVal
+ description: ''
type: Number
- - name: yPosition
- description: the y coordinate of the panner.
+ - name: yVal
+ description: ''
type: Number
- - name: zPosition
- description: the z coordinate of the panner.
+ - name: zVal
+ description: ''
type: Number
+ - name: time
+ description: ''
+ type: Number
+return:
+ description: 'Updated x, y, z values as an array'
+ type: Array
chainable: false
---
diff --git a/src/content/reference/en/p5.Panner3D/setFalloff.mdx b/src/content/reference/en/p5.Panner3D/setFalloff.mdx
index 6d1f5c75d7..e8a02b8761 100644
--- a/src/content/reference/en/p5.Panner3D/setFalloff.mdx
+++ b/src/content/reference/en/p5.Panner3D/setFalloff.mdx
@@ -2,19 +2,22 @@
title: setFalloff
module: p5.sound
submodule: p5.sound
-file: src/Panner3D.js
-description: The rolloff rate of the panner.
-line: 140
+file: lib/addons/p5.sound.js
+description: |
+ Set the rolloff factor and max distance
+line: 7838
isConstructor: false
itemtype: method
class: p5.Panner3D
params:
- - name: rolloffFactor
+ - name: maxDistance
description: ''
type: Number
- - name: maxDistance
+ optional: true
+ - name: rolloffFactor
description: ''
type: Number
+ optional: true
chainable: false
---
diff --git a/src/content/reference/en/p5.PitchShifter/shift.mdx b/src/content/reference/en/p5.PitchShifter/shift.mdx
deleted file mode 100644
index 6a4e4f74b1..0000000000
--- a/src/content/reference/en/p5.PitchShifter/shift.mdx
+++ /dev/null
@@ -1,19 +0,0 @@
----
-title: shift
-module: p5.sound
-submodule: p5.sound
-file: src/PitchShifter.js
-description: Shift the pitch of the source audio.
-line: 55
-isConstructor: false
-itemtype: method
-class: p5.PitchShifter
-params:
- - name: pitchValue
- description: amount of semitones to shift the pitch
- type: Number
-chainable: false
----
-
-
-# shift
diff --git a/src/content/reference/en/p5.PolySynth/noteRelease.mdx b/src/content/reference/en/p5.PolySynth/noteRelease.mdx
index d12252b2ab..f57fbcd8d5 100644
--- a/src/content/reference/en/p5.PolySynth/noteRelease.mdx
+++ b/src/content/reference/en/p5.PolySynth/noteRelease.mdx
@@ -11,7 +11,7 @@ line: 12021
isConstructor: false
itemtype: method
example:
- - |
+ - |-
let polySynth = new p5.PolySynth();
diff --git a/src/content/reference/en/p5.Reverb/drywet.mdx b/src/content/reference/en/p5.Reverb/drywet.mdx
deleted file mode 100644
index daffbb89c2..0000000000
--- a/src/content/reference/en/p5.Reverb/drywet.mdx
+++ /dev/null
@@ -1,21 +0,0 @@
----
-title: drywet
-module: p5.sound
-submodule: p5.sound
-file: src/Reverb.js
-description: Adjust the dry/wet value.
-line: 66
-isConstructor: false
-itemtype: method
-class: p5.Reverb
-params:
- - name: mix
- description: >-
- The desired mix between the original and the affected signal. A number
- between 0 and 1. 0 is all dry, 1 is completely affected.
- type: Number
-chainable: false
----
-
-
-# drywet
diff --git a/src/content/reference/en/p5.Reverb/set.mdx b/src/content/reference/en/p5.Reverb/set.mdx
index 43ee523b56..f60e63e903 100644
--- a/src/content/reference/en/p5.Reverb/set.mdx
+++ b/src/content/reference/en/p5.Reverb/set.mdx
@@ -2,16 +2,32 @@
title: set
module: p5.sound
submodule: p5.sound
-file: src/Reverb.js
-description: Set the decay time of the reverb.
-line: 56
+file: lib/addons/p5.sound.js
+description: |
+ Set the reverb settings. Similar to .process(), but without
+ assigning a new input.
+line: 8446
isConstructor: false
itemtype: method
class: p5.Reverb
params:
- - name: time
- description: Decay time of the reverb in seconds.
+ - name: seconds
+ description: |
+ Duration of the reverb, in seconds.
+ Min: 0, Max: 10. Defaults to 3.
type: Number
+ optional: true
+ - name: decayRate
+ description: |
+ Percentage of decay with each echo.
+ Min: 0, Max: 100. Defaults to 2.
+ type: Number
+ optional: true
+ - name: reverse
+ description: |
+ Play the reverb backwards or forwards.
+ type: Boolean
+ optional: true
chainable: false
---
diff --git a/src/content/reference/en/p5.Shader/copyToContext.mdx b/src/content/reference/en/p5.Shader/copyToContext.mdx
index 2dd8f71c2c..c87c008ce2 100644
--- a/src/content/reference/en/p5.Shader/copyToContext.mdx
+++ b/src/content/reference/en/p5.Shader/copyToContext.mdx
@@ -55,7 +55,7 @@ description: >
objects
have the same context as the main canvas.
-line: 577
+line: 574
isConstructor: false
itemtype: method
example:
diff --git a/src/content/reference/en/p5.Shader/modify.mdx b/src/content/reference/en/p5.Shader/modify.mdx
index 9a2cdd5b89..ac666c7dc5 100644
--- a/src/content/reference/en/p5.Shader/modify.mdx
+++ b/src/content/reference/en/p5.Shader/modify.mdx
@@ -59,7 +59,7 @@ description: >
vertexDeclarations
and fragmentDeclarations
keys.
-line: 343
+line: 340
isConstructor: false
itemtype: method
example:
diff --git a/src/content/reference/en/p5.Shader/setUniform.mdx b/src/content/reference/en/p5.Shader/setUniform.mdx
index 7b4a7ac213..b0dd26032e 100644
--- a/src/content/reference/en/p5.Shader/setUniform.mdx
+++ b/src/content/reference/en/p5.Shader/setUniform.mdx
@@ -33,7 +33,7 @@ description: >
uniform’s type. Numbers, strings, booleans, arrays, and many types of
images can all be passed to a shader with setUniform()
.
-line: 993
+line: 990
isConstructor: false
itemtype: method
example:
diff --git a/src/content/reference/en/p5.SoundFile/amp.mdx b/src/content/reference/en/p5.SoundFile/amp.mdx
deleted file mode 100644
index e5e479b9ec..0000000000
--- a/src/content/reference/en/p5.SoundFile/amp.mdx
+++ /dev/null
@@ -1,19 +0,0 @@
----
-title: amp
-module: p5.sound
-submodule: SoundFile
-file: src/SoundFile.js
-description: Adjust the amplitude of the soundfile.
-line: 220
-isConstructor: false
-itemtype: method
-class: p5.SoundFile
-params:
- - name: amplitude
- description: amplitude value between 0 and 1.
- type: Number
-chainable: false
----
-
-
-# amp
diff --git a/src/content/reference/en/p5.SoundFile/channels.mdx b/src/content/reference/en/p5.SoundFile/channels.mdx
index 7ac3e87d5f..a771a5c8ca 100644
--- a/src/content/reference/en/p5.SoundFile/channels.mdx
+++ b/src/content/reference/en/p5.SoundFile/channels.mdx
@@ -1,15 +1,18 @@
---
title: channels
module: p5.sound
-submodule: SoundFile
-file: src/SoundFile.js
-description: Gets the number of channels in the sound file.
-line: 438
+submodule: p5.sound
+file: lib/addons/p5.sound.js
+description: |
+ Return the number of channels in a sound file.
+ For example, Mono = 1, Stereo = 2.
+line: 2340
isConstructor: false
itemtype: method
class: p5.SoundFile
return:
- description: Returns the number of channels in the sound file.
+ description: '[channels]'
+ type: Number
chainable: false
---
diff --git a/src/content/reference/en/p5.SoundFile/duration.mdx b/src/content/reference/en/p5.SoundFile/duration.mdx
index bd509e7a0b..9c26242d40 100644
--- a/src/content/reference/en/p5.SoundFile/duration.mdx
+++ b/src/content/reference/en/p5.SoundFile/duration.mdx
@@ -1,15 +1,16 @@
---
title: duration
module: p5.sound
-submodule: SoundFile
-file: src/SoundFile.js
-description: Returns the duration of a sound file in seconds.
-line: 301
+submodule: p5.sound
+file: lib/addons/p5.sound.js
+description: |
+ Returns the duration of a sound file in seconds.
+line: 2276
isConstructor: false
itemtype: method
class: p5.SoundFile
return:
- description: duration
+ description: The duration of the soundFile in seconds.
type: Number
chainable: false
---
diff --git a/src/content/reference/en/p5.SoundFile/frames.mdx b/src/content/reference/en/p5.SoundFile/frames.mdx
index 7af9a07edd..1ea17aaee5 100644
--- a/src/content/reference/en/p5.SoundFile/frames.mdx
+++ b/src/content/reference/en/p5.SoundFile/frames.mdx
@@ -1,41 +1,17 @@
---
title: frames
module: p5.sound
-submodule: SoundFile
-file: src/SoundFile.js
-description: Return the number of samples in a sound file.
-line: 394
+submodule: p5.sound
+file: lib/addons/p5.sound.js
+description: |
+ Return the number of samples in a sound file.
+ Equal to sampleRate * duration.
+line: 2367
isConstructor: false
itemtype: method
-example:
- - |-
-
-
-
- let player;
-
- function preload() {
- player = loadSound('//assets/lucky_dragons_-_power_melody.mp3');
- }
-
- function setup() {
- describe('A sketch that calculates and displays the length of a sound file using number of samples and sample rate.');
- createCanvas(100, 100);
- background(220);
- textAlign(CENTER);
- textWrap(WORD);
- textSize(10);
- frames = player.frames();
- sampleRate = player.sampleRate();
- sampleLength = round((frames / sampleRate), 2);
- info = `sample is ${sampleLength} seconds long`;
- text(info, 0, 20, 100);
- }
-
-
class: p5.SoundFile
return:
- description: The number of samples in the sound file.
+ description: '[sampleCount]'
type: Number
chainable: false
---
diff --git a/src/content/reference/en/p5.SoundFile/isLooping.mdx b/src/content/reference/en/p5.SoundFile/isLooping.mdx
index 7e7455e147..5fb89cadb4 100644
--- a/src/content/reference/en/p5.SoundFile/isLooping.mdx
+++ b/src/content/reference/en/p5.SoundFile/isLooping.mdx
@@ -1,15 +1,17 @@
---
title: isLooping
module: p5.sound
-submodule: SoundFile
-file: src/SoundFile.js
-description: Return the playback state of the soundfile.
-line: 341
+submodule: p5.sound
+file: lib/addons/p5.sound.js
+description: >
+ Returns 'true' if a p5.SoundFile is currently looping and playing, 'false'
+ if not.
+line: 1976
isConstructor: false
itemtype: method
class: p5.SoundFile
return:
- description: 'Looping State, true or false.'
+ description: ''
type: Boolean
chainable: false
---
diff --git a/src/content/reference/en/p5.SoundFile/isPlaying.mdx b/src/content/reference/en/p5.SoundFile/isPlaying.mdx
index 9a17921c48..27e3dccc40 100644
--- a/src/content/reference/en/p5.SoundFile/isPlaying.mdx
+++ b/src/content/reference/en/p5.SoundFile/isPlaying.mdx
@@ -1,15 +1,17 @@
---
title: isPlaying
module: p5.sound
-submodule: SoundFile
-file: src/SoundFile.js
-description: Return the playback state of the soundfile.
-line: 331
+submodule: p5.sound
+file: lib/addons/p5.sound.js
+description: |
+ Returns true if a p5.SoundFile is playing, false if not (i.e.
+ paused or stopped).
+line: 1997
isConstructor: false
itemtype: method
class: p5.SoundFile
return:
- description: 'Playback state, true or false.'
+ description: ''
type: Boolean
chainable: false
---
diff --git a/src/content/reference/en/p5.SoundFile/jump.mdx b/src/content/reference/en/p5.SoundFile/jump.mdx
index 1cc1a173cd..9fe1f16781 100644
--- a/src/content/reference/en/p5.SoundFile/jump.mdx
+++ b/src/content/reference/en/p5.SoundFile/jump.mdx
@@ -1,16 +1,31 @@
---
title: jump
module: p5.sound
-submodule: SoundFile
-file: src/SoundFile.js
-description: Move the playhead of a soundfile that is currently playing to a new position.
-line: 321
+submodule: p5.sound
+file: lib/addons/p5.sound.js
+description: >
+ Move the playhead of a soundfile that is currently playing to a
+
+ new position and a new duration, in seconds.
+
+ If none are given, will reset the file to play entire duration
+
+ from start to finish. To set the position of a soundfile that is
+
+ not currently playing, use the play
or loop
+ methods.
+line: 2308
isConstructor: false
itemtype: method
class: p5.SoundFile
params:
- - name: timePoint
- description: Time to jump to in seconds.
+ - name: cueTime
+ description: |
+ cueTime of the soundFile in seconds.
+ type: Number
+ - name: duration
+ description: |
+ duration in seconds.
type: Number
chainable: false
---
diff --git a/src/content/reference/en/p5.SoundFile/loop.mdx b/src/content/reference/en/p5.SoundFile/loop.mdx
index 06b447f2d3..5874de795c 100644
--- a/src/content/reference/en/p5.SoundFile/loop.mdx
+++ b/src/content/reference/en/p5.SoundFile/loop.mdx
@@ -1,17 +1,69 @@
---
title: loop
module: p5.sound
-submodule: SoundFile
-file: src/SoundFile.js
-description: Loop the soundfile.
-line: 196
+submodule: p5.sound
+file: lib/addons/p5.sound.js
+description: |
+ Loop the p5.SoundFile. Accepts optional parameters to set the
+ playback rate, playback volume, loopStart, loopEnd.
+line: 1905
isConstructor: false
itemtype: method
+example:
+ - |2-
+
+
+ let soundFile;
+ let loopStart = 0.5;
+ let loopDuration = 0.2;
+ function preload() {
+ soundFormats('ogg', 'mp3');
+ soundFile = loadSound('/assets/Damscray_-_Dancing_Tiger_02.mp3');
+ }
+ function setup() {
+ let cnv = createCanvas(100, 100);
+ cnv.mousePressed(canvasPressed);
+ background(220);
+ text('tap to play, release to pause', 10, 20, width - 20);
+ }
+ function canvasPressed() {
+ soundFile.loop();
+ background(0, 200, 50);
+ }
+ function mouseReleased() {
+ soundFile.pause();
+ background(220);
+ }
+
+
class: p5.SoundFile
params:
- - name: loopState
- description: Set to True or False in order to set the loop state.
- type: Boolean
+ - name: startTime
+ description: |
+ (optional) schedule event to occur
+ seconds from now
+ type: Number
+ optional: true
+ - name: rate
+ description: |
+ (optional) playback rate
+ type: Number
+ optional: true
+ - name: amp
+ description: |
+ (optional) playback volume
+ type: Number
+ optional: true
+ - name: cueLoopStart
+ description: |
+ (optional) startTime in seconds
+ type: Number
+ optional: true
+ - name: duration
+ description: |
+ (optional) loop duration in seconds
+ type: Number
+ optional: true
chainable: false
---
diff --git a/src/content/reference/en/p5.SoundFile/onended.mdx b/src/content/reference/en/p5.SoundFile/onended.mdx
index 9ea2272e1c..a2a7a23fa9 100644
--- a/src/content/reference/en/p5.SoundFile/onended.mdx
+++ b/src/content/reference/en/p5.SoundFile/onended.mdx
@@ -1,51 +1,23 @@
---
title: onended
module: p5.sound
-submodule: SoundFile
-file: src/SoundFile.js
-description: Define a function to call when the soundfile is done playing.
-line: 351
+submodule: p5.sound
+file: lib/addons/p5.sound.js
+description: |
+ Schedule an event to be called when the soundfile
+ reaches the end of a buffer. If the soundfile is
+ playing through once, this will be called when it
+ ends. If it is looping, it will be called when
+ stop is called.
+line: 2497
isConstructor: false
itemtype: method
-example:
- - |-
-
-
-
- let player;
-
- function preload() {
- player = loadSound('//assets/lucky_dragons_-_power_melody.mp3');
- }
-
- function setup() {
- let cnv = createCanvas(100, 100);
- background(220);
- textAlign(CENTER);
- textSize(10);
- text('click to play', width/2, height/2);
- cnv.mousePressed(playSound);
- player.onended(coolFunction);
- }
-
- function coolFunction() {
- background(220);
- text('sound is done', width/2, height/2);
- }
-
- function playSound() {
- background(0, 255, 255);
- text('sound is playing', width/2, height/2);
- if (!player.isPlaying()) {
- player.play();
- }
- }
-
-
class: p5.SoundFile
params:
- name: callback
- description: Name of a function that will be called when the soundfile is done playing.
+ description: |
+ function to call when the
+ soundfile has ended.
type: Function
chainable: false
---
diff --git a/src/content/reference/en/p5.SoundFile/pause.mdx b/src/content/reference/en/p5.SoundFile/pause.mdx
index a161720b51..ab9fa5f577 100644
--- a/src/content/reference/en/p5.SoundFile/pause.mdx
+++ b/src/content/reference/en/p5.SoundFile/pause.mdx
@@ -1,52 +1,51 @@
---
title: pause
module: p5.sound
-submodule: SoundFile
-file: src/SoundFile.js
-description: Pause the soundfile.
-line: 147
+submodule: p5.sound
+file: lib/addons/p5.sound.js
+description: |
+ Pauses a file that is currently playing. If the file is not
+ playing, then nothing will happen.
+ After pausing, .play() will resume from the paused
+ position.
+ If p5.SoundFile had been set to loop before it was paused,
+ it will continue to loop after it is unpaused with .play().
+line: 1847
isConstructor: false
itemtype: method
example:
- |-
-
-
- let player;
-
+
+ let soundFile;
function preload() {
- player = loadSound('//assets/Damscray_DancingTiger.mp3');
+ soundFormats('ogg', 'mp3');
+ soundFile = loadSound('/assets/Damscray_-_Dancing_Tiger_02.mp3');
}
-
function setup() {
- describe('A sketch that pauses and resumes sound file playback.');
let cnv = createCanvas(100, 100);
- cnv.mousePressed(playSound);
- background(220);
- textAlign(CENTER);
- textWrap(WORD);
- textSize(10);
+ cnv.mousePressed(canvasPressed);
background(220);
- text('click to play', 0, 20, 100);
-
- player.loop();
+ text('tap to play, release to pause', 10, 20, width - 20);
}
-
- function playSound() {
- if (!player.isPlaying()) {
- player.play();
- background(220);
- text('click to pause', 0, 20, 100);
- }
- else {
- player.pause();
- background(220);
- text('click to play', 0, 20, 100);
- }
+ function canvasPressed() {
+ soundFile.loop();
+ background(0, 200, 50);
+ }
+ function mouseReleased() {
+ soundFile.pause();
+ background(220);
}
class: p5.SoundFile
+params:
+ - name: startTime
+ description: |
+ (optional) schedule event to occur
+ seconds from now
+ type: Number
+ optional: true
chainable: false
---
diff --git a/src/content/reference/en/p5.SoundFile/play.mdx b/src/content/reference/en/p5.SoundFile/play.mdx
index 0783cc9dda..15ba14875f 100644
--- a/src/content/reference/en/p5.SoundFile/play.mdx
+++ b/src/content/reference/en/p5.SoundFile/play.mdx
@@ -1,13 +1,41 @@
---
title: play
module: p5.sound
-submodule: SoundFile
-file: src/SoundFile.js
-description: Start the soundfile.
-line: 124
+submodule: p5.sound
+file: lib/addons/p5.sound.js
+description: |
+ Play the p5.SoundFile
+line: 1679
isConstructor: false
itemtype: method
class: p5.SoundFile
+params:
+ - name: startTime
+ description: |
+ (optional) schedule playback to start (in seconds from now).
+ type: Number
+ optional: true
+ - name: rate
+ description: |
+ (optional) playback rate
+ type: Number
+ optional: true
+ - name: amp
+ description: |
+ (optional) amplitude (volume)
+ of playback
+ type: Number
+ optional: true
+ - name: cueStart
+ description: |
+ (optional) cue start time in seconds
+ type: Number
+ optional: true
+ - name: duration
+ description: |
+ (optional) duration of playback in seconds
+ type: Number
+ optional: true
chainable: false
---
diff --git a/src/content/reference/en/p5.SoundFile/rate.mdx b/src/content/reference/en/p5.SoundFile/rate.mdx
index b4c62712a9..86c5553a44 100644
--- a/src/content/reference/en/p5.SoundFile/rate.mdx
+++ b/src/content/reference/en/p5.SoundFile/rate.mdx
@@ -1,19 +1,58 @@
---
title: rate
module: p5.sound
-submodule: SoundFile
-file: src/SoundFile.js
-description: Set the playback rate of the soundfile.
-line: 286
+submodule: p5.sound
+file: lib/addons/p5.sound.js
+description: |
+ Set the playback rate of a sound file. Will change the speed and the pitch.
+ Values less than zero will reverse the audio buffer.
+line: 2146
isConstructor: false
itemtype: method
+example:
+ - |-
+
+
+ let mySound;
+
+ function preload() {
+ mySound = loadSound('/assets/Damscray_DancingTiger.mp3');
+ }
+
+ function setup() {
+ let cnv = createCanvas(100, 100);
+ cnv.mousePressed(canvasPressed);
+ }
+ function canvasPressed() {
+ mySound.loop();
+ }
+ function mouseReleased() {
+ mySound.pause();
+ }
+ function draw() {
+ background(220);
+
+ // Set the rate to a range between 0.1 and 4
+ // Changing the rate also alters the pitch
+ let playbackRate = map(mouseY, 0.1, height, 2, 0);
+ playbackRate = constrain(playbackRate, 0.01, 4);
+ mySound.rate(playbackRate);
+
+ line(0, mouseY, width, mouseY);
+ text('rate: ' + round(playbackRate * 100) + '%', 10, 20);
+ }
+
+
+
class: p5.SoundFile
params:
- - name: rate
- description: >-
- 1 is normal speed, 2 is double speed. Negative values plays the soundfile
- backwards.
+ - name: playbackRate
+ description: |
+ Set the playback rate. 1.0 is normal,
+ .5 is half-speed, 2.0 is twice as fast.
+ Values less than zero play backwards.
type: Number
+ optional: true
chainable: false
---
diff --git a/src/content/reference/en/p5.SoundFile/sampleRate.mdx b/src/content/reference/en/p5.SoundFile/sampleRate.mdx
index d54bd3d957..07dab7c3af 100644
--- a/src/content/reference/en/p5.SoundFile/sampleRate.mdx
+++ b/src/content/reference/en/p5.SoundFile/sampleRate.mdx
@@ -1,15 +1,17 @@
---
title: sampleRate
module: p5.sound
-submodule: SoundFile
-file: src/SoundFile.js
-description: Gets the number of channels in the sound file.
-line: 428
+submodule: p5.sound
+file: lib/addons/p5.sound.js
+description: |
+ Return the sample rate of the sound file.
+line: 2354
isConstructor: false
itemtype: method
class: p5.SoundFile
return:
- description: Returns the sample rate of the sound file.
+ description: '[sampleRate]'
+ type: Number
chainable: false
---
diff --git a/src/content/reference/en/p5.SoundFile/setLoop.mdx b/src/content/reference/en/p5.SoundFile/setLoop.mdx
index fd68311339..af55e6a639 100644
--- a/src/content/reference/en/p5.SoundFile/setLoop.mdx
+++ b/src/content/reference/en/p5.SoundFile/setLoop.mdx
@@ -1,32 +1,21 @@
---
title: setLoop
module: p5.sound
-submodule: SoundFile
-file: src/SoundFile.js
-description: >-
- Set a loop region, and optionally a playback rate, and amplitude for the
- soundfile.
-line: 206
+submodule: p5.sound
+file: lib/addons/p5.sound.js
+description: |
+ Set a p5.SoundFile's looping flag to true or false. If the sound
+ is currently playing, this change will take effect when it
+ reaches the end of the current playback.
+line: 1950
isConstructor: false
itemtype: method
class: p5.SoundFile
params:
- - name: startTime
- description: Set to True or False in order to set the loop state.
- type: Number
- optional: true
- - name: rate
- description: Set to True or False in order to set the loop state.
- type: Number
- optional: true
- - name: amp
- description: Set to True or False in order to set the loop state.
- type: Number
- optional: true
- - name: duration
- description: Set to True or False in order to set the loop state.
- type: Number
- optional: true
+ - name: Boolean
+ description: |
+ set looping to true or false
+ type: Boolean
chainable: false
---
diff --git a/src/content/reference/en/p5.SoundFile/setPath.mdx b/src/content/reference/en/p5.SoundFile/setPath.mdx
index 6530e839ef..77449f49bb 100644
--- a/src/content/reference/en/p5.SoundFile/setPath.mdx
+++ b/src/content/reference/en/p5.SoundFile/setPath.mdx
@@ -1,58 +1,24 @@
---
title: setPath
module: p5.sound
-submodule: SoundFile
-file: src/SoundFile.js
-description: Change the path for the soundfile.
-line: 231
+submodule: p5.sound
+file: lib/addons/p5.sound.js
+description: |
+ Reset the source for this SoundFile to a
+ new path (URL).
+line: 2612
isConstructor: false
itemtype: method
-example:
- - |-
-
-
-
- let soundSource, cnv, btn;
-
- function preload() {
- soundSource = loadSound('//assets/Damscray_-_Dancing_Tiger_01.mp3');
- }
-
- function setup() {
- describe(
- 'a sketch that says click to play sound. there is a button that says load sound. when you click the button, the path of the sound file player changes and the new sound plays.');
- cnv = createCanvas(100, 100);
- cnv.mousePressed(playSound);
- background(220);
- textAlign(CENTER);
- textWrap(WORD);
- textSize(10);
- text('click to play sound or the button to load a new sound', 0, 20, 100);
- btn = createButton('New Sound');
- btn.mousePressed(setNewPath);
- soundSource.loop();
- }
-
- function playSound() {
- soundSource.play();
- }
-
- function setNewPath() {
- background(220);
- text('a new sound was loaded', 0, 20, 100);
- soundSource.setPath('//assets/Damscray_-_Dancing_Tiger_02.mp3', playSound);
- }
-
-
class: p5.SoundFile
params:
- name: path
- description: Path to the sound file.
+ description: |
+ path to audio file
type: String
- - name: successCallback
- description: Function to call when the sound file is loaded.
+ - name: callback
+ description: |
+ Callback
type: Function
- optional: true
chainable: false
---
diff --git a/src/content/reference/en/p5.SoundFile/start.mdx b/src/content/reference/en/p5.SoundFile/start.mdx
deleted file mode 100644
index 5c2c1528e7..0000000000
--- a/src/content/reference/en/p5.SoundFile/start.mdx
+++ /dev/null
@@ -1,15 +0,0 @@
----
-title: start
-module: p5.sound
-submodule: SoundFile
-file: src/SoundFile.js
-description: Start the soundfile.
-line: 111
-isConstructor: false
-itemtype: method
-class: p5.SoundFile
-chainable: false
----
-
-
-# start
diff --git a/src/content/reference/en/p5.SoundFile/stop.mdx b/src/content/reference/en/p5.SoundFile/stop.mdx
index 82d9c3b8c3..e7cd522978 100644
--- a/src/content/reference/en/p5.SoundFile/stop.mdx
+++ b/src/content/reference/en/p5.SoundFile/stop.mdx
@@ -1,13 +1,21 @@
---
title: stop
module: p5.sound
-submodule: SoundFile
-file: src/SoundFile.js
-description: Stop the soundfile.
-line: 137
+submodule: p5.sound
+file: lib/addons/p5.sound.js
+description: |
+ Stop soundfile playback.
+line: 2025
isConstructor: false
itemtype: method
class: p5.SoundFile
+params:
+ - name: startTime
+ description: |
+ (optional) schedule event to occur
+ in seconds from now
+ type: Number
+ optional: true
chainable: false
---
diff --git a/src/content/reference/en/p5.Table/addColumn.mdx b/src/content/reference/en/p5.Table/addColumn.mdx
index 92ad724737..b296ccb6af 100644
--- a/src/content/reference/en/p5.Table/addColumn.mdx
+++ b/src/content/reference/en/p5.Table/addColumn.mdx
@@ -4,7 +4,7 @@ module: IO
submodule: Table
file: src/io/p5.Table.js
description: >
- Use addColumn() to add a new column
+
Use addColumn() to add a new column
to a Table object.
Typically, you will want to specify a title, so the column
diff --git a/src/content/reference/en/p5.Table/addRow.mdx b/src/content/reference/en/p5.Table/addRow.mdx
index 4690e2e74b..b04b28dd5a 100644
--- a/src/content/reference/en/p5.Table/addRow.mdx
+++ b/src/content/reference/en/p5.Table/addRow.mdx
@@ -4,7 +4,7 @@ module: IO
submodule: Table
file: src/io/p5.Table.js
description: >
-
Use addRow() to add a new row of data
+
Use addRow() to add a new row of data
to a p5.Table object. By default,
an empty row is created. Typically, you would store a reference to
diff --git a/src/content/reference/en/p5.Table/removeColumn.mdx b/src/content/reference/en/p5.Table/removeColumn.mdx
index 0b6e2bd163..591a6f546a 100644
--- a/src/content/reference/en/p5.Table/removeColumn.mdx
+++ b/src/content/reference/en/p5.Table/removeColumn.mdx
@@ -4,7 +4,7 @@ module: IO
submodule: Table
file: src/io/p5.Table.js
description: >
-
Use removeColumn() to remove an
+
Use removeColumn() to remove an
existing column from a Table
object. The column to be removed may be identified by either
diff --git a/src/content/reference/en/p5.Table/rows.mdx b/src/content/reference/en/p5.Table/rows.mdx
index 018a45fcf1..127ed88cfa 100644
--- a/src/content/reference/en/p5.Table/rows.mdx
+++ b/src/content/reference/en/p5.Table/rows.mdx
@@ -8,7 +8,7 @@ description: >
objects that make up the
rows of the table. The same result as calling getRows()
+ href="/reference/p5/getRows/">getRows()
line: 80
isConstructor: false
itemtype: property
diff --git a/src/content/reference/en/p5.sound/getAudioContext.mdx b/src/content/reference/en/p5.sound/getAudioContext.mdx
deleted file mode 100644
index fb7ab3cf3c..0000000000
--- a/src/content/reference/en/p5.sound/getAudioContext.mdx
+++ /dev/null
@@ -1,18 +0,0 @@
----
-title: getAudioContext
-module: Sound
-submodule: Sound Utilities
-file: src/Utils.js
-description: Get the window's audio context.
-line: 14
-isConstructor: false
-itemtype: method
-class: p5.sound
-return:
- description: the audio context
- type: AudioContext
-chainable: false
----
-
-
-# getAudioContext
diff --git a/src/content/reference/en/p5.sound/loadSound.mdx b/src/content/reference/en/p5.sound/loadSound.mdx
deleted file mode 100644
index a8cb982c55..0000000000
--- a/src/content/reference/en/p5.sound/loadSound.mdx
+++ /dev/null
@@ -1,56 +0,0 @@
----
-title: loadSound
-module: p5.sound
-submodule: SoundFile
-file: src/SoundFile.js
-description: |-
- loadSound() returns a new SoundFile from a specified
- path. If called during preload(), the SoundFile will be ready
- to play in time for setup() and draw(). If called outside of
- preload, the SoundFile will not be ready immediately, so
- loadSound accepts a callback as the second parameter. Using a
-
- local server is recommended when loading external files.
-line: 12
-isConstructor: false
-itemtype: method
-example:
- - |-
-
-
- let mySound;
- function preload() {
- mySound = loadSound('//assets/doorbell.mp3');
- }
-
- function setup() {
- let cnv = createCanvas(100, 100);
- cnv.mousePressed(canvasPressed);
- background(220);
- text('tap here to play', 10, 20);
- }
-
- function canvasPressed() {
- // playing a sound file on a user gesture
- // is equivalent to `userStartAudio()`
- mySound.play();
- }
-
-class: p5.sound
-params:
- - name: path
- description: |-
- Path to the sound file, or an array with
- paths to soundfiles in multiple formats
- i.e. ['sound.ogg', 'sound.mp3'].
- Alternately, accepts an object: either
- from the HTML5 File API, or a p5.File.
- type: String|Array
-return:
- description: Returns a SoundFile
- type: SoundFile
-chainable: false
----
-
-
-# loadSound
diff --git a/src/content/reference/en/p5.sound/p5.Amplitude.mdx b/src/content/reference/en/p5.sound/p5.Amplitude.mdx
index 6af2d0a0bf..1aa8a0d443 100644
--- a/src/content/reference/en/p5.sound/p5.Amplitude.mdx
+++ b/src/content/reference/en/p5.sound/p5.Amplitude.mdx
@@ -2,57 +2,33 @@
title: p5.Amplitude
module: p5.sound
submodule: p5.sound
-file: src/Amplitude.js
-description: Get the current volume of a sound.
-line: 10
+file: lib/addons/p5.sound.js
+description: |
+ Amplitude measures volume between 0.0 and 1.0.
+ Listens to all p5sound by default, or use setInput()
+ to listen to a specific sound source. Accepts an optional
+ smoothing value, which defaults to 0.
+line: 3022
isConstructor: true
params:
- name: smoothing
- description: >-
- Smooth the amplitude analysis by averaging with the last analysis frame.
- 0.0 is no time averaging with the last analysis frame.
+ description: |
+ between 0.0 and .999 to smooth
+ amplitude readings (defaults to 0)
type: Number
optional: true
example:
- - |-
-
-
-
- let sound, amp, cnv;
-
- function preload() {
- //replace this sound with something local with rights to distribute
- sound = loadSound('//assets/Damscray_DancingTiger.mp3');
- }
-
- function setup() {
- cnv = createCanvas(100, 100);
- cnv.mousePressed(playSound);
- textAlign(CENTER);
- fill(255);
- amp = new p5.Amplitude();
- sound.connect(amp);
- }
-
- function playSound() {
- sound.play();
- }
-
- function draw() {
- let level = amp.getLevel();
- level = map(level, 0, 0.2, 0, 255);
- background(level, 0, 0);
- text('tap to play', width/2, 20);
- describe('The color of the background changes based on the amplitude of the sound.');
- }
-
-
+ - "\n\nlet sound, amplitude;\n\nfunction preload(){\n sound = loadSound('/assets/beat.mp3');\n}\nfunction setup() {\n let cnv = createCanvas(100,100);\n cnv.mouseClicked(togglePlay);\n amplitude = new p5.Amplitude();\n}\n\nfunction draw() {\n background(220);\n text('tap to play', 20, 20);\n\n let level = amplitude.getLevel();\n let size = map(level, 0, 1, 0, 200);\n ellipse(width/2, height/2, size, size);\n}\n\nfunction togglePlay() {\n if (sound.isPlaying() ){\n sound.pause();\n } else {\n sound.loop();\n\t\tamplitude = new p5.Amplitude();\n\t\tamplitude.setInput(sound);\n }\n}\n\n
"
methods:
setInput:
- description: Connect an audio source to the amplitude object.
+ description: |
+ Connects to the p5sound instance (main output) by default.
+ Optionally, you can pass in a specific source (i.e. a soundfile).
path: p5.Amplitude/setInput
getLevel:
- description: Get the current amplitude value of a sound.
+ description: |
+ Returns a single Amplitude reading at the moment it is called.
+ For continuous readings, run in the draw loop.
path: p5.Amplitude/getLevel
toggleNormalize:
description: |
@@ -66,7 +42,9 @@ methods:
(true or false). Normalizing is off by default.
path: p5.Amplitude/toggleNormalize
smooth:
- description: Get the current amplitude value of a sound.
+ description: |
+ Smooth Amplitude analysis by averaging with the last analysis
+ frame. Off by default.
path: p5.Amplitude/smooth
chainable: false
---
diff --git a/src/content/reference/en/p5.sound/p5.AudioIn.mdx b/src/content/reference/en/p5.sound/p5.AudioIn.mdx
index a77576f408..2b3f2a87b2 100644
--- a/src/content/reference/en/p5.sound/p5.AudioIn.mdx
+++ b/src/content/reference/en/p5.sound/p5.AudioIn.mdx
@@ -2,54 +2,83 @@
title: p5.AudioIn
module: p5.sound
submodule: p5.sound
-file: src/AudioIn.js
-description: 'Get sound from an input source, typically a computer microphone.'
-line: 11
+file: lib/addons/p5.sound.js
+description: >-
+ Get audio from an input, i.e. your computer's microphone.
+
+
+ Turn the mic on/off with the start() and stop() methods. When the mic
+
+ is on, its volume can be measured with getLevel or by connecting an
+
+ FFT object.
+
+
+ If you want to hear the AudioIn, use the .connect() method.
+
+ AudioIn does not connect to p5.sound output by default to prevent
+
+ feedback.
+
+
+ Note: This uses the getUserMedia/
+
+ Stream API, which is not supported by certain browsers. Access in Chrome
+ browser
+
+ is limited to localhost and https, but access over http may be
+ limited.
+line: 6015
isConstructor: true
+params:
+ - name: errorCallback
+ description: |
+ A function to call if there is an error
+ accessing the AudioIn. For example,
+ Safari and iOS devices do not
+ currently allow microphone access.
+ type: Function
+ optional: true
example:
- |-
-
-
- let mic, delay, filter;
+
+ let mic;
- function setup() {
+ function setup(){
let cnv = createCanvas(100, 100);
- cnv.mousePressed(startMic);
- background(220);
-
- mic = new p5.AudioIn();
- delay = new p5.Delay(0.74, 0.1);
- filter = new p5.Biquad(600, "bandpass");
-
- mic.disconnect();
- mic.connect(delay);
- delay.disconnect();
- delay.connect(filter);
-
+ cnv.mousePressed(userStartAudio);
textAlign(CENTER);
- textWrap(WORD);
- textSize(10);
- text('click to open mic, watch out for feedback', 0, 20, 100);
- describe('a sketch that accesses the user\'s microphone and connects it to a delay line.')
- }
-
- function startMic() {
+ mic = new p5.AudioIn();
mic.start();
}
- function draw() {
- d = map(mouseX, 0, width, 0.0, 0.5);
- delay.delayTime(d);
+ function draw(){
+ background(0);
+ fill(255);
+ text('tap to start', width/2, 20);
+
+ micLevel = mic.getLevel();
+ let y = height - micLevel * height;
+ ellipse(width/2, y, 10, 10);
}
-
-
+
methods:
start:
- description: Start the audio input.
+ description: |
+ Start processing audio input. This enables the use of other
+ AudioIn methods like getLevel(). Note that by default, AudioIn
+ is not connected to p5.sound's output. So you won't hear
+ anything unless you use the connect() method.
+ Certain browsers limit access to the user's microphone. For example,
+ Chrome only allows access from localhost and over https. For this reason,
+ you may want to include an errorCallback—a function that is called in case
+ the browser won't provide mic access.
path: p5.AudioIn/start
stop:
- description: Stop the audio input.
+ description: |
+ Turn the AudioIn off. If the AudioIn is stopped, it cannot getLevel().
+ If re-starting, the user may be prompted for permission access.
path: p5.AudioIn/stop
connect:
description: |
@@ -71,7 +100,8 @@ methods:
.start() before using .getLevel().
path: p5.AudioIn/getLevel
amp:
- description: Set amplitude (volume) of a mic input between 0 and 1.0.
+ description: |
+ Set amplitude (volume) of a mic input between 0 and 1.0.
path: p5.AudioIn/amp
getSources:
description: |
diff --git a/src/content/reference/en/p5.sound/p5.BandPass.mdx b/src/content/reference/en/p5.sound/p5.BandPass.mdx
index 718f5e3c72..a58992dbc8 100644
--- a/src/content/reference/en/p5.sound/p5.BandPass.mdx
+++ b/src/content/reference/en/p5.sound/p5.BandPass.mdx
@@ -2,15 +2,14 @@
title: p5.BandPass
module: p5.sound
submodule: p5.sound
-file: src/Biquad.js
-description: Creates a Bandpass Biquad filter.
-line: 164
+file: lib/addons/p5.sound.js
+description: |
+ Constructor: new p5.BandPass()
Filter.
+ This is the same as creating a p5.Filter and then calling
+ its method setType('bandpass')
.
+ See p5.Filter for methods.
+line: 6962
isConstructor: true
-params:
- - name: freq
- description: Set the cutoff frequency of the filter
- type: Number
- optional: true
chainable: false
---
diff --git a/src/content/reference/en/p5.sound/p5.Biquad.mdx b/src/content/reference/en/p5.sound/p5.Biquad.mdx
deleted file mode 100644
index 245e37064c..0000000000
--- a/src/content/reference/en/p5.sound/p5.Biquad.mdx
+++ /dev/null
@@ -1,92 +0,0 @@
----
-title: p5.Biquad
-module: p5.sound
-submodule: p5.sound
-file: src/Biquad.js
-description: Filter the frequency range of a sound.
-line: 11
-isConstructor: true
-params:
- - name: cutoff
- description: 'cutoff frequency of the filter, a value between 0 and 24000.'
- type: Number
- optional: true
- - name: type
- description: |-
- filter type. Options: "lowpass",
- "highpass", "bandpass", "lowshelf",
- "highshelf", "notch", "allpass",
- "peaking"
- type: String
- optional: true
-example:
- - |-
-
-
-
- ///kind of Karplus-Strong string synthesis using p5.sound.js
-
- let noise, lowPass, hiPass, delay, env, gain;
-
- function setup() {
- let cnv = createCanvas(100, 100);
- background(220);
- textAlign(CENTER);
- textSize(9);
- text('click and drag mouse', width/2, height/2);
-
- noise = new p5.Noise('white');
- env = new p5.Envelope(0);
- lowPass = new p5.Biquad(1200, 'lowpass');
- hiPass = new p5.Biquad(55, 'highpass');
- delay = new p5.Delay(0.0005, 0.97);
- gain = new p5.Gain(0.5);
- noise.disconnect();
- noise.connect(hiPass);
- hiPass.disconnect();
- hiPass.connect(env);
- env.disconnect();
- env.connect(lowPass);
- lowPass.disconnect();
- lowPass.connect(delay);
-
- cnv.mousePressed(pluckStart);
- cnv.mouseReleased(pluckStop);
- cnv.mouseOut(pluckStop);
- describe('A sketch that synthesizes string sounds.');
- }
-
- function pluckStart() {
- background(0, 255, 255);
- text('release to trigger decay', width/2, height/2);
- let dtime = map(mouseX, 0, width, 0.009, 0.001);
- delay.delayTime(dtime, 0);
- noise.start();
- env.triggerAttack();
- }
-
- function pluckStop() {
- background(220);
- text('click to pluck', width/2, height/2);
- env.triggerRelease();
- }
-
-
-methods:
- res:
- description: The filter's resonance factor.
- path: p5.Biquad/res
- gain:
- description: The gain of the filter in dB units.
- path: p5.Biquad/gain
- setType:
- description: Set the type of the filter.
- path: p5.Biquad/setType
- freq:
- description: Set the cutoff frequency of the filter.
- path: p5.Biquad/freq
-chainable: false
----
-
-
-# p5.Biquad
diff --git a/src/content/reference/en/p5.sound/p5.Delay.mdx b/src/content/reference/en/p5.sound/p5.Delay.mdx
index 7708eb5ea4..d100387609 100644
--- a/src/content/reference/en/p5.sound/p5.Delay.mdx
+++ b/src/content/reference/en/p5.sound/p5.Delay.mdx
@@ -2,24 +2,40 @@
title: p5.Delay
module: p5.sound
submodule: p5.sound
-file: src/Delay.js
-description: 'A delay effect with parameters for feedback, and delay time.'
-line: 12
+file: lib/addons/p5.sound.js
+description: >
+ Delay is an echo effect. It processes an existing sound source,
+
+ and outputs a delayed version of that sound. The p5.Delay can
+
+ produce different effects depending on the delayTime, feedback,
+
+ filter, and type. In the example below, a feedback of 0.5 (the
+
+ default value) will produce a looping delay that decreases in
+
+ volume by 50% each repeat. A filter will cut out the high
+
+ frequencies so that the delay does not sound as piercing as the
+
+ original source.
+
+ This class extends p5.Effect.
+
+ Methods amp(), chain(),
+
+ drywet(), connect(), and
+
+ disconnect() are
+ available.
+line: 7926
isConstructor: true
-params:
- - name: delayTime
- description: The delay time in seconds between 0 and 1. Defaults to 0.250.
- type: Number
- optional: true
- - name: feedback
- description: The amount of feedback in the delay line between 0 and 1. Defaults to 0.2.
- type: Number
- optional: true
example:
- |-
-
-
+
let osc;
function setup() {
@@ -30,33 +46,46 @@ example:
osc = new p5.Oscillator('square');
osc.amp(0.5);
- delay = new p5.Delay(0.12, 0.7);
-
- osc.disconnect();
- osc.connect(delay);
+ delay = new p5.Delay();
+
+ // delay.process() accepts 4 parameters:
+ // source, delayTime (in seconds), feedback, filter frequency
+ delay.process(osc, 0.12, .7, 2300);
cnv.mousePressed(oscStart);
- describe('Tap to play a square wave with delay effect.');
}
function oscStart() {
osc.start();
}
-
-
function mouseReleased() {
osc.stop();
}
+
methods:
process:
- description: Process an input signal with a delay effect.
+ description: |
+ Add delay to an audio signal according to a set
+ of delay parameters.
path: p5.Delay/process
delayTime:
- description: Set the delay time in seconds.
+ description: |
+ Set the delay (echo) time, in seconds. Usually this value will be
+ a floating point number between 0.0 and 1.0.
path: p5.Delay/delayTime
feedback:
- description: The amount of feedback in the delay line.
+ description: >
+ Feedback occurs when Delay sends its signal back through its input
+
+ in a loop. The feedback amount determines how much signal to send each
+
+ time through the loop. A feedback greater than 1.0 is not desirable
+ because
+
+ it will increase the overall output each time through the loop,
+
+ creating an infinite feedback loop. The default value is 0.5
path: p5.Delay/feedback
filter:
description: |
@@ -70,7 +99,8 @@ methods:
Any other parameter will revert to the default delay setting.
path: p5.Delay/setType
amp:
- description: Adjust the amplitude of the delay effect.
+ description: |
+ Set the output level of the delay effect.
path: p5.Delay/amp
connect:
description: |
diff --git a/src/content/reference/en/p5.sound/p5.Envelope.mdx b/src/content/reference/en/p5.sound/p5.Envelope.mdx
index 0541d7e71c..12146b9ead 100644
--- a/src/content/reference/en/p5.sound/p5.Envelope.mdx
+++ b/src/content/reference/en/p5.sound/p5.Envelope.mdx
@@ -2,49 +2,98 @@
title: p5.Envelope
module: p5.sound
submodule: p5.sound
-file: src/Envelope.js
-description: Generate an amplitude envelope.
-line: 10
+file: lib/addons/p5.sound.js
+description: >-
+ Envelopes are pre-defined amplitude distribution over time.
+
+ Typically, envelopes are used to control the output volume
+
+ of an object, a series of fades referred to as Attack, Decay,
+
+ Sustain and Release (
+
+ ADSR
+
+ ). Envelopes can also control other Web Audio Parameters—for example, a
+ p5.Envelope can
+
+ control an Oscillator's frequency like this: osc.freq(env)
.
+
+ Use setRange
to
+ change the attack/release level.
+
+ Use setADSR
to
+ change attackTime, decayTime, sustainPercent and releaseTime.
+
+ Use the play
method
+ to play the entire envelope,
+
+ the ramp
method for a
+ pingable trigger,
+
+ or triggerAttack
/
+
+ triggerRelease
to
+ trigger noteOn/noteOff.
+line: 4721
isConstructor: true
-params:
- - name: attack
- description: how quickly the envelope reaches the maximum level
- type: Number
- optional: true
- - name: decay
- description: how quickly the envelope reaches the sustain level
- type: Number
- optional: true
- - name: sustain
- description: how long the envelope stays at the decay level
- type: Number
- optional: true
- - name: release
- description: how quickly the envelope fades out after the sustain level
- type: Number
- optional: true
example:
- |-
-
-
- consoe.log('do an example here');
-
-
+
+ let t1 = 0.1; // attack time in seconds
+ let l1 = 0.7; // attack level 0.0 to 1.0
+ let t2 = 0.3; // decay time in seconds
+ let l2 = 0.1; // decay level 0.0 to 1.0
+
+ let env;
+ let triOsc;
+
+ function setup() {
+ let cnv = createCanvas(100, 100);
+ background(220);
+ text('tap to play', 20, 20);
+ cnv.mousePressed(playSound);
+
+ env = new p5.Envelope(t1, l1, t2, l2);
+ triOsc = new p5.Oscillator('triangle');
+ }
+
+ function playSound() {
+ // starting the oscillator ensures that audio is enabled.
+ triOsc.start();
+ env.play(triOsc);
+ }
+
methods:
set:
description: |
Reset the envelope with a series of time/value pairs.
path: p5.Envelope/set
setADSR:
- description: 'Sets the attack, decay, sustain, and release times of the envelope.'
+ description: >
+ Set values like a traditional
+
+
+
+ ADSR envelope
+
+ .
path: p5.Envelope/setADSR
setRange:
description: |
Set max (attackLevel) and min (releaseLevel) of envelope.
path: p5.Envelope/setRange
setInput:
- description: ''
+ description: |
+ Assign a parameter to be controlled by this envelope.
+ If a p5.Sound object is given, then the p5.Envelope will control its
+ output gain. If multiple inputs are provided, the env will
+ control all of them.
path: p5.Envelope/setInput
setExp:
description: |
@@ -53,20 +102,28 @@ methods:
and frequency logarithmically.
path: p5.Envelope/setExp
play:
- description: Trigger the envelope and release it after the sustain time.
+ description: |-
+ Play tells the envelope to start acting on a given input.
+ If the input is a p5.sound object (i.e. AudioIn, Oscillator,
+ SoundFile), then Envelope will control its output volume.
+ Envelopes can also be used to control any
+ Web Audio Audio Param.
path: p5.Envelope/play
triggerAttack:
- description: >-
- Trigger the Attack, and Decay portion of the Envelope. Similar to holding
-
- down a key on a piano, but it will hold the sustain level until you let
- go.
+ description: |
+ Trigger the Attack, and Decay portion of the Envelope.
+ Similar to holding down a key on a piano, but it will
+ hold the sustain level until you let go. Input can be
+ any p5.sound object, or a
+ Web Audio Param.
path: p5.Envelope/triggerAttack
triggerRelease:
- description: |-
- Trigger the Release of the envelope. Similar to releasing the key on
- a piano and letting the sound fade according to the release level and
- release time.
+ description: |
+ Trigger the Release of the Envelope. This is similar to releasing
+ the key on a piano and letting the sound fade according to the
+ release level and release time.
path: p5.Envelope/triggerRelease
ramp:
description: >
@@ -102,12 +159,6 @@ methods:
range, and return the envelope. Calling this method
again will override the initial scale() with new values.
path: p5.Envelope/scale
- releaseTime:
- description: Sets the release time of the envelope.
- path: p5.Envelope/releaseTime
- attackTime:
- description: Sets the attack time of the envelope.
- path: p5.Envelope/attackTime
properties:
attackTime:
description: |
diff --git a/src/content/reference/en/p5.sound/p5.FFT.mdx b/src/content/reference/en/p5.sound/p5.FFT.mdx
index 83024bdefe..900c8d7022 100644
--- a/src/content/reference/en/p5.sound/p5.FFT.mdx
+++ b/src/content/reference/en/p5.sound/p5.FFT.mdx
@@ -2,41 +2,74 @@
title: p5.FFT
module: p5.sound
submodule: p5.sound
-file: src/FFT.js
-description: Analyze the frequency spectrum and waveform of sounds.
-line: 11
+file: lib/addons/p5.sound.js
+description: |-
+ FFT (Fast Fourier Transform) is an analysis algorithm that
+ isolates individual
+
+ audio frequencies within a waveform.
+
+ Once instantiated, a p5.FFT object can return an array based on
+ two types of analyses:
• FFT.waveform()
computes
+ amplitude values along the time domain. The array indices correspond
+ to samples across a brief moment in time. Each value represents
+ amplitude of the waveform at that sample of time.
+ • FFT.analyze()
computes amplitude values along the
+ frequency domain. The array indices correspond to frequencies (i.e.
+ pitches), from the lowest to the highest that humans can hear. Each
+ value represents amplitude at that slice of the frequency spectrum.
+ Use with getEnergy()
to measure amplitude at specific
+ frequencies, or within a range of frequencies.
+
+ FFT analyzes a very short snapshot of sound called a sample
+ buffer. It returns an array of amplitude measurements, referred
+ to as bins
. The array is 1024 bins long by default.
+ You can change the bin array length, but it must be a power of 2
+ between 16 and 1024 in order for the FFT algorithm to function
+ correctly. The actual size of the FFT buffer is twice the
+ number of bins, so given a standard sample rate, the buffer is
+ 2048/44100 seconds long.
+line: 3347
isConstructor: true
params:
- - name: fftSize
- description: >-
- FFT anaylsis size. Must be a power of two between 16 and 1024. Defaults to
- 32.
+ - name: smoothing
+ description: |
+ Smooth results of Freq Spectrum.
+ 0.0 < smoothing < 1.0.
+ Defaults to 0.8.
+ type: Number
+ optional: true
+ - name: bins
+ description: |
+ Length of resulting array.
+ Must be a power of two between
+ 16 and 1024. Defaults to 1024.
type: Number
optional: true
example:
- |-
-
-
- let osc;
+
+ function preload(){
+ sound = loadSound('/assets/Damscray_DancingTiger.mp3');
+ }
function setup(){
let cnv = createCanvas(100,100);
cnv.mouseClicked(togglePlay);
- fft = new p5.FFT(32);
- osc = new p5.TriOsc(440);
- osc.connect(fft);
+ fft = new p5.FFT();
+ sound.amp(0.2);
}
function draw(){
background(220);
+
let spectrum = fft.analyze();
noStroke();
- fill(255, 0, 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);
+ fill(255, 0, 255);
+ for (let i = 0; i< spectrum.length; i++){
+ let x = map(i, 0, spectrum.length, 0, width);
+ let h = -height + map(spectrum[i], 0, 255, height, 0);
rect(x, height, width / spectrum.length, h )
}
@@ -44,25 +77,24 @@ example:
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();
-
- textAlign(CENTER);
- text('tap to play', width/2, 20);
- osc.freq(map(mouseX, 0, width, 100, 2000));
- describe('The sketch displays the frequency spectrum and waveform of the sound that plays.');
+
+ text('tap to play', 20, 20);
}
function togglePlay() {
- osc.start();
+ if (sound.isPlaying()) {
+ sound.pause();
+ } else {
+ sound.loop();
+ }
}
-
-
+
methods:
setInput:
description: |
@@ -70,10 +102,25 @@ methods:
provided, FFT will analyze all sound in the sketch.
path: p5.FFT/setInput
waveform:
- description: Returns an array of sample values from the input audio.
+ description: >
+ Returns an array of amplitude values (between -1.0 and +1.0) that
+ represent
+
+ a snapshot of amplitude readings in a single buffer. Length will be
+
+ equal to bins (defaults to 1024). Can be used to draw the waveform
+
+ of a sound.
path: p5.FFT/waveform
analyze:
- description: Returns the frequency spectrum of the input signal.
+ description: |
+ Returns an array of amplitude values (between 0 and 255)
+ across the frequency spectrum. Length is equal to FFT bins
+ (1024 by default). The array indices correspond to frequencies
+ (i.e. pitches), from the lowest to the highest that humans can
+ hear. Each value represents amplitude at that slice of the
+ frequency spectrum. Must be called prior to using
+ getEnergy()
.
path: p5.FFT/analyze
getEnergy:
description: |
diff --git a/src/content/reference/en/p5.sound/p5.Gain.mdx b/src/content/reference/en/p5.sound/p5.Gain.mdx
index 5c9fda6d5c..f441abc389 100644
--- a/src/content/reference/en/p5.sound/p5.Gain.mdx
+++ b/src/content/reference/en/p5.sound/p5.Gain.mdx
@@ -2,49 +2,74 @@
title: p5.Gain
module: p5.sound
submodule: p5.sound
-file: src/Gain.js
-description: Generate a gain node to use for mixing and main volume.
-line: 10
+file: lib/addons/p5.sound.js
+description: |
+ A gain node is usefull to set the relative volume of sound.
+ It's typically used to build mixers.
+line: 10973
isConstructor: true
example:
- |-
-
-
- let cnv, soundFile, osc, gain;
+
- function preload() {
- soundFile = loadSound('/assets/Damscray_DancingTiger.mp3');
+ // load two soundfile and crossfade beetween them
+ let sound1,sound2;
+ let sound1Gain, sound2Gain, mixGain;
+ function preload(){
+ soundFormats('ogg', 'mp3');
+ sound1 = loadSound('/assets/Damscray_-_Dancing_Tiger_01');
+ sound2 = loadSound('/assets/beat');
}
-
function setup() {
- cnv = createCanvas(100, 100);
- cnv.mousePressed(playSound);
-
- gain = new p5.Gain(0.74);
- osc = new p5.Oscillator();
- osc.amp(0.74);
- osc.disconnect();
- soundFile.loop();
- soundFile.disconnect();
-
- //connect both sound sources to gain node
- soundFile.connect(gain);
- osc.connect(gain);
+ let cnv = createCanvas(100, 100);
+ cnv.mousePressed(startSound);
+ // create a 'mix' gain bus to which we will connect both soundfiles
+ mixGain = new p5.Gain();
+ mixGain.connect();
+ sound1.disconnect(); // diconnect from p5 output
+ sound1Gain = new p5.Gain(); // setup a gain node
+ sound1Gain.setInput(sound1); // connect the first sound to its input
+ sound1Gain.connect(mixGain); // connect its output to the final mix bus
+ sound2.disconnect();
+ sound2Gain = new p5.Gain();
+ sound2Gain.setInput(sound2);
+ sound2Gain.connect(mixGain);
}
-
- function playSound() {
- soundFile.play();
- soundFile.play();
+ function startSound() {
+ sound1.loop();
+ sound2.loop();
+ loop();
}
-
- function draw() {
+ function mouseReleased() {
+ sound1.stop();
+ sound2.stop();
+ }
+ function draw(){
background(220);
- let level = map(mouseX, 0, width, 0, 1);
- gain.amp(level);
+ textAlign(CENTER);
+ textSize(11);
+ fill(0);
+ if (!sound1.isPlaying()) {
+ text('tap and drag to play', width/2, height/2);
+ return;
+ }
+ // map the horizontal position of the mouse to values useable for volume * control of sound1
+ var sound1Volume = constrain(map(mouseX,width,0,0,1), 0, 1);
+ var sound2Volume = 1-sound1Volume;
+ sound1Gain.amp(sound1Volume);
+ sound2Gain.amp(sound2Volume);
+ // map the vertical position of the mouse to values useable for 'output * volume control'
+ var outputVolume = constrain(map(mouseY,height,0,0,1), 0, 1);
+ mixGain.amp(outputVolume);
+ text('output', width/2, height - outputVolume * height * 0.9)
+ fill(255, 0, 255);
+ textAlign(LEFT);
+ text('sound1', 5, height - sound1Volume * height * 0.9);
+ textAlign(RIGHT);
+ text('sound2', width - 5, height - sound2Volume * height * 0.9);
}
-
-
+
methods:
setInput:
description: |
@@ -59,7 +84,8 @@ methods:
Disconnect all output.
path: p5.Gain/disconnect
amp:
- description: Adjust the amplitude of the soundfile.
+ description: |
+ Set the output level of the gain node.
path: p5.Gain/amp
chainable: false
---
diff --git a/src/content/reference/en/p5.sound/p5.HighPass.mdx b/src/content/reference/en/p5.sound/p5.HighPass.mdx
index d35221bbfd..3aa854c235 100644
--- a/src/content/reference/en/p5.sound/p5.HighPass.mdx
+++ b/src/content/reference/en/p5.sound/p5.HighPass.mdx
@@ -2,15 +2,14 @@
title: p5.HighPass
module: p5.sound
submodule: p5.sound
-file: src/Biquad.js
-description: Creates a Highpass Biquad filter.
-line: 150
+file: lib/addons/p5.sound.js
+description: |
+ Constructor: new p5.HighPass()
Filter.
+ This is the same as creating a p5.Filter and then calling
+ its method setType('highpass')
.
+ See p5.Filter for methods.
+line: 6938
isConstructor: true
-params:
- - name: freq
- description: Set the cutoff frequency of the filter
- type: Number
- optional: true
chainable: false
---
diff --git a/src/content/reference/en/p5.sound/p5.LowPass.mdx b/src/content/reference/en/p5.sound/p5.LowPass.mdx
index 99f85c1974..6ec84a3429 100644
--- a/src/content/reference/en/p5.sound/p5.LowPass.mdx
+++ b/src/content/reference/en/p5.sound/p5.LowPass.mdx
@@ -2,15 +2,14 @@
title: p5.LowPass
module: p5.sound
submodule: p5.sound
-file: src/Biquad.js
-description: Creates a Lowpass Biquad filter.
-line: 136
+file: lib/addons/p5.sound.js
+description: |
+ Constructor: new p5.LowPass()
Filter.
+ This is the same as creating a p5.Filter and then calling
+ its method setType('lowpass')
.
+ See p5.Filter for methods.
+line: 6914
isConstructor: true
-params:
- - name: freq
- description: Set the cutoff frequency of the filter
- type: Number
- optional: true
chainable: false
---
diff --git a/src/content/reference/en/p5.sound/p5.Noise.mdx b/src/content/reference/en/p5.sound/p5.Noise.mdx
index 774a1fb181..843ed2ce1e 100644
--- a/src/content/reference/en/p5.sound/p5.Noise.mdx
+++ b/src/content/reference/en/p5.sound/p5.Noise.mdx
@@ -2,67 +2,24 @@
title: p5.Noise
module: p5.sound
submodule: p5.sound
-file: src/Noise.js
-description: Generate a buffer with random values.
-line: 11
+file: lib/addons/p5.sound.js
+description: >
+ Noise is a type of oscillator that generates a buffer with random
+ values.
+line: 5620
isConstructor: true
params:
- name: type
- description: '- the type of noise (white, pink, brown)'
+ description: |
+ Type of noise can be 'white' (default),
+ 'brown' or 'pink'.
type: String
- optional: true
-example:
- - |-
-
-
-
- let noise, env, cnv;
- let types = ['white', 'pink', 'brown'];
- let noiseType = 'brown';
-
- function setup() {
- cnv = createCanvas(100, 100);
- textAlign(CENTER);
- cnv.mousePressed(start);
- noise = new p5.Noise(noiseType);
- env = new p5.Envelope(0.01, 0.1, 0.15, 0.5);
- noise.disconnect();
- noise.connect(env);
- noise.start();
- }
-
- function start() {
- noiseType = random(types);
- noise.type(noiseType);
- env.play();
- }
-
- function draw() {
- background(noiseType);
- text('tap to play', width/2, 20);
- let txt = 'type: ' + noiseType;
- text(txt, width/2, 40);
- }
-
-
methods:
setType:
description: |
Set type of noise to 'white', 'pink' or 'brown'.
White is the default.
path: p5.Noise/setType
- type:
- description: ''
- path: p5.Noise/type
- amp:
- description: Adjust the amplitude of the noise source.
- path: p5.Noise/amp
- start:
- description: Starts the noise source.
- path: p5.Noise/start
- stop:
- description: Stops the noise source.
- path: p5.Noise/stop
chainable: false
---
diff --git a/src/content/reference/en/p5.sound/p5.Oscillator.mdx b/src/content/reference/en/p5.sound/p5.Oscillator.mdx
index 24fafc37f0..d3c47fd23b 100644
--- a/src/content/reference/en/p5.sound/p5.Oscillator.mdx
+++ b/src/content/reference/en/p5.sound/p5.Oscillator.mdx
@@ -2,88 +2,121 @@
title: p5.Oscillator
module: p5.sound
submodule: p5.sound
-file: src/Oscillator.js
-description: 'Generate Sine, Triangle, Square and Sawtooth waveforms.'
-line: 12
+file: lib/addons/p5.sound.js
+description: >-
+ Creates a signal that oscillates between -1.0 and 1.0.
+
+ By default, the oscillation takes the form of a sinusoidal
+
+ shape ('sine'). Additional types include 'triangle',
+
+ 'sawtooth' and 'square'. The frequency defaults to
+
+ 440 oscillations per second (440Hz, equal to the pitch of an
+
+ 'A' note).
+
+
+ Set the type of oscillation with setType(), or by instantiating a
+
+ specific oscillator: p5.SinOsc, p5.TriOsc, p5.SqrOsc, or p5.SawOsc.
+
+
+line: 4060
isConstructor: true
params:
- - name: frequency
- description: frequency defaults to 440Hz
+ - name: freq
+ description: |
+ frequency defaults to 440Hz
type: Number
optional: true
- name: type
- description: |-
- type of oscillator. Options:
+ description: |
+ type of oscillator. Options:
'sine' (default), 'triangle',
- 'sawtooth', 'square'
+ 'sawtooth', 'square'
type: String
optional: true
example:
- |-
-
-
+
let osc, playing, freq, amp;
function setup() {
- describe("a sketch that demonstrates the frequency and amplitude parameters of an oscillator.");
let cnv = createCanvas(100, 100);
cnv.mousePressed(playOscillator);
- osc = new p5.Oscillator();
+ osc = new p5.Oscillator('sine');
}
function draw() {
background(220)
freq = constrain(map(mouseX, 0, width, 100, 500), 100, 500);
- //amp = constrain(map(mouseY, height, 0, 0, 1), 0, 1);
+ amp = constrain(map(mouseY, height, 0, 0, 1), 0, 1);
+
text('tap to play', 20, 20);
text('freq: ' + freq, 20, 40);
- //text('amp: ' + amp, 20, 60);
+ text('amp: ' + amp, 20, 60);
if (playing) {
// smooth the transitions by 0.1 seconds
- osc.freq(freq);
- //osc.amp(amp);
+ osc.freq(freq, 0.1);
+ osc.amp(amp, 0.1);
}
}
function playOscillator() {
// starting an oscillator on a user gesture will enable audio
// in browsers that have a strict autoplay policy.
+ // See also: userStartAudio();
osc.start();
playing = true;
}
function mouseReleased() {
// ramp amplitude to 0 over 0.5 seconds
- //osc.amp(0, 0.5);
+ osc.amp(0, 0.5);
playing = false;
}
-
-
+
methods:
start:
- description: Starts the oscillator. Usually from user gesture.
+ description: |
+ Start an oscillator.
+ Starting an oscillator on a user gesture will enable audio in browsers
+ that have a strict autoplay policy, including Chrome and most mobile
+ devices. See also: userStartAudio()
.
path: p5.Oscillator/start
stop:
- description: Stops the oscillator.
+ description: |
+ Stop an oscillator. Accepts an optional parameter
+ to determine how long (in seconds from now) until the
+ oscillator stops.
path: p5.Oscillator/stop
amp:
- description: Adjust the amplitude of the Oscillator.
+ description: |
+ Set the amplitude between 0 and 1.0. Or, pass in an object
+ such as an oscillator to modulate amplitude with an audio signal.
path: p5.Oscillator/amp
getAmp:
description: |
Returns the value of output gain
path: p5.Oscillator/getAmp
freq:
- description: Adjusts the frequency of the oscillator.
+ description: |
+ Set frequency of an oscillator to a value. Or, pass in an object
+ such as an oscillator to modulate the frequency with an audio signal.
path: p5.Oscillator/freq
getFreq:
description: |
Returns the value of frequency of oscillator
path: p5.Oscillator/getFreq
setType:
- description: Sets the type of the oscillator.
+ description: |
+ Set type to 'sine', 'triangle', 'sawtooth' or 'square'.
path: p5.Oscillator/setType
getType:
description: >
@@ -108,7 +141,10 @@ methods:
(1)
path: p5.Oscillator/getPan
phase:
- description: Adjusts the phase of the oscillator.
+ description: |
+ Set the phase of an oscillator between 0.0 and 1.0.
+ In this implementation, phase is a delay time
+ based on the oscillator's current frequency.
path: p5.Oscillator/phase
add:
description: |
diff --git a/src/content/reference/en/p5.sound/p5.Panner.mdx b/src/content/reference/en/p5.sound/p5.Panner.mdx
deleted file mode 100644
index bb987224f0..0000000000
--- a/src/content/reference/en/p5.sound/p5.Panner.mdx
+++ /dev/null
@@ -1,51 +0,0 @@
----
-title: p5.Panner
-module: p5.sound
-submodule: p5.sound
-file: src/Panner.js
-description: A panning effect.
-line: 11
-isConstructor: true
-example:
- - |-
-
-
-
- let panner, lfo, soundfile, cnv;
-
- function preload() {
- soundfile = loadSound('//assets/beat.mp3');
- }
-
- function setup() {
- cnv = createCanvas(100, 100);
- background(220);
- cnv.mousePressed(startSound);
-
- panner = new p5.Panner();
- lfo = new p5.Oscillator(1);
- //disconnect lfo from speakers because we don't want to hear it!
- lfo.disconnect();
- panner.pan(lfo);
-
- soundfile.loop();
- soundfile.disconnect();
- soundfile.connect(panner);
-
- }
-
- function startSound() {
- lfo.start();
- soundfile.start();
- }
-
-
-methods:
- pan:
- description: Pan a sound source left or right.
- path: p5.Panner/pan
-chainable: false
----
-
-
-# p5.Panner
diff --git a/src/content/reference/en/p5.sound/p5.Panner3D.mdx b/src/content/reference/en/p5.sound/p5.Panner3D.mdx
index 6ecf82da22..a0401efff1 100644
--- a/src/content/reference/en/p5.sound/p5.Panner3D.mdx
+++ b/src/content/reference/en/p5.sound/p5.Panner3D.mdx
@@ -2,116 +2,45 @@
title: p5.Panner3D
module: p5.sound
submodule: p5.sound
-file: src/Panner3D.js
-description: A 3D sound spatializer.
-line: 10
-isConstructor: true
-example:
- - |-
-
-
-
- let radius = 10 ;
- let soundSource, spatializer;
- let font;
- let cnv;
-
- let x = 0;
- let y = 0;
- let z = 100;
-
- let vX;
- let vY;
- let vZ;
+file: lib/addons/p5.sound.js
+description: >
+ Panner3D is based on the
- function preload() {
- soundSource = loadSound('//assets/beat.mp3');
- font = loadFont('//assets/SourceSansPro-Regular.otf');
- }
+ Web Audio Spatial Panner Node.
- function setup() {
- describe(
- 'A 3D shape with a sound source attached to it. The sound source is spatialized using the Panner3D class. Click to play the sound.'
- );
- cnv = createCanvas(100, 100, WEBGL);
- cnv.mousePressed(playSound);
+ This panner is a spatial processing node that allows audio to be positioned
- camera(0, 0, 0, 0, 0, 1);
-
- textFont(font);
- textAlign(CENTER,CENTER);
-
- angleMode(DEGREES);
+ and oriented in 3D space.
- vX = random(-0.5, 0.5);
- vY = random(-0.5, 0.5);
- vZ = random(-0.5, 0.5) * 1.5;
+ The position is relative to an
- spatializer = new p5.Panner3D();
- spatializer.maxDist(100);
- soundSource.loop();
- soundSource.disconnect();
- soundSource.connect(spatializer);
- }
+ Audio Context Listener, which can be accessed
- function playSound() {
- soundSource.play();
- }
-
- function draw() {
- background(220);
- push();
- textSize(5);
- fill(0);
- translate(0,0,100);
- //text('click to play', 0, 0);
- pop();
- // Update Box and Sound Source Position
- push();
- moveSoundBox();
- box(5, 5, 5);
- pop();
- }
-
- // Rotate 1 degree per frame along all three axes
- function moveSoundBox() {
- x = x + vX;
- y = y + vY;
- z = z + vZ;
-
- if (x > radius || x < -radius) {
- vX = -vX;
- }
- if (y > radius || y < -radius) {
- vY = -vY;
- }
- if (z > 250 || z < 80) {
- vZ = -vZ;
- }
- //set the position of the 3D panner
- spatializer.set(x, y, z);
- //set the postion of the box
- translate(x, y, z);
- rotateX(45 + frameCount);
- rotateZ(45);
- }
-
-
+ by p5.soundOut.audiocontext.listener
+line: 7602
+isConstructor: true
methods:
process:
- description: Connects an input source to the 3D panner.
+ description: |
+ Connect an audio sorce
path: p5.Panner3D/process
set:
- description: 'Set the x, y, and z position of the 3D panner.'
+ description: |
+ Set the X,Y,Z position of the Panner
path: p5.Panner3D/set
positionX:
- description: Set the X position of the sound source.
+ description: |
+ Getter and setter methods for position coordinates
path: p5.Panner3D/positionX
positionY:
- description: Set the Y position of the sound source.
+ description: |
+ Getter and setter methods for position coordinates
path: p5.Panner3D/positionY
positionZ:
- description: Set the Z position of the sound source.
+ description: |
+ Getter and setter methods for position coordinates
path: p5.Panner3D/positionZ
orient:
description: |
@@ -130,19 +59,18 @@ methods:
Getter and setter methods for orient coordinates
path: p5.Panner3D/orientZ
setFalloff:
- description: The rolloff rate of the panner.
+ description: |
+ Set the rolloff factor and max distance
path: p5.Panner3D/setFalloff
maxDist:
- description: Set the maximum distance of the panner.
+ description: |
+ Maxium distance between the source and the listener
path: p5.Panner3D/maxDist
rollof:
description: >
How quickly the volume is reduced as the source moves away from the
listener
path: p5.Panner3D/rollof
- rolloff:
- description: Set the rolloff rate of the panner.
- path: p5.Panner3D/rolloff
properties:
panner:
description: >
diff --git a/src/content/reference/en/p5.sound/p5.PitchShifter.mdx b/src/content/reference/en/p5.sound/p5.PitchShifter.mdx
deleted file mode 100644
index 5f49497892..0000000000
--- a/src/content/reference/en/p5.sound/p5.PitchShifter.mdx
+++ /dev/null
@@ -1,54 +0,0 @@
----
-title: p5.PitchShifter
-module: p5.sound
-submodule: p5.sound
-file: src/PitchShifter.js
-description: Change the pitch of a sound.
-line: 10
-isConstructor: true
-example:
- - |-
-
-
-
- let cnv, soundFile, pitchShifter;
-
- function preload() {
- soundFile = loadSound('//assets/beatbox.mp3');
- }
-
- function setup() {
- cnv = createCanvas(100, 100);
- cnv.mousePressed(startSound);
- background(220);
- textAlign(CENTER);
- textSize(9);
- text('click to play sound', width/2, height/2);
- pitchShifter = new p5.PitchShifter();
-
- soundFile.disconnect();
- soundFile.connect(pitchShifter);
- //change the pitch and retrigger sample when done playing
- soundFile.onended(changePitch);
- }
-
- function startSound () {
- soundFile.play();
- }
-
- function changePitch () {
- let pitchValue = random(-12, 12);
- pitchShifter.shift(pitchValue);
- soundFile.play();
- }
-
-
-methods:
- shift:
- description: Shift the pitch of the source audio.
- path: p5.PitchShifter/shift
-chainable: false
----
-
-
-# p5.PitchShifter
diff --git a/src/content/reference/en/p5.sound/p5.Pulse.mdx b/src/content/reference/en/p5.sound/p5.Pulse.mdx
index fd914d455a..8f27d0c899 100644
--- a/src/content/reference/en/p5.sound/p5.Pulse.mdx
+++ b/src/content/reference/en/p5.sound/p5.Pulse.mdx
@@ -9,7 +9,7 @@ description: |
The pulse is created with two oscillators.
Accepts a parameter for frequency, and to set the
width between the pulses. See
+ http://p5js.org/reference/#/p5.Oscillator">
p5.Oscillator
for a full list of methods.
line: 5779
isConstructor: true
diff --git a/src/content/reference/en/p5.sound/p5.Reverb.mdx b/src/content/reference/en/p5.sound/p5.Reverb.mdx
index 14742dfef1..4d0e249011 100644
--- a/src/content/reference/en/p5.sound/p5.Reverb.mdx
+++ b/src/content/reference/en/p5.sound/p5.Reverb.mdx
@@ -2,58 +2,78 @@
title: p5.Reverb
module: p5.sound
submodule: p5.sound
-file: src/Reverb.js
-description: Add reverb to a sound.
-line: 10
+file: lib/addons/p5.sound.js
+description: >
+ Reverb adds depth to a sound through a large number of decaying
+
+ echoes. It creates the perception that sound is occurring in a
+
+ physical space. The p5.Reverb has paramters for Time (how long does the
+
+ reverb last) and decayRate (how much the sound decays with each echo)
+
+ that can be set with the .set() or .process() methods. The p5.Convolver
+
+ extends p5.Reverb allowing you to recreate the sound of actual physical
+
+ spaces through convolution.
+
+ This class extends p5.Effect.
+
+ Methods amp(), chain(),
+
+ drywet(), connect(), and
+
+ disconnect() are
+ available.
+line: 8308
isConstructor: true
-params:
- - name: decayTime
- description: Set the decay time of the reverb
- type: Number
- optional: true
example:
- |-
-
-
- let noise, osc, env, reverb;
- let randomTime = 0;
+
+ let soundFile, reverb;
+ function preload() {
+ soundFile = loadSound('/assets/Damscray_DancingTiger.mp3');
+ }
function setup() {
let cnv = createCanvas(100, 100);
cnv.mousePressed(playSound);
- noise = new p5.Noise();
- env = new p5.Envelope();
+
reverb = new p5.Reverb();
- noise.disconnect();
- noise.connect(env);
- env.disconnect();
- env.connect(reverb);
- noise.start();
- textAlign(CENTER);
- }
+ soundFile.disconnect(); // so we'll only hear reverb...
- function playSound() {
- randomTime = random(0.1, 3);
- reverb.set(randomTime);
- env.play();
+ // connect soundFile to reverb, process w/
+ // 3 second reverbTime, decayRate of 2%
+ reverb.process(soundFile, 3, 2);
}
function draw() {
+ let dryWet = constrain(map(mouseX, 0, width, 0, 1), 0, 1);
+ // 1 = all reverb, 0 = no reverb
+ reverb.drywet(dryWet);
+
background(220);
- text('click to play', width/2, 20);
- text('decay ' + round(randomTime, 2), width/2, 40);
- describe('Click to play a sound with a random decay time.');
+ text('tap to play', 10, 20);
+ text('dry/wet: ' + round(dryWet * 100) + '%', 10, height - 20);
}
-
-
+
+ function playSound() {
+ soundFile.play();
+ }
+
methods:
process:
description: |
Connect a source to the reverb, and assign reverb parameters.
path: p5.Reverb/process
set:
- description: Set the decay time of the reverb.
+ description: |
+ Set the reverb settings. Similar to .process(), but without
+ assigning a new input.
path: p5.Reverb/set
amp:
description: |
@@ -67,9 +87,6 @@ methods:
description: |
Disconnect all output.
path: p5.Reverb/disconnect
- drywet:
- description: Adjust the dry/wet value.
- path: p5.Reverb/drywet
chainable: false
---
diff --git a/src/content/reference/en/p5.sound/p5.SawOsc.mdx b/src/content/reference/en/p5.sound/p5.SawOsc.mdx
index 9609e2986e..0ba76fe10d 100644
--- a/src/content/reference/en/p5.sound/p5.SawOsc.mdx
+++ b/src/content/reference/en/p5.sound/p5.SawOsc.mdx
@@ -2,13 +2,20 @@
title: p5.SawOsc
module: p5.sound
submodule: p5.sound
-file: src/Oscillator.js
-description: Creates a sawtooth oscillator.
-line: 219
+file: lib/addons/p5.sound.js
+description: |
+ Constructor: new p5.SawOsc()
.
+ This creates a SawTooth Wave Oscillator and is
+ equivalent to new p5.Oscillator('sawtooth')
+
or creating a p5.Oscillator and then calling
+ its method setType('sawtooth')
.
+ See p5.Oscillator for methods.
+line: 4656
isConstructor: true
params:
- name: freq
- description: Set the frequency
+ description: |
+ Set the frequency
type: Number
optional: true
chainable: false
diff --git a/src/content/reference/en/p5.sound/p5.SinOsc.mdx b/src/content/reference/en/p5.sound/p5.SinOsc.mdx
index 3e395f679e..b103bf3b89 100644
--- a/src/content/reference/en/p5.sound/p5.SinOsc.mdx
+++ b/src/content/reference/en/p5.sound/p5.SinOsc.mdx
@@ -2,13 +2,20 @@
title: p5.SinOsc
module: p5.sound
submodule: p5.sound
-file: src/Oscillator.js
-description: Creates a sine oscillator.
-line: 261
+file: lib/addons/p5.sound.js
+description: |
+ Constructor: new p5.SinOsc()
.
+ This creates a Sine Wave Oscillator and is
+ equivalent to new p5.Oscillator('sine')
+
or creating a p5.Oscillator and then calling
+ its method setType('sine')
.
+ See p5.Oscillator for methods.
+line: 4602
isConstructor: true
params:
- name: freq
- description: Set the frequency
+ description: |
+ Set the frequency
type: Number
optional: true
chainable: false
diff --git a/src/content/reference/en/p5.sound/p5.SoundFile.mdx b/src/content/reference/en/p5.sound/p5.SoundFile.mdx
index d792d1f2d5..a5bb335e51 100644
--- a/src/content/reference/en/p5.sound/p5.SoundFile.mdx
+++ b/src/content/reference/en/p5.sound/p5.SoundFile.mdx
@@ -1,58 +1,88 @@
---
title: p5.SoundFile
module: p5.sound
-submodule: SoundFile
-file: src/SoundFile.js
-description: Load and play sound files.
-line: 60
+submodule: p5.sound
+file: lib/addons/p5.sound.js
+description: |-
+ SoundFile object with a path to a file.
+
+ The p5.SoundFile may not be available immediately because
+ it loads the file information asynchronously.
+
+ To do something with the sound as soon as it loads
+ pass the name of a function as the second parameter.
+
+ Only one file path is required. However, audio file formats
+ (i.e. mp3, ogg, wav and m4a/aac) are not supported by all
+ web browsers. If you want to ensure compatability, instead of a single
+ file path, you may include an Array of filepaths, and the browser will
+ choose a format that works.
+line: 1405
isConstructor: true
+params:
+ - name: path
+ description: |
+ path to a sound file (String). Optionally,
+ you may include multiple file formats in
+ an array. Alternately, accepts an object
+ from the HTML5 File API, or a p5.File.
+ type: String|Array
+ - name: successCallback
+ description: |
+ Name of a function to call once file loads
+ type: Function
+ optional: true
+ - name: errorCallback
+ description: |
+ Name of a function to call if file fails to
+ load. This function will receive an error or
+ XMLHttpRequest object with information
+ about what went wrong.
+ type: Function
+ optional: true
+ - name: whileLoadingCallback
+ description: |
+ Name of a function to call while file
+ is loading. That function will
+ receive progress of the request to
+ load the sound file
+ (between 0 and 1) as its first
+ parameter. This progress
+ does not account for the additional
+ time needed to decode the audio data.
+ type: Function
+ optional: true
example:
- |-
-
-
- let sound, amp, delay, cnv;
-
+
+ let mySound;
function preload() {
- //replace this sound with something local with rights to distribute
- //need to fix local asset loading first though :)
- sound = loadSound('//assets/doorbell.mp3');
+ soundFormats('mp3', 'ogg');
+ mySound = loadSound('/assets/doorbell');
}
function setup() {
- cnv = createCanvas(100, 100);
- textAlign(CENTER);
- cnv.mousePressed(playSound);
- amp = new p5.Amplitude();
- delay = new p5.Delay();
- sound.disconnect();
- sound.connect(delay);
- delay.connect(amp);
+ let cnv = createCanvas(100, 100);
+ cnv.mousePressed(canvasPressed);
+ background(220);
+ text('tap here to play', 10, 20);
}
- function playSound() {
- sound.play();
+ function canvasPressed() {
+ // playing a sound file on a user gesture
+ // is equivalent to `userStartAudio()`
+ mySound.play();
}
-
- function draw() {
- let dtime = map(mouseX, 0, width, 0, 1);
- delay.delayTime(dtime);
- let f = map(mouseY, 0, height, 0, .75);
- delay.feedback(f);
- let level = map(amp.getLevel(), 0, 0.5, 0, 255);
- background(level, 0, 0);
- fill(255);
- text('click to play', width/2, 20);
- }
-
-
+
methods:
isLoaded:
description: |
Returns true if the sound file finished loading successfully.
path: p5.SoundFile/isLoaded
play:
- description: Start the soundfile.
+ description: |
+ Play the p5.SoundFile
path: p5.SoundFile/play
playMode:
description: |
@@ -65,21 +95,34 @@ methods:
not already playing. Sustain is the default mode.
path: p5.SoundFile/playMode
pause:
- description: Pause the soundfile.
+ description: |
+ Pauses a file that is currently playing. If the file is not
+ playing, then nothing will happen.
+ After pausing, .play() will resume from the paused
+ position.
+ If p5.SoundFile had been set to loop before it was paused,
+ it will continue to loop after it is unpaused with .play().
path: p5.SoundFile/pause
loop:
- description: Loop the soundfile.
+ description: |
+ Loop the p5.SoundFile. Accepts optional parameters to set the
+ playback rate, playback volume, loopStart, loopEnd.
path: p5.SoundFile/loop
setLoop:
- description: >-
- Set a loop region, and optionally a playback rate, and amplitude for the
- soundfile.
+ description: |
+ Set a p5.SoundFile's looping flag to true or false. If the sound
+ is currently playing, this change will take effect when it
+ reaches the end of the current playback.
path: p5.SoundFile/setLoop
isLooping:
- description: Return the playback state of the soundfile.
+ description: >
+ Returns 'true' if a p5.SoundFile is currently looping and playing,
+ 'false' if not.
path: p5.SoundFile/isLooping
isPlaying:
- description: Return the playback state of the soundfile.
+ description: |
+ Returns true if a p5.SoundFile is playing, false if not (i.e.
+ paused or stopped).
path: p5.SoundFile/isPlaying
isPaused:
description: |
@@ -87,7 +130,8 @@ methods:
playing or stopped).
path: p5.SoundFile/isPaused
stop:
- description: Stop the soundfile.
+ description: |
+ Stop soundfile playback.
path: p5.SoundFile/stop
pan:
description: |
@@ -100,7 +144,11 @@ methods:
Returns the current stereo pan position (-1.0 to 1.0)
path: p5.SoundFile/getPan
rate:
- description: Set the playback rate of the soundfile.
+ description: >
+ Set the playback rate of a sound file. Will change the speed and the
+ pitch.
+
+ Values less than zero will reverse the audio buffer.
path: p5.SoundFile/rate
setVolume:
description: |
@@ -114,7 +162,8 @@ methods:
oscillator to modulate the amplitude with an audio signal.
path: p5.SoundFile/setVolume
duration:
- description: Returns the duration of a sound file in seconds.
+ description: |
+ Returns the duration of a sound file in seconds.
path: p5.SoundFile/duration
currentTime:
description: >
@@ -126,18 +175,31 @@ methods:
has been called, currentTime will count backwards.
path: p5.SoundFile/currentTime
jump:
- description: >-
- Move the playhead of a soundfile that is currently playing to a new
- position.
+ description: >
+ Move the playhead of a soundfile that is currently playing to a
+
+ new position and a new duration, in seconds.
+
+ If none are given, will reset the file to play entire duration
+
+ from start to finish. To set the position of a soundfile that is
+
+ not currently playing, use the play
or loop
+ methods.
path: p5.SoundFile/jump
channels:
- description: Gets the number of channels in the sound file.
+ description: |
+ Return the number of channels in a sound file.
+ For example, Mono = 1, Stereo = 2.
path: p5.SoundFile/channels
sampleRate:
- description: Gets the number of channels in the sound file.
+ description: |
+ Return the sample rate of the sound file.
path: p5.SoundFile/sampleRate
frames:
- description: Return the number of samples in a sound file.
+ description: |
+ Return the number of samples in a sound file.
+ Equal to sampleRate * duration.
path: p5.SoundFile/frames
getPeaks:
description: |
@@ -154,7 +216,12 @@ methods:
Playback must be handled separately (see example).
path: p5.SoundFile/reverseBuffer
onended:
- description: Define a function to call when the soundfile is done playing.
+ description: |
+ Schedule an event to be called when the soundfile
+ reaches the end of a buffer. If the soundfile is
+ playing through once, this will be called when it
+ ends. If it is looping, it will be called when
+ stop is called.
path: p5.SoundFile/onended
connect:
description: |
@@ -169,7 +236,9 @@ methods:
Disconnects the output of this p5sound object.
path: p5.SoundFile/disconnect
setPath:
- description: Change the path for the soundfile.
+ description: |
+ Reset the source for this SoundFile to a
+ new path (URL).
path: p5.SoundFile/setPath
setBuffer:
description: |
@@ -223,12 +292,6 @@ methods:
and attach the blob as one of the form values using
FormData
.
path: p5.SoundFile/getBlob
- start:
- description: Start the soundfile.
- path: p5.SoundFile/start
- amp:
- description: Adjust the amplitude of the soundfile.
- path: p5.SoundFile/amp
chainable: false
---
diff --git a/src/content/reference/en/p5.sound/p5.SqrOsc.mdx b/src/content/reference/en/p5.sound/p5.SqrOsc.mdx
index e0a1ff3fc8..11e9769ff1 100644
--- a/src/content/reference/en/p5.sound/p5.SqrOsc.mdx
+++ b/src/content/reference/en/p5.sound/p5.SqrOsc.mdx
@@ -2,13 +2,20 @@
title: p5.SqrOsc
module: p5.sound
submodule: p5.sound
-file: src/Oscillator.js
-description: Creates a square oscillator.
-line: 233
+file: lib/addons/p5.sound.js
+description: |
+ Constructor: new p5.SqrOsc()
.
+ This creates a Square Wave Oscillator and is
+ equivalent to new p5.Oscillator('square')
+
or creating a p5.Oscillator and then calling
+ its method setType('square')
.
+ See p5.Oscillator for methods.
+line: 4683
isConstructor: true
params:
- name: freq
- description: Set the frequency
+ description: |
+ Set the frequency
type: Number
optional: true
chainable: false
diff --git a/src/content/reference/en/p5.sound/p5.TriOsc.mdx b/src/content/reference/en/p5.sound/p5.TriOsc.mdx
index c8a02e50ac..96e24afbc0 100644
--- a/src/content/reference/en/p5.sound/p5.TriOsc.mdx
+++ b/src/content/reference/en/p5.sound/p5.TriOsc.mdx
@@ -2,13 +2,20 @@
title: p5.TriOsc
module: p5.sound
submodule: p5.sound
-file: src/Oscillator.js
-description: Creates a triangle oscillator.
-line: 247
+file: lib/addons/p5.sound.js
+description: |
+ Constructor: new p5.TriOsc()
.
+ This creates a Triangle Wave Oscillator and is
+ equivalent to new p5.Oscillator('triangle')
+
or creating a p5.Oscillator and then calling
+ its method setType('triangle')
.
+ See p5.Oscillator for methods.
+line: 4629
isConstructor: true
params:
- name: freq
- description: Set the frequency
+ description: |
+ Set the frequency
type: Number
optional: true
chainable: false
diff --git a/src/content/reference/en/p5.sound/setAudioContext.mdx b/src/content/reference/en/p5.sound/setAudioContext.mdx
deleted file mode 100644
index 292eed6596..0000000000
--- a/src/content/reference/en/p5.sound/setAudioContext.mdx
+++ /dev/null
@@ -1,21 +0,0 @@
----
-title: setAudioContext
-module: Sound
-submodule: Sound Utilities
-file: src/Utils.js
-description: >-
- Sets the AudioContext to a specified context to enable cross library
- compatibility.
-line: 26
-isConstructor: false
-itemtype: method
-class: p5.sound
-params:
- - name: the
- description: desired AudioContext.
- type: AudioContext
-chainable: false
----
-
-
-# setAudioContext
diff --git a/src/content/reference/en/p5.sound/userStartAudio.mdx b/src/content/reference/en/p5.sound/userStartAudio.mdx
deleted file mode 100644
index 21d17706cf..0000000000
--- a/src/content/reference/en/p5.sound/userStartAudio.mdx
+++ /dev/null
@@ -1,17 +0,0 @@
----
-title: userStartAudio
-module: Sound
-submodule: Sound Utilities
-file: src/Utils.js
-description: >-
- userStartAudio() starts the AudioContext on a user gesture. It can be placed
- in a specific interaction function, such as mousePressed().
-line: 35
-isConstructor: false
-itemtype: method
-class: p5.sound
-chainable: false
----
-
-
-# userStartAudio
diff --git a/src/content/reference/en/p5.sound/userStopAudio.mdx b/src/content/reference/en/p5.sound/userStopAudio.mdx
deleted file mode 100644
index ed3d3b1419..0000000000
--- a/src/content/reference/en/p5.sound/userStopAudio.mdx
+++ /dev/null
@@ -1,15 +0,0 @@
----
-title: userStopAudio
-module: Sound
-submodule: Sound Utilities
-file: src/Utils.js
-description: userStopAudio() stops the AudioContext on a user gesture.
-line: 43
-isConstructor: false
-itemtype: method
-class: p5.sound
-chainable: false
----
-
-
-# userStopAudio
diff --git a/src/content/reference/en/p5/append.mdx b/src/content/reference/en/p5/append.mdx
index 60652959b6..12e0a20aab 100644
--- a/src/content/reference/en/p5/append.mdx
+++ b/src/content/reference/en/p5/append.mdx
@@ -7,6 +7,7 @@ description: |
Adds a value to the end of an array. Extends the length of
the array by one. Maps to Array.push().
line: 10
+deprecated: true
isConstructor: false
itemtype: method
example:
diff --git a/src/content/reference/en/p5/arrayCopy.mdx b/src/content/reference/en/p5/arrayCopy.mdx
index 0a74f8beea..01656def7e 100644
--- a/src/content/reference/en/p5/arrayCopy.mdx
+++ b/src/content/reference/en/p5/arrayCopy.mdx
@@ -27,6 +27,7 @@ description: >
iterating through a for() loop and copying each element individually.
line: 35
+deprecated: true
isConstructor: false
itemtype: method
example:
diff --git a/src/content/reference/en/p5/background.mdx b/src/content/reference/en/p5/background.mdx
index e2d306d595..6e83c4b14c 100644
--- a/src/content/reference/en/p5/background.mdx
+++ b/src/content/reference/en/p5/background.mdx
@@ -63,7 +63,7 @@ line: 414
isConstructor: false
itemtype: method
example:
- - |
+ - |-
diff --git a/src/content/reference/en/p5/blue.mdx b/src/content/reference/en/p5/blue.mdx
index 6b66af6f5d..b6ba1b8848 100644
--- a/src/content/reference/en/p5/blue.mdx
+++ b/src/content/reference/en/p5/blue.mdx
@@ -15,7 +15,7 @@ description: >
By default, blue()
returns a color's blue value in the range 0
- to 255. If the colorMode() is set to RGB,
+ to 255. If the colorMode() is set to RGB,
it
returns the blue value in the given range.
diff --git a/src/content/reference/en/p5/brightness.mdx b/src/content/reference/en/p5/brightness.mdx
index 1a10a00acf..5631384233 100644
--- a/src/content/reference/en/p5/brightness.mdx
+++ b/src/content/reference/en/p5/brightness.mdx
@@ -16,7 +16,7 @@ description: >
By default, brightness()
returns a color's HSB brightness in
the range 0
- to 100. If the colorMode() is set to HSB,
+ to 100. If the colorMode() is set to HSB,
it
returns the brightness value in the given range.
diff --git a/src/content/reference/en/p5/class.mdx b/src/content/reference/en/p5/class.mdx
index e389794dc5..400957b6cb 100644
--- a/src/content/reference/en/p5/class.mdx
+++ b/src/content/reference/en/p5/class.mdx
@@ -8,7 +8,7 @@ line: 1329
isConstructor: false
itemtype: property
example:
- - "\n\n\n// Declare a frog variable.\nlet fifi;\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Assign the frog variable a new Frog object.\n fifi = new Frog(50, 50, 20);\n\n describe('A frog face drawn on a gray background.');\n}\n\nfunction draw() {\n background('cornflowerblue');\n\n // Show the frog.\n fifi.show();\n}\n\nclass Frog {\n constructor(x, y, size) {\n this.x = x;\n this.y = y;\n this.size = size;\n }\n\n show() {\n textAlign(CENTER, CENTER);\n textSize(this.size);\n text('\U0001F438', this.x, this.y);\n }\n}\n
\n\n\n\n\n// Declare two frog variables.\nlet frog1;\nlet frog2;\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Assign the frog variables a new Frog object.\n frog1 = new Frog(25, 50, 10);\n frog2 = new Frog(75, 50, 20);\n\n describe('Two frog faces drawn next to each other on a gray background.');\n}\n\nfunction draw() {\n background('cornflowerblue');\n\n // Show the frogs.\n frog1.show();\n frog2.show();\n}\n\nclass Frog {\n constructor(x, y, size) {\n this.x = x;\n this.y = y;\n this.size = size;\n }\n\n show() {\n textAlign(CENTER, CENTER);\n textSize(this.size);\n text('\U0001F438', this.x, this.y);\n }\n}\n
\n\n\n\n\n// Declare two frog variables.\nlet frog1;\nlet frog2;\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Assign the frog variables a new Frog object.\n frog1 = new Frog(25, 50, 10);\n frog2 = new Frog(75, 50, 20);\n\n // Slow the frame rate.\n frameRate(1);\n\n describe('Two frog faces on a gray background. The frogs hop around randomly.');\n}\n\nfunction draw() {\n background('cornflowerblue');\n\n // Show the frogs.\n frog1.show();\n frog2.show();\n\n // Move the frogs.\n frog1.hop();\n frog2.hop();\n\n // Wrap around if they've hopped off the edge.\n frog1.checkEdges();\n frog2.checkEdges();\n}\n\nclass Frog {\n constructor(x, y, size) {\n this.x = x;\n this.y = y;\n this.size = size;\n }\n\n show() {\n textAlign(CENTER, CENTER);\n textSize(this.size);\n text('\U0001F438', this.x, this.y);\n }\n\n hop() {\n this.x += random(-10, 10);\n this.y += random(-10, 10);\n }\n\n checkEdges() {\n if (this.x > width) {\n this.x = this.x - width;\n } else if (this.x < 0) {\n this.x = width - this.x;\n }\n\n if (this.y > height) {\n this.y = this.y - height;\n } else if (this.y < 0) {\n this.y = height - this.y;\n }\n }\n}\n
\n\n\n\n\n// Declare two frog variables.\nlet frog1;\nlet frog2;\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Assign the frog variables a new Frog object.\n frog1 = new Frog(25, 50, 10);\n frog2 = new Frog(75, 50, 20);\n\n describe('Two frog faces drawn next to each other on a gray background.');\n}\n\nfunction draw() {\n background('cornflowerblue');\n\n // Show the frogs.\n frog1.show();\n frog2.show();\n}\n\nclass Frog {\n constructor(x, y, size) {\n this.x = x;\n this.y = y;\n this.size = size;\n }\n\n show() {\n textAlign(CENTER, CENTER);\n textSize(this.size);\n text('\U0001F438', this.x, this.y);\n }\n}\n
\n\n\n\n\n// Create an array that will hold frogs.\nlet frogs = [];\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Add Frog objects to the array.\n for (let i = 0; i < 5; i += 1) {\n // Calculate random coordinates and size.\n let x = random(0, 100);\n let y = random(0, 100);\n let s = random(2, 20);\n\n // Create a new Frog object.\n let frog = new Frog(x, y, s);\n\n // Add the Frog to the array.\n frogs.push(frog);\n }\n\n // Slow the frame rate.\n frameRate(1);\n\n describe(\n 'Five frog faces on a gray background. The frogs hop around randomly.'\n );\n}\n\nfunction draw() {\n background('cornflowerblue');\n\n for (let frog of frogs) {\n // Show the frog.\n frog.show();\n\n // Move the frog.\n frog.hop();\n\n // Wrap around if they've hopped off the edge.\n frog.checkEdges();\n }\n}\n\nclass Frog {\n constructor(x, y, size) {\n this.x = x;\n this.y = y;\n this.size = size;\n }\n\n show() {\n textAlign(CENTER, CENTER);\n textSize(this.size);\n text('\U0001F438', this.x, this.y);\n }\n\n hop() {\n this.x += random(-10, 10);\n this.y += random(-10, 10);\n }\n\n checkEdges() {\n if (this.x > width) {\n this.x = this.x - width;\n } else if (this.x < 0) {\n this.x = width - this.x;\n }\n\n if (this.y > height) {\n this.y = this.y - height;\n } else if (this.y < 0) {\n this.y = height - this.y;\n }\n }\n}\n
\n"
+ - "\n\n\n// Declare a frog variable.\nlet fifi;\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Assign the frog variable a new Frog object.\n fifi = new Frog(50, 50, 20);\n\n describe('A frog face drawn on a blue background.');\n}\n\nfunction draw() {\n background('cornflowerblue');\n\n // Show the frog.\n fifi.show();\n}\n\nclass Frog {\n constructor(x, y, size) {\n this.x = x;\n this.y = y;\n this.size = size;\n }\n\n show() {\n textAlign(CENTER, CENTER);\n textSize(this.size);\n text('\U0001F438', this.x, this.y);\n }\n}\n
\n\n\n\n\n// Declare two frog variables.\nlet frog1;\nlet frog2;\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Assign the frog variables a new Frog object.\n frog1 = new Frog(25, 50, 10);\n frog2 = new Frog(75, 50, 20);\n\n describe('Two frog faces drawn next to each other on a blue background.');\n}\n\nfunction draw() {\n background('cornflowerblue');\n\n // Show the frogs.\n frog1.show();\n frog2.show();\n}\n\nclass Frog {\n constructor(x, y, size) {\n this.x = x;\n this.y = y;\n this.size = size;\n }\n\n show() {\n textAlign(CENTER, CENTER);\n textSize(this.size);\n text('\U0001F438', this.x, this.y);\n }\n}\n
\n\n\n\n\n// Declare two frog variables.\nlet frog1;\nlet frog2;\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Assign the frog variables a new Frog object.\n frog1 = new Frog(25, 50, 10);\n frog2 = new Frog(75, 50, 20);\n\n // Slow the frame rate.\n frameRate(1);\n\n describe('Two frog faces on a blue background. The frogs hop around randomly.');\n}\n\nfunction draw() {\n background('cornflowerblue');\n\n // Show the frogs.\n frog1.show();\n frog2.show();\n\n // Move the frogs.\n frog1.hop();\n frog2.hop();\n\n // Wrap around if they've hopped off the edge.\n frog1.checkEdges();\n frog2.checkEdges();\n}\n\nclass Frog {\n constructor(x, y, size) {\n this.x = x;\n this.y = y;\n this.size = size;\n }\n\n show() {\n textAlign(CENTER, CENTER);\n textSize(this.size);\n text('\U0001F438', this.x, this.y);\n }\n\n hop() {\n this.x += random(-10, 10);\n this.y += random(-10, 10);\n }\n\n checkEdges() {\n if (this.x > width) {\n this.x = this.x - width;\n } else if (this.x < 0) {\n this.x = width - this.x;\n }\n\n if (this.y > height) {\n this.y = this.y - height;\n } else if (this.y < 0) {\n this.y = height - this.y;\n }\n }\n}\n
\n\n\n\n\n// Create an array that will hold frogs.\nlet frogs = [];\n\nfunction setup() {\n createCanvas(100, 100);\n\n // Add Frog objects to the array.\n for (let i = 0; i < 5; i += 1) {\n // Calculate random coordinates and size.\n let x = random(0, 100);\n let y = random(0, 100);\n let s = random(2, 20);\n\n // Create a new Frog object.\n let frog = new Frog(x, y, s);\n\n // Add the Frog to the array.\n frogs.push(frog);\n }\n\n // Slow the frame rate.\n frameRate(1);\n\n describe(\n 'Five frog faces on a blue background. The frogs hop around randomly.'\n );\n}\n\nfunction draw() {\n background('cornflowerblue');\n\n for (let frog of frogs) {\n // Show the frog.\n frog.show();\n\n // Move the frog.\n frog.hop();\n\n // Wrap around if they've hopped off the edge.\n frog.checkEdges();\n }\n}\n\nclass Frog {\n constructor(x, y, size) {\n this.x = x;\n this.y = y;\n this.size = size;\n }\n\n show() {\n textAlign(CENTER, CENTER);\n textSize(this.size);\n text('\U0001F438', this.x, this.y);\n }\n\n hop() {\n this.x += random(-10, 10);\n this.y += random(-10, 10);\n }\n\n checkEdges() {\n if (this.x > width) {\n this.x = this.x - width;\n } else if (this.x < 0) {\n this.x = width - this.x;\n }\n\n if (this.y > height) {\n this.y = this.y - height;\n } else if (this.y < 0) {\n this.y = height - this.y;\n }\n }\n}\n
\n"
class: p5
---
diff --git a/src/content/reference/en/p5/concat.mdx b/src/content/reference/en/p5/concat.mdx
index 7fc162190a..44fed0d2f9 100644
--- a/src/content/reference/en/p5/concat.mdx
+++ b/src/content/reference/en/p5/concat.mdx
@@ -7,6 +7,7 @@ description: |
Concatenates two arrays, maps to Array.concat(). Does not modify the
input arrays.
line: 112
+deprecated: true
isConstructor: false
itemtype: method
example:
diff --git a/src/content/reference/en/p5/console.mdx b/src/content/reference/en/p5/console.mdx
index 9a4c1e86b4..1695dd7373 100644
--- a/src/content/reference/en/p5/console.mdx
+++ b/src/content/reference/en/p5/console.mdx
@@ -45,7 +45,7 @@ description: >
loadImage('https://example.com/cat.jpg', handleImage, handleError);
-line: 2028
+line: 1988
isConstructor: false
itemtype: property
example:
diff --git a/src/content/reference/en/p5/cos.mdx b/src/content/reference/en/p5/cos.mdx
index c785135788..d81ee03047 100644
--- a/src/content/reference/en/p5/cos.mdx
+++ b/src/content/reference/en/p5/cos.mdx
@@ -86,8 +86,9 @@ example:
class: p5
params:
- name: angle
- description: |
- the angle.
+ description: >
+ the angle in radians unless specified by angleMode().
type: Number
return:
description: cosine of the angle.
diff --git a/src/content/reference/en/p5/createA.mdx b/src/content/reference/en/p5/createA.mdx
index f9809d38e7..72b86e97fe 100644
--- a/src/content/reference/en/p5/createA.mdx
+++ b/src/content/reference/en/p5/createA.mdx
@@ -42,7 +42,7 @@ example:
background(200);
// Create an anchor element that links to p5js.org.
- let a = createA('https://p5js.org/', 'p5*js');
+ let a = createA('http://p5js.org/', 'p5*js');
a.position(25, 35);
describe('The text "p5*js" written at the center of a gray square.');
@@ -57,7 +57,7 @@ example:
// Create an anchor tag that links to p5js.org.
// Open the link in a new tab.
- let a = createA('https://p5js.org/', 'p5*js', '_blank');
+ let a = createA('http://p5js.org/', 'p5*js', '_blank');
a.position(25, 35);
describe('The text "p5*js" written at the center of a gray square.');
diff --git a/src/content/reference/en/p5/createModel.mdx b/src/content/reference/en/p5/createModel.mdx
index 8014b83599..6ba33e4a9d 100644
--- a/src/content/reference/en/p5/createModel.mdx
+++ b/src/content/reference/en/p5/createModel.mdx
@@ -47,7 +47,7 @@ description: >
flipV
: Flips the V texture coordinates of the model.
-line: 1129
+line: 1134
isConstructor: false
itemtype: method
example:
@@ -93,7 +93,7 @@ return:
description: the p5.Geometry object
type: p5.Geometry
overloads:
- - line: 1129
+ - line: 1134
params:
- name: modelString
description: |
@@ -126,7 +126,7 @@ overloads:
return:
description: the p5.Geometry object
type: p5.Geometry
- - line: 1199
+ - line: 1204
params:
- name: modelString
description: ''
@@ -146,7 +146,7 @@ overloads:
return:
description: the p5.Geometry object
type: p5.Geometry
- - line: 1207
+ - line: 1212
params:
- name: modelString
description: ''
diff --git a/src/content/reference/en/p5/createP.mdx b/src/content/reference/en/p5/createP.mdx
index 851e7ded92..c7998ad8f0 100644
--- a/src/content/reference/en/p5/createP.mdx
+++ b/src/content/reference/en/p5/createP.mdx
@@ -4,7 +4,7 @@ module: DOM
submodule: DOM
file: src/dom/dom.js
description: >
- Creates a paragraph element.
+ Creates a
element.
elements are commonly used for paragraph-length
text.
diff --git a/src/content/reference/en/p5/createSlider.mdx b/src/content/reference/en/p5/createSlider.mdx
index ec96d92c93..a38232f3b5 100644
--- a/src/content/reference/en/p5/createSlider.mdx
+++ b/src/content/reference/en/p5/createSlider.mdx
@@ -150,7 +150,7 @@ params:
type: Number
optional: true
return:
- description: new p5.Element object.
+ description: new p5.Element object.
type: p5.Element
chainable: false
---
diff --git a/src/content/reference/en/p5/fill.mdx b/src/content/reference/en/p5/fill.mdx
index e704ef6ef1..a06bd2f294 100644
--- a/src/content/reference/en/p5/fill.mdx
+++ b/src/content/reference/en/p5/fill.mdx
@@ -240,7 +240,7 @@ overloads:
type: Number
- name: alpha
description: >
- optional alpha value, controls transparency (0 - transparent, 255 -
+
alpha value, controls transparency (0 - transparent, 255 -
opaque).
type: Number
optional: true
diff --git a/src/content/reference/en/p5/for.mdx b/src/content/reference/en/p5/for.mdx
index c8ee85b2b7..65ced3c14c 100644
--- a/src/content/reference/en/p5/for.mdx
+++ b/src/content/reference/en/p5/for.mdx
@@ -165,7 +165,7 @@ description: >
updates its value to 40
and then 60
during the next
iterations.
-line: 1688
+line: 1648
isConstructor: false
itemtype: property
example:
diff --git a/src/content/reference/en/p5/getURLParams.mdx b/src/content/reference/en/p5/getURLParams.mdx
index c7661b7f34..8f4a37bd44 100644
--- a/src/content/reference/en/p5/getURLParams.mdx
+++ b/src/content/reference/en/p5/getURLParams.mdx
@@ -15,7 +15,7 @@ description: >
For example, calling getURLParams()
in a sketch hosted at the
URL
- https://p5js.org?year=2014&month=May&day=15
returns
+ http://p5js.org?year=2014&month=May&day=15
returns
{ year: 2014, month: 'May', day: 15 }
.
line: 1208
diff --git a/src/content/reference/en/p5/green.mdx b/src/content/reference/en/p5/green.mdx
index b19ba7523f..5aee8b7de1 100644
--- a/src/content/reference/en/p5/green.mdx
+++ b/src/content/reference/en/p5/green.mdx
@@ -16,7 +16,7 @@ description: >
By default, green()
returns a color's green value in the range
0
- to 255. If the colorMode() is set to RGB,
+ to 255. If the colorMode() is set to RGB,
it
returns the green value in the given range.
diff --git a/src/content/reference/en/p5/hue.mdx b/src/content/reference/en/p5/hue.mdx
index a14c21882b..af5861e635 100644
--- a/src/content/reference/en/p5/hue.mdx
+++ b/src/content/reference/en/p5/hue.mdx
@@ -18,7 +18,7 @@ description: >
returns a color's HSL hue in the range 0 to 360. If the
- colorMode() is set to HSB or HSL, it
+ colorMode() is set to HSB or HSL, it
returns the hue
value in the given mode.
diff --git a/src/content/reference/en/p5/keyIsDown.mdx b/src/content/reference/en/p5/keyIsDown.mdx
index 4de0221d64..0f98f1696e 100644
--- a/src/content/reference/en/p5/keyIsDown.mdx
+++ b/src/content/reference/en/p5/keyIsDown.mdx
@@ -30,7 +30,7 @@ description: >
keyIsDown(LEFT_ARROW)
. Key codes can be found on websites such as
keycode.info.
-line: 795
+line: 809
isConstructor: false
itemtype: method
example:
diff --git a/src/content/reference/en/p5/keyReleased.mdx b/src/content/reference/en/p5/keyReleased.mdx
index 1fe77469fb..e293d6cad4 100644
--- a/src/content/reference/en/p5/keyReleased.mdx
+++ b/src/content/reference/en/p5/keyReleased.mdx
@@ -57,7 +57,7 @@ description: >
the end
of the function.
-line: 461
+line: 472
isConstructor: false
itemtype: method
example:
diff --git a/src/content/reference/en/p5/keyTyped.mdx b/src/content/reference/en/p5/keyTyped.mdx
index 646087c938..8ff0573ff8 100644
--- a/src/content/reference/en/p5/keyTyped.mdx
+++ b/src/content/reference/en/p5/keyTyped.mdx
@@ -73,7 +73,7 @@ description: >
the end
of the function.
-line: 639
+line: 653
isConstructor: false
itemtype: method
example:
diff --git a/src/content/reference/en/p5/lightness.mdx b/src/content/reference/en/p5/lightness.mdx
index 15b87823a9..de4dbf41bc 100644
--- a/src/content/reference/en/p5/lightness.mdx
+++ b/src/content/reference/en/p5/lightness.mdx
@@ -16,7 +16,7 @@ description: >
By default, lightness()
returns a color's HSL lightness in the
range 0
- to 100. If the colorMode() is set to HSL,
+ to 100. If the colorMode() is set to HSL,
it
returns the lightness value in the given range.
diff --git a/src/content/reference/en/p5/line.mdx b/src/content/reference/en/p5/line.mdx
index f338067107..8fafe3a215 100644
--- a/src/content/reference/en/p5/line.mdx
+++ b/src/content/reference/en/p5/line.mdx
@@ -94,7 +94,7 @@ example:
}
- - |
+ - |-
diff --git a/src/content/reference/en/p5/loadModel.mdx b/src/content/reference/en/p5/loadModel.mdx
index f5bbd47a90..9c34c265db 100644
--- a/src/content/reference/en/p5/loadModel.mdx
+++ b/src/content/reference/en/p5/loadModel.mdx
@@ -31,6 +31,16 @@ description: >
'https://example.com/model.obj'
may be blocked due to browser
security.
+ Note: When loading a .obj
file that references materials
+ stored in
+
+ .mtl
files, p5.js will attempt to load and apply those materials.
+
+ To ensure that the .obj
file reads the .mtl
file
+ correctly include the
+
+ .mtl
file alongside it.
+
The first way to call loadModel()
has three optional
parameters after the
@@ -391,7 +401,7 @@ overloads:
return:
description: the p5.Geometry object
type: p5.Geometry
- - line: 319
+ - line: 324
params:
- name: path
description: ''
@@ -411,7 +421,7 @@ overloads:
return:
description: new p5.Geometry object.
type: p5.Geometry
- - line: 327
+ - line: 332
params:
- name: path
description: ''
diff --git a/src/content/reference/en/p5/loadTable.mdx b/src/content/reference/en/p5/loadTable.mdx
index bbb05cfc2f..871026ac69 100644
--- a/src/content/reference/en/p5/loadTable.mdx
+++ b/src/content/reference/en/p5/loadTable.mdx
@@ -57,7 +57,7 @@ example:
//and has a header specifying the columns labels
table = loadTable('/assets/mammals.csv', 'csv', 'header');
//the file can be remote
- //table = loadTable("https://p5js.org/reference//assets/mammals.csv",
+ //table = loadTable("http://p5js.org/reference//assets/mammals.csv",
// "csv", "header");
}
diff --git a/src/content/reference/en/p5/model.mdx b/src/content/reference/en/p5/model.mdx
index 4fd95e7946..981de3bf09 100644
--- a/src/content/reference/en/p5/model.mdx
+++ b/src/content/reference/en/p5/model.mdx
@@ -23,7 +23,7 @@ description: >
a file with loadGeometry().
Note: model()
can only be used in WebGL mode.
-line: 988
+line: 993
isConstructor: false
itemtype: method
example:
diff --git a/src/content/reference/en/p5/p5.Geometry.mdx b/src/content/reference/en/p5/p5.Geometry.mdx
index c86a37cb3a..a5ab48e47e 100644
--- a/src/content/reference/en/p5/p5.Geometry.mdx
+++ b/src/content/reference/en/p5/p5.Geometry.mdx
@@ -496,11 +496,11 @@ methods:
// Notice the swaps:
- // Left vertices: [0, 0] <--> [1, 0]
+ // Left vertices: [0, 0] <--> [1, 0]
- // Right vertices: [1, 0] <--> [1, 1]
+ // Right vertices: [1, 0] <--> [1, 1]
- -->-->
+
path: p5.Geometry/flipV
computeFaces:
description: >
diff --git a/src/content/reference/en/p5/p5.Shader.mdx b/src/content/reference/en/p5/p5.Shader.mdx
index 85aa3ae372..df30922ab4 100644
--- a/src/content/reference/en/p5/p5.Shader.mdx
+++ b/src/content/reference/en/p5/p5.Shader.mdx
@@ -64,7 +64,7 @@ description: >
void main() {
HOOK_beforeVertex();
- // Add the rest ofy our shader code here!
+ // Add the rest of your shader code here!
}
diff --git a/src/content/reference/en/p5/paletteLerp.mdx b/src/content/reference/en/p5/paletteLerp.mdx
index 30a3dee1b6..281627209d 100644
--- a/src/content/reference/en/p5/paletteLerp.mdx
+++ b/src/content/reference/en/p5/paletteLerp.mdx
@@ -19,7 +19,7 @@ description: >
The way that colors are interpolated depends on the current
- colorMode().
+ colorMode().
line: 1079
isConstructor: false
itemtype: method
diff --git a/src/content/reference/en/p5/red.mdx b/src/content/reference/en/p5/red.mdx
index bd47f1ba6f..53caf4c44c 100644
--- a/src/content/reference/en/p5/red.mdx
+++ b/src/content/reference/en/p5/red.mdx
@@ -15,7 +15,7 @@ description: >
By default, red()
returns a color's red value in the range 0
- to 255. If the colorMode() is set to RGB,
+ to 255. If the colorMode() is set to RGB,
it
returns the red value in the given range.
diff --git a/src/content/reference/en/p5/reverse.mdx b/src/content/reference/en/p5/reverse.mdx
index df1d26cbb8..b30a4f75c6 100644
--- a/src/content/reference/en/p5/reverse.mdx
+++ b/src/content/reference/en/p5/reverse.mdx
@@ -6,6 +6,7 @@ file: src/utilities/array_functions.js
description: |
Reverses the order of an array, maps to Array.reverse()
line: 141
+deprecated: true
isConstructor: false
itemtype: method
example:
diff --git a/src/content/reference/en/p5/saturation.mdx b/src/content/reference/en/p5/saturation.mdx
index 4ac75f6a26..2940cc659f 100644
--- a/src/content/reference/en/p5/saturation.mdx
+++ b/src/content/reference/en/p5/saturation.mdx
@@ -18,7 +18,7 @@ description: >
returns a color's HSL saturation in the range 0 to 100. If the
- colorMode() is set to HSB or HSL, it
+ colorMode() is set to HSB or HSL, it
returns the
saturation value in the given mode.
diff --git a/src/content/reference/en/p5/saveFrames.mdx b/src/content/reference/en/p5/saveFrames.mdx
index 5ea0e4aa75..c77c3a0335 100644
--- a/src/content/reference/en/p5/saveFrames.mdx
+++ b/src/content/reference/en/p5/saveFrames.mdx
@@ -14,7 +14,7 @@ description: >
example, the first saved frame might have the following properties:
- { ext: 'png', filenmame: 'frame0', imageData:
+ { ext: 'png', filename: 'frame0', imageData:
'data:image/octet-stream;base64, abc123' }
.
The first parameter, filename
, sets the prefix for the file
diff --git a/src/content/reference/en/p5/saveSound.mdx b/src/content/reference/en/p5/saveSound.mdx
index 42eef131a3..0676ce11fe 100644
--- a/src/content/reference/en/p5/saveSound.mdx
+++ b/src/content/reference/en/p5/saveSound.mdx
@@ -11,7 +11,7 @@ description: >
For uploading audio to a server, use
p5.SoundFile.saveBlob
.
+ href="/docs/reference/#/p5.SoundFile/saveBlob/">p5.SoundFile.saveBlob
.
line: 1145
isConstructor: false
itemtype: method
diff --git a/src/content/reference/en/p5/shorten.mdx b/src/content/reference/en/p5/shorten.mdx
index b3cfdecf68..7d9060df54 100644
--- a/src/content/reference/en/p5/shorten.mdx
+++ b/src/content/reference/en/p5/shorten.mdx
@@ -7,6 +7,7 @@ description: |
Decreases an array by one element and returns the shortened array,
maps to Array.pop().
line: 161
+deprecated: true
isConstructor: false
itemtype: method
example:
diff --git a/src/content/reference/en/p5/sin.mdx b/src/content/reference/en/p5/sin.mdx
index 439945e25b..fc241c4173 100644
--- a/src/content/reference/en/p5/sin.mdx
+++ b/src/content/reference/en/p5/sin.mdx
@@ -86,8 +86,9 @@ example:
class: p5
params:
- name: angle
- description: |
- the angle.
+ description: >
+ the angle in radians unless specified by angleMode().
type: Number
return:
description: sine of the angle.
diff --git a/src/content/reference/en/p5/sort.mdx b/src/content/reference/en/p5/sort.mdx
index 8c4398d07b..bfc89c09d5 100644
--- a/src/content/reference/en/p5/sort.mdx
+++ b/src/content/reference/en/p5/sort.mdx
@@ -10,6 +10,7 @@ description: |
elements to sort. For example, if there are 12 elements in an array and
count is set to 5, only the first 5 elements in the array will be sorted.
line: 300
+deprecated: true
isConstructor: false
itemtype: method
example:
diff --git a/src/content/reference/en/p5/splice.mdx b/src/content/reference/en/p5/splice.mdx
index e3aec6c786..eb111d0991 100644
--- a/src/content/reference/en/p5/splice.mdx
+++ b/src/content/reference/en/p5/splice.mdx
@@ -11,6 +11,7 @@ description: |
(Remember that array index numbering starts at zero, so the first position
is 0, the second position is 1, and so on.)
line: 346
+deprecated: true
isConstructor: false
itemtype: method
example:
diff --git a/src/content/reference/en/p5/stroke.mdx b/src/content/reference/en/p5/stroke.mdx
index 25a21ed99c..ada5111cb6 100644
--- a/src/content/reference/en/p5/stroke.mdx
+++ b/src/content/reference/en/p5/stroke.mdx
@@ -262,7 +262,9 @@ overloads:
is HSB.
type: Number
- name: alpha
- description: ''
+ description: >
+ alpha value, controls transparency (0 - transparent, 255 -
+ opaque).
type: Number
optional: true
chainable: 1
diff --git a/src/content/reference/en/p5/subset.mdx b/src/content/reference/en/p5/subset.mdx
index 1cf9f6c1f6..b6968e511f 100644
--- a/src/content/reference/en/p5/subset.mdx
+++ b/src/content/reference/en/p5/subset.mdx
@@ -11,6 +11,7 @@ description: |
When specifying the start, remember that the first array element is 0.
This function does not change the source array.
line: 381
+deprecated: true
isConstructor: false
itemtype: method
example:
diff --git a/src/content/reference/en/p5/tan.mdx b/src/content/reference/en/p5/tan.mdx
index 1fb3eeafd8..94694a1888 100644
--- a/src/content/reference/en/p5/tan.mdx
+++ b/src/content/reference/en/p5/tan.mdx
@@ -43,8 +43,9 @@ example:
class: p5
params:
- name: angle
- description: |
- the angle.
+ description: >
+ the angle in radians unless specified by angleMode().
type: Number
return:
description: tangent of the angle.
diff --git a/src/content/reference/en/p5/while.mdx b/src/content/reference/en/p5/while.mdx
index 5198618587..4622976804 100644
--- a/src/content/reference/en/p5/while.mdx
+++ b/src/content/reference/en/p5/while.mdx
@@ -94,7 +94,7 @@ description: >
}
-line: 1912
+line: 1872
isConstructor: false
itemtype: property
example:
diff --git a/src/globals/globals.ts b/src/globals/globals.ts
index 6fce520364..33c302365a 100644
--- a/src/globals/globals.ts
+++ b/src/globals/globals.ts
@@ -23,4 +23,6 @@ export const libraryDownloadUrl =
export const minifiedLibraryDownloadUrl =
`https://github.com/processing/p5.js/releases/download/v${p5Version}/p5.min.js` as const;
export const cdnSoundUrl =
- `https://cdn.jsdelivr.net/npm/p5.sound@${p5SoundVersion}` as const;
+ (!!import.meta.env?.PUBLIC_P5_LIBRARY_PATH || p5Version.startsWith('v2'))
+ ? `https://cdn.jsdelivr.net/npm/p5.sound@${p5SoundVersion}` as const
+ : `https://cdn.jsdelivr.net/npm/p5@${p5Version}/lib/addons/p5.sound.min.js` as const
diff --git a/src/scripts/builders/reference.ts b/src/scripts/builders/reference.ts
index 50fbce16b1..d72954c418 100644
--- a/src/scripts/builders/reference.ts
+++ b/src/scripts/builders/reference.ts
@@ -415,6 +415,7 @@ const convertDocsToMDX = async (
doc.example = correctRelativeLinksToExampleAssets(
doc.example,
) as string[];
+ doc.deprecated = (doc.deprecated ? (doc.deprecationMessage ?? true) : undefined) as any;
const mdx = await convertToMDX(doc);
return mdx ? { mdx, savePath, name: doc.name } : null;
diff --git a/src/scripts/parsers/reference.ts b/src/scripts/parsers/reference.ts
index 1395782e80..f49ae0bc21 100644
--- a/src/scripts/parsers/reference.ts
+++ b/src/scripts/parsers/reference.ts
@@ -27,6 +27,9 @@ export const parseLibraryReference =
latestRelease = 'v' + latestRelease;
}
+ const useExternalP5Sound = !!process.env.P5_REPO_BRANCH ||
+ latestRelease.startsWith('v2');
+
// Clone p5.js
await cloneLibraryRepo(
localPath,
@@ -36,56 +39,68 @@ export const parseLibraryReference =
);
// Install dependencies and build docs in the p5 repo
- await createP5Docs('p5.js', 'data-p5')
+ await createP5Docs('p5.js', 'data-p5');
// If we're using a custom build of p5 instead of a public release, create
// a build and copy it to the specified path
if (process.env.PUBLIC_P5_LIBRARY_PATH) {
- await createP5Build('p5.js', '../../../public' + process.env.PUBLIC_P5_LIBRARY_PATH)
+ await createP5Build('p5.js', '../../../public' + process.env.PUBLIC_P5_LIBRARY_PATH);
}
// Copy the reference output so we can process it
const p5Data = await getYuidocOutput('data-p5');
if (!p5Data) throw new Error('Error generating p5 reference data!');
- // Clone p5.sound.js
- await cloneLibraryRepo(
- localSoundPath,
- 'https://github.com/processing/p5.sound.js.git',
- 'main'
- );
- await saveYuidocOutput('p5.sound.js', 'data-sound');
- const soundData = await getYuidocOutput('data-sound');
- if (!soundData) throw new Error('Error generating p5.sound reference data!');
-
- // Fix p5.sound classes
- for (const key in soundData.classes) {
- const newName = 'p5.' + soundData.classes[key].name;
- const updated = {
- ...soundData.classes[key],
- name: newName,
- };
- soundData.classes[newName] = updated;
- delete soundData.classes[key];
- }
- for (const item of soundData.classitems) {
- item.class = 'p5.' + item.class;
- }
+ let result;
+ if (useExternalP5Sound) {
+ console.log('Cloning separate p5.sound repo');
+
+ // Clone p5.sound.js
+ await cloneLibraryRepo(
+ localSoundPath,
+ 'https://github.com/processing/p5.sound.js.git',
+ 'main'
+ );
+ await saveYuidocOutput('p5.sound.js', 'data-sound');
+ const soundData = await getYuidocOutput('data-sound');
+ if (!soundData) throw new Error('Error generating p5.sound reference data!');
+
+ // Fix p5.sound classes
+ for (const key in soundData.classes) {
+ const newName = 'p5.' + soundData.classes[key].name;
+ const updated = {
+ ...soundData.classes[key],
+ name: newName,
+ };
+ soundData.classes[newName] = updated;
+ delete soundData.classes[key];
+ }
+ for (const item of soundData.classitems) {
+ item.class = 'p5.' + item.class;
+ }
- const combined = await combineYuidocData(
- [
- p5Data,
- soundData,
- ],
- 'data'
- );
+ result = await combineYuidocData(
+ [
+ p5Data,
+ soundData,
+ ],
+ 'data'
+ );
+ } else {
+ result = await combineYuidocData(
+ [
+ p5Data,
+ ],
+ 'data'
+ );
+ }
await serveYuidocOutput('data');
//delete the cloned directories
await cleanUpDirectory(parsersInPath );
await cleanUpDirectory(parsersOutPath );
- return combined;
+ return result;
};
/**
diff --git a/types/parsers.interface.ts b/types/parsers.interface.ts
index 6833946a62..7dfdf23bbf 100644
--- a/types/parsers.interface.ts
+++ b/types/parsers.interface.ts
@@ -93,7 +93,8 @@ interface Chainable {
}
interface Deprecatable {
- deprecated?: string; // If this item is deprecated, a description of why.
+ deprecated?: boolean; // If this item is deprecated, a description of why.
+ deprecationMessage?: string; // If this item is deprecated, a description of why.
}
/* Represents the return value of a method or constructor */