This reference is for Processing 3.0+. If you have a previous version, use the reference included with your software in the Help menu. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Core Javadoc and Libraries Javadoc.
Class | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Name | write() |
||||||||||||
Examples | import processing.sound.*; AudioSample sample; void setup() { size(640, 360); background(255); // Create a new audiosample sample = new AudioSample(this, 100000, 22050); // A freshly initiated audiosample contains nothing but zeros, so let's // write some data to it. for (int i = 0; i < sample.frames(); i++) { // Random numbers will make it sound like white noise sample.write(i, random(-100, 100)); } sample.play(); } void draw() { } | ||||||||||||
Description | The underlying data of the audiosample can be read and (over)written in several different ways: the method taking a single float array `data` replaces the sample data with the content of the given array. The array has to contain as many floats as there are frames in this sample. It is also possible to only write parts of the sample data using the method with four arguments, which allows you to specify the index of the first frame to write, the position in the array to take the data from, as well as how many frames should be copied over. Finally, the method taking two arguments simply sets the value of the single audio frame specified by the first argument to the given float value. | ||||||||||||
Syntax | .write(data) .write(startFrame, data, startIndex, numFrames) .write(index, value) | ||||||||||||
Parameters |
| ||||||||||||
Returns | void |
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.