Permalink
Browse files

Merge pull request #3 from tildebyte/master

Update JBallDroppings Processing to Processing 2.x
  • Loading branch information...
2 parents 11c33d2 + d35bc7a commit 3553da4044e05bd24369a5067e47740cc41fa0b2 @jtnimoy committed Apr 18, 2014
Showing with 720 additions and 847 deletions.
  1. +41 −0 Processing/BumpyInstrument.pde
  2. +679 −847 Processing/JBallDroppings.pde
@@ -0,0 +1,41 @@
+class BumpyInstrument implements Instrument{
+ // create all variables that must be used throughout the class
+ Oscil toneOsc, envOsc;
+
+ // constructor for this instrument
+ BumpyInstrument(float pitch, float amplitude){
+ // create a wave for the amplitude envelope.
+ // The name of the method "gen7" is a reference to a genorator in Csound.
+ // This is a somewhat silly, but demonstrative wave. It rises from 0 to 1
+ // over 1/8th of the time, then goes to 0.25 over 1/8th of it's time, then
+ // drops to 0.15 over 1/128th of it's time, and then decays to 0
+ // for the rest of the time.
+ // Note that this envelope is of fixed shape regardless of duration.
+ Wavetable myEnv = WavetableGenerator.gen7(8192,
+ new float[] {0.00, 1.00, 0.25, 0.15, 0.00},
+ new int[] {1024, 1024, 64, 6080});
+
+ // create new instances of any UGen objects as necessary
+ // The tone is the first ten harmonics of a saw wave.
+ toneOsc = new Oscil(pitch, 1.0f, Waves.sawh(10));
+ envOsc = new Oscil(1.0f, amplitude, myEnv);
+
+ // patch everything up to the output
+ envOsc.patch(toneOsc.amplitude);
+ }
+
+ // every instrument must have a noteOn(float) method
+ void noteOn(float dur){
+ // the duration of the amplitude envelope is set to the length
+ // of the note
+ envOsc.setFrequency(1.0f/dur);
+ // the tone ascillator is patched directly to the output.
+ toneOsc.patch(out);
+ }
+
+ // every instrument must have a noteOff() method
+ void noteOff(){
+ // unpatch the tone oscillator when the note is over
+ toneOsc.unpatch(out);
+ }
+}
Oops, something went wrong.

0 comments on commit 3553da4

Please sign in to comment.