| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,5 @@ | |||
| 1 | + *.o | ||
| 2 | + *.class | ||
| 3 | + .DS_Store | ||
| 4 | + /distribution | ||
| 5 | + /bin | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,31 @@ | |||
| 1 | + <?xml version="1.0"?> | ||
| 2 | + <project name="Processing Serial Library" default="build"> | ||
| 3 | + | ||
| 4 | + <target name="clean" description="Clean the build directories"> | ||
| 5 | + <delete dir="bin" /> | ||
| 6 | + <delete file="library/sound.jar" /> | ||
| 7 | + </target> | ||
| 8 | + | ||
| 9 | + <target name="compile" description="Compile sources"> | ||
| 10 | + <condition property="core-built"> | ||
| 11 | + <available file="../../../core/library/core.jar" /> | ||
| 12 | + </condition> | ||
| 13 | + <fail unless="core-built" message="Please build the core library first and make sure it sits in ../../../core/library/core.jar" /> | ||
| 14 | + | ||
| 15 | + <mkdir dir="bin" /> | ||
| 16 | + <javac source="1.6" | ||
| 17 | + target="1.6" | ||
| 18 | + srcdir="src" destdir="bin" | ||
| 19 | + encoding="UTF-8" | ||
| 20 | + includeAntRuntime="false" | ||
| 21 | + classpath="../../../core/library/core.jar; library/sound.jar" | ||
| 22 | + nowarn="true" | ||
| 23 | + compiler="org.eclipse.jdt.core.JDTCompilerAdapter"> | ||
| 24 | + <compilerclasspath path="../../mode/ecj.jar" /> | ||
| 25 | + </javac> | ||
| 26 | + </target> | ||
| 27 | + | ||
| 28 | + <target name="build" depends="compile" description="Build sound library"> | ||
| 29 | + <jar basedir="bin" destfile="library/sound.jar" /> | ||
| 30 | + </target> | ||
| 31 | + </project> | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,41 @@ | |||
| 1 | + /* | ||
| 2 | + This example shows how to use the RMS amplitude tracker. The tracker | ||
| 3 | + calculates the Root Mean Square over a block of audio and returns | ||
| 4 | + the mean as a float between 0 and 1. | ||
| 5 | + */ | ||
| 6 | + | ||
| 7 | + import processing.sound.*; | ||
| 8 | + | ||
| 9 | + Sound stream; | ||
| 10 | + SoundFile sample; | ||
| 11 | + Amplitude rms; | ||
| 12 | + | ||
| 13 | + int scale=1; | ||
| 14 | + | ||
| 15 | + public void setup() { | ||
| 16 | + size(350,350); | ||
| 17 | + | ||
| 18 | + // Create and start the sound renderer | ||
| 19 | + stream = new Sound(this, 44100, 512); | ||
| 20 | + | ||
| 21 | + //Load and play a soundfile and loop it | ||
| 22 | + sample = new SoundFile(this, "beat.aiff"); | ||
| 23 | + sample.loop(); | ||
| 24 | + | ||
| 25 | + // Create and patch the rms tracker | ||
| 26 | + rms = new Amplitude(this); | ||
| 27 | + rms.input(sample); | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + public void draw() { | ||
| 31 | + background(125,255,125); | ||
| 32 | + | ||
| 33 | + // rms.process() return a value between 0 and 1. To adjust | ||
| 34 | + // the scaling and mapping of an ellipse we scale from 0 to 0.5 | ||
| 35 | + scale=int(map(rms.process(), 0, 0.5, 1, 350)); | ||
| 36 | + noStroke(); | ||
| 37 | + | ||
| 38 | + fill(255,0,150); | ||
| 39 | + // We draw an ellispe coupled to the audio analysis | ||
| 40 | + ellipse(width/2, height/2, 1*scale, 1*scale); | ||
| 41 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,47 @@ | |||
| 1 | + /* | ||
| 2 | + This example shows how to use the Fast Fourier Transform function to get the spectrum | ||
| 3 | + of a sound. This function calculates the FFT of a signal and returns the positive normalized | ||
| 4 | + magnitude spectrum. This means we pass it the number of bands we want (the actual FFT size is | ||
| 5 | + two times that size) and a float array with the same size. | ||
| 6 | + */ | ||
| 7 | + | ||
| 8 | + import processing.sound.*; | ||
| 9 | + | ||
| 10 | + Sound stream; | ||
| 11 | + SoundFile sample; | ||
| 12 | + FFT fft; | ||
| 13 | + | ||
| 14 | + int scale=1; | ||
| 15 | + int bands=512; | ||
| 16 | + float[] spec = new float[bands]; | ||
| 17 | + | ||
| 18 | + public void setup() { | ||
| 19 | + size(bands,350); | ||
| 20 | + background(255); | ||
| 21 | + | ||
| 22 | + // Create and start the sound renderer | ||
| 23 | + stream = new Sound(this, 44100, 256); | ||
| 24 | + | ||
| 25 | + //Load and play a soundfile and loop it. This has to be called | ||
| 26 | + // before the FFT is created. | ||
| 27 | + sample = new SoundFile(this, "beat.aiff"); | ||
| 28 | + sample.loop(); | ||
| 29 | + | ||
| 30 | + // Create and patch the rms tracker | ||
| 31 | + fft = new FFT(this); | ||
| 32 | + fft.input(sample, bands); | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + public void draw() { | ||
| 36 | + background(255); | ||
| 37 | + | ||
| 38 | + fft.process(spec); | ||
| 39 | + | ||
| 40 | + for(int i = 0; i < bands; i++) | ||
| 41 | + { | ||
| 42 | + // The result of the FFT is normalized | ||
| 43 | + // draw the line for frequency band i scaling it up by 5 to get more amplitude. | ||
| 44 | + line( i, height, i, height - spec[i]*height*5 ); | ||
| 45 | + } | ||
| 46 | + } | ||
| 47 | + | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,31 @@ | |||
| 1 | + /* | ||
| 2 | + This is a simple WhiteNoise generator. It can be started with .play(float amp). | ||
| 3 | + In this example it is started and stopped by clicking into the renderer window. | ||
| 4 | + */ | ||
| 5 | + | ||
| 6 | + import processing.sound.*; | ||
| 7 | + | ||
| 8 | + Sound stream; | ||
| 9 | + WhiteNoise noise; | ||
| 10 | + BPF bandPass; | ||
| 11 | + | ||
| 12 | + float amp=0.0; | ||
| 13 | + | ||
| 14 | + void setup() { | ||
| 15 | + size(350,350); | ||
| 16 | + background(255); | ||
| 17 | + | ||
| 18 | + // Create and start the sound renderer and the noise generator | ||
| 19 | + stream = new Sound(this); | ||
| 20 | + noise = new WhiteNoise(this); | ||
| 21 | + bandPass = new BPF(this); | ||
| 22 | + noise.play(0.5); | ||
| 23 | + bandPass.play(noise, 100); | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + void draw() { | ||
| 27 | + | ||
| 28 | + bandPass.freq(map(mouseX, 0, 350, 20, 10000)); | ||
| 29 | + | ||
| 30 | + bandPass.res(map(mouseY, 0, 350, 0.05, 1.0)); | ||
| 31 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,29 @@ | |||
| 1 | + /* | ||
| 2 | + This is a simple WhiteNoise generator. It can be started with .play(float amp). | ||
| 3 | + In this example it is started and stopped by clicking into the renderer window. | ||
| 4 | + */ | ||
| 5 | + | ||
| 6 | + import processing.sound.*; | ||
| 7 | + | ||
| 8 | + Sound stream; | ||
| 9 | + WhiteNoise noise; | ||
| 10 | + HPF highPass; | ||
| 11 | + | ||
| 12 | + float amp=0.0; | ||
| 13 | + | ||
| 14 | + void setup() { | ||
| 15 | + size(350,350); | ||
| 16 | + background(255); | ||
| 17 | + | ||
| 18 | + // Create and start the sound renderer and the noise generator | ||
| 19 | + stream = new Sound(this); | ||
| 20 | + noise = new WhiteNoise(this); | ||
| 21 | + highPass = new HPF(this); | ||
| 22 | + noise.play(0.5); | ||
| 23 | + highPass.play(noise, 100); | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + void draw() { | ||
| 27 | + | ||
| 28 | + highPass.freq(map(mouseX, 0, 350, 20, 10000)); | ||
| 29 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,30 @@ | |||
| 1 | + /* | ||
| 2 | + This is a simple WhiteNoise generator. It can be started with .play(float amp). | ||
| 3 | + In this example it is started and stopped by clicking into the renderer window. | ||
| 4 | + */ | ||
| 5 | + | ||
| 6 | + import processing.sound.*; | ||
| 7 | + | ||
| 8 | + Sound stream; | ||
| 9 | + WhiteNoise noise; | ||
| 10 | + LPF lowPass; | ||
| 11 | + | ||
| 12 | + | ||
| 13 | + float amp=0.0; | ||
| 14 | + | ||
| 15 | + void setup() { | ||
| 16 | + size(350,350); | ||
| 17 | + background(255); | ||
| 18 | + | ||
| 19 | + // Create and start the sound renderer and the noise generator | ||
| 20 | + stream = new Sound(this); | ||
| 21 | + noise = new WhiteNoise(this); | ||
| 22 | + lowPass = new LPF(this); | ||
| 23 | + noise.play(0.5); | ||
| 24 | + lowPass.play(noise, 100); | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + void draw() { | ||
| 28 | + | ||
| 29 | + lowPass.freq(map(mouseX, 0, 350, 20, 10000)); | ||
| 30 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments