p5.js | setBuffer() Function Last Updated : 12 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report The setBuffer() function is an inbuilt function in p5.js library. This function is used to reset the buffer with the current buffer. Syntax: setBuffer( buf ) Note: All the sound-related functions only work when the sound library is included in the head section of the index.html file. Parameter: This function accept a single parameters as mentioned above and described below: buf: This parameter holds an array that array 2 Float32 Arrays will create a stereo source. 1 will create a mono source. Below example illustrates the p5.setBuffer() function in JavaScript: Example: javascript var sound; function preload() { // Initialize sound sound = loadSound("pfivesound.mp3"); } function setup() { // reversebyffering the source sound.setBuffer(1); // Playing the preloaded sound sound.play(); } Online editor: https://editor.p5js.org/ Environment Setup: https://www.geeksforgeeks.org/javascript/p5-js-soundfile-object-installation-and-methods/ Supported Browsers: The browsers supported by p5.js setBuffer() function are listed below: Google Chrome Internet Explorer Firefox Safari Opera Comment More infoAdvertise with us Next Article p5.js | reverseBuffer() Function S skyridetim Follow Improve Article Tags : JavaScript Web Technologies JavaScript-p5.js Similar Reads p5.js setBlue() Function The setBlue() function in p5.js is used to set the blue color value in RGB color mode. It sets the third value of the RGB format. Syntax:setBlue(blue)Parameters: The function accepts a single parameter as mentioned above and described below: blue: This parameter stores the new blue value.Example 1: 2 min read p5.js | reverseBuffer() Function The reverseBuffer() function is an inbuilt function in p5.js library. This function is used to reverse the p5.soundfile buffer source and the playback should be handled separately. Syntax: reverseBuffer() Note: All the sound-related functions only work when the sound library is included in the head 1 min read p5.js setup() Function The setup() function runs when the program starts. It is used to set the initial environment properties such as text-color, screen size, background-color and load the media file such as images and fonts. The program contains only one setup() function. The setup() function can not be called again aft 2 min read p5.js setRed() Function The setRed() function in p5.js is used to set the red color value in RGB color mode. It sets the first value of RGB format. Syntax:setRed(red)Parameters:red: This parameter stores the new red value.Example 1: This example uses setRed() function to set red value of RGB color format. javascript/* decl 2 min read p5.js texture() Function The texture() function in p5.js is used to provide a texture for geometry objects. This texture can be an p5.Image, p5.MediaElement or p5.Graphics object. Syntax: texture( tex ) Parameters: This function accepts a single parameter as mentioned above and described below. tex: It is a p5.Image, p5.Med 2 min read p5.js | setInput() Function The setInput() function is an inbuilt function in p5.js library. This function is used to connects to the p5sound instance that is the master output by default. By using this function you can also pass in a specific source. Syntax: setInput(snd, smoothing) Note: All the sound-related functions only 1 min read Like