-
-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Sound library Waveform analyzer documentation
Contributed by @mhamilt
- Loading branch information
1 parent
868fa13
commit bdd2a02
Showing
1 changed file
with
107 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<root> | ||
|
||
<name>Waveform</name> | ||
|
||
<category>Sound</category> | ||
|
||
<subcategory>Analyzer</subcategory> | ||
|
||
<usage>Application</usage> | ||
|
||
<example> | ||
<image></image> | ||
<code><![CDATA[ | ||
import processing.sound.*; | ||
SoundFile sample; | ||
Waveform waveform; | ||
int samples = 100; | ||
public void setup() | ||
{ | ||
size(640, 360); | ||
background(255); | ||
sample = new SoundFile(this, "beat.aiff"); | ||
sample.loop(); | ||
waveform = new Waveform(this, samples); | ||
waveform.input(sample); | ||
} | ||
public void draw() | ||
{ | ||
background(0); | ||
stroke(255); | ||
strokeWeight(2); | ||
noFill(); | ||
waveform.analyze(); | ||
beginShape(); | ||
for(int i = 0; i < samples; i++) | ||
{ | ||
vertex( | ||
map(i, 0, samples, 0, width), | ||
map(waveform.data[i], -1, 1, 0, height) | ||
); | ||
} | ||
endShape(); | ||
} | ||
]]></code> | ||
</example> | ||
|
||
<description><![CDATA[ | ||
This is a Waveform analyzer. It returns the waveform of the of an audio stream the moment it is queried with the analyze() method. | ||
]]></description> | ||
|
||
<syntax> | ||
</syntax> | ||
|
||
<parameters> | ||
|
||
</parameters> | ||
|
||
<method> | ||
<mname>input()</mname> | ||
<mdescription>Define the audio input for the analyzer</mdescription> | ||
</method> | ||
|
||
<method> | ||
<mname>analyze()</mname> | ||
<mdescription>Gets the last nsamples captured from the connected input sound source, writes them | ||
into this Waveform's `data` array, and returns it.</mdescription> | ||
</method> | ||
|
||
<method> | ||
<mname>stop()</mname> | ||
<mdescription>Stop the analyzer</mdescription> | ||
</method> | ||
|
||
<method> | ||
<mname>data</mname> | ||
<mdescription>`float[]` of length nsamples, with the sample amplitudes between `-1` and `1`</mdescription> | ||
</method> | ||
|
||
<constructor> | ||
Waveform(<c>parent</c>) | ||
</constructor> | ||
|
||
<cparameter> | ||
<clabel>parent</clabel> | ||
<cdescription>PApplet: typically use "this"</cdescription> | ||
</cparameter> | ||
|
||
<returns></returns> | ||
|
||
<related> | ||
</related> | ||
|
||
<type>Object</type> | ||
|
||
<partof>Library</partof> | ||
|
||
</root> |