Reference+
Name
play()
Class
AudioSample
Description
Starts the playback of the audiosample. Only plays to the end of the audiosample once. If cue() or pause() were called previously, playback will resume from the cued position.
Examples
import processing.sound.*; AudioSample sample; void setup() { size(640, 360); background(255); sample = new AudioSample(this, 100000); // Fill it with random numbers (which will make it sound like white noise) for (int i = 0; i < sample.frames(); i++) { sample.write(i, random(-100, 100)); } sample.play(); } void draw() { }
Syntax
audiosample.play()
audiosample.play(rate)
audiosample.play(rate, amp)
audiosample.play(rate, pos, amp)
audiosample.play(rate, pos, amp, cue)
Parameters
rate
(float)
relative playback rate to use. 1 is the original speed. 0.5 is half speed and one octave down. 2 is double the speed and one octave up.pos
(float)
the panoramic position of this sound unit from -1.0 (left) to 1.0 (right). Only works for mono audiosamples!amp
(float)
the desired playback amplitude of the audiosample as a value from 0.0 (complete silence) to 1.0 (full volume)cue
(float)
position in the audiosample that playback should start from, in seconds.
Return
void
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.