Skip to content

Commit

Permalink
Add some header comments
Browse files Browse the repository at this point in the history
  • Loading branch information
hirthy committed Mar 29, 2011
1 parent 1e9a2b2 commit 8255674
Show file tree
Hide file tree
Showing 12 changed files with 80 additions and 87 deletions.
10 changes: 5 additions & 5 deletions src/Cuomo.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
* Cuomo instrument class. Uses Sine and Square Instruments to create
* a sound similar to a synth lead. Uses no envelopes.
* @author Mike Hirth
*
*/
* Cuomo instrument class. Uses Sine and Square Instruments to create
* a sound similar to a synth lead. Uses no envelopes.
* @author Mike Hirth
*
*/

import java.util.*;
import com.softsynth.jsyn.*;
Expand Down
37 changes: 18 additions & 19 deletions src/Instrument.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@

/**
* Abstract class for instruments. Contains data for harmonics, oscillators, LFOs,
* envelopes and scopes.
*
* @author theChillwavves
*
*/

import java.util.*;

Expand All @@ -10,14 +16,6 @@
import com.softsynth.jsyn.*;
import com.softsynth.jsyn.view102.SynthScope;



/**
* Abstract class Instrument - write a description of the class here
*
* @author (your name here)
* @version (version number or date here)
*/
public abstract class Instrument
{
protected boolean isPlaying;
Expand Down Expand Up @@ -54,7 +52,7 @@ public abstract class Instrument
public double LAG_LIFE = 0; //lag between freqs (used after LFO creation) (0-10)

//state variables?
private boolean LFO_INIT = false; //we don't prolly need these
private boolean LFO_INIT = false;
private boolean LFO_ENABLED = false;


Expand All @@ -69,13 +67,17 @@ public Instrument() { //constructor needs: scale, freq, amp?
abstract void stop();
abstract void makeTimbre();
abstract void adjustFrequencyByOffset(int offset);


public int[] addHarmonics(int[] firstHarmonics, int[] secondHarmonics) {
int[] newHarmonics = new int[firstHarmonics.length + secondHarmonics.length];
System.arraycopy(secondHarmonics, 0, newHarmonics, 0, secondHarmonics.length);
System.arraycopy(firstHarmonics, 0, newHarmonics, secondHarmonics.length, firstHarmonics.length);
return newHarmonics;
}
/*
* Adds two arrays of harmonics together by copying. Appends and does not sort
*/
public int[] addHarmonics(int[] firstHarmonics, int[] secondHarmonics) {
int[] newHarmonics = new int[firstHarmonics.length + secondHarmonics.length];
System.arraycopy(secondHarmonics, 0, newHarmonics, 0, secondHarmonics.length);
System.arraycopy(firstHarmonics, 0, newHarmonics, secondHarmonics.length, firstHarmonics.length);
return newHarmonics;
}

public void makeLFOs(boolean enable)
{
Expand All @@ -95,9 +97,6 @@ public void setEnvelopeData(SynthEnvelope envData)
{
customEnvelope = true;
this.envData = envData;
// envPlayer.envelopePort.clear(); // clear the queue
// envPlayer.envelopePort.queueLoop(envData ); // queue an envelope

}

public void enableLFOs()
Expand Down
12 changes: 1 addition & 11 deletions src/InstrumentController.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
//
// Controls an instrument based on trackpad movement.
// This should probably be modified to control multiple instruments

import java.util.ArrayList;

import com.softsynth.jsyn.*;
Expand Down Expand Up @@ -264,18 +260,13 @@ public void changeFrequency(int offset)
CURRENT_INSTRUMENT.adjustFrequencyByOffset(offset);
}

public void changeAmplitude()
{
}

public void lowpass(int freq)
{
filter.frequency.set(freq);
}

public void pan(double absolutePan)
{
//System.out.println(absolutePan);
panUnit.pan.set(absolutePan);
}

Expand All @@ -297,8 +288,7 @@ public void makeSauce()

public void iThinkItsTheSauceBoss()
{
streamer.startStream();

streamer.startStream();
}

}
Expand Down
36 changes: 10 additions & 26 deletions src/KaossTest.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
/*
* A test for the basic idea behind our Kaoss Emulator. This class will see substantial changes.
*
* TODO:
* This should be an instrument controller and observe trackpad changes.
* Multiple instrument support
* User input mode:
* -how to select instruments, etc (independent fingers / single finger)
/**
* Main class for the application. Creates an instrument controller
* and observers for input.
*
* Decide on axis effects (envelope, panning, EQ?)
* @author theChillwavves
*
*/

import com.softsynth.jsyn.*;
Expand Down Expand Up @@ -56,22 +52,18 @@ public class KaossTest implements Observer {
public final static int INSTRUMENT_MESSIER = 8;
public final static int INSTRUMENT_GONG = 9;
public final static int INSTRUMENT_SQUOISE = 0;
public final static int LOWPASS_MAX = 2000;
public final static int MOD_RATE_MAX = 20;
public final static int MOD_DEPTH_MAX = 1000;
public final static int LOWPASS_MAX = 2000;
public final static int MOD_RATE_MAX = 20;
public final static int MOD_DEPTH_MAX = 1000;

public final static int INSTRUMENT_DEFAULT = INSTRUMENT_SINE;


//most of these are sucky. but we are using some for now
public static Color darkBrownTest = new Color(166, 65, 8);
public static Color lightBrownTest = new Color(242, 204, 133);
public static Color darkGreenTest = new Color(37,89,59);
public static Color lightGreenTest = new Color(100, 126, 41);
public static Color brownTest = new Color(223,167,73);

// public static SynthContext context = new SynthContext(); //we should prob implement this

public KaossTest()
{
//start synth & instruments
Expand Down Expand Up @@ -140,7 +132,7 @@ public void update( Observable obj, Object arg ) {
Finger f = (Finger) arg;
updateViaFinger(f);
} else {
//degrade to mouse position on screen. this sucks but it's a quick and stable alternative
//degrade to mouse position on screen.
updateViaMouse((Dimension)arg);
}

Expand Down Expand Up @@ -173,9 +165,6 @@ public void updateViaFinger(Finger f)
if(dy < lDy) lDy = dy;
if(dy > hDy) hDy = dy;

//System.out.println(lDx + " , " +hDx + " / " + lDy + " " + hDy);
//-13.950837 , 17.629349 / -15.644904 20.096266

//mark on / off
if(! fingersPressed.contains(id)) { //finger pressed.
//we were not tracking this finger. so let's add it to the queue.
Expand All @@ -198,11 +187,8 @@ public void updateViaFinger(Finger f)

updateViaAccelerometer();

//boolean fingerIsController = fingersPressed.getFirst().equals(id);
//if(! fingerIsController) return; //only use control finger for points

int whichFinger = fingersPressed.indexOf(id) + 1;
//System.out.println(whichFinger);

//depends on nth finger
switch(whichFinger)
{
Expand All @@ -216,8 +202,6 @@ public void updateViaFinger(Finger f)
updateModRate((int)(x*MOD_RATE_MAX));
updateModDepth((int)(y*MOD_DEPTH_MAX)); //this is cool except it is rarely zero
break;
//default:


}

Expand Down
10 changes: 5 additions & 5 deletions src/Messier.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
* Messier instrument class. Uses Triangle and Noise Instruments to create
* a spacey sound. Uses an envelope with a short duration.
* @author Mike Hirth
*
*/
* Messier instrument class. Uses Triangle and Noise Instruments to create
* a spacey sound. Uses an envelope with a short duration.
* @author Mike Hirth
*
*/

import java.util.*;
import com.softsynth.jsyn.*;
Expand Down
6 changes: 6 additions & 0 deletions src/MouseObservable.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* Mouse observable class reads mouse input.
*
* @author theChillwavves
*/

import java.util.Observable;
import java.awt.*;

Expand Down
6 changes: 5 additions & 1 deletion src/MouseObserverThread.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* Thread for the mouse observer.
*
* @author theChillwavves
*/

public class MouseObserverThread extends Thread {
MouseObservable obs;
Expand All @@ -10,7 +15,6 @@ public MouseObserverThread(MouseObservable obs)
// This method is called when the thread runs
public void run() {
try { while(true) {
//System.out.println(obs);
obs.readMouse();
Thread.sleep(100);
} } catch (Exception e) {
Expand Down
12 changes: 9 additions & 3 deletions src/RedNoise.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
//
// Class to test the Mac Mulittouch API mixed with JSyn.
// Modifying some code shtuffs here
/*
* Red Noise instrument class. Creates gritty sounding noise similar to
* white noise. Uses noise oscillator from JSyn.
*
* http://www.softsynth.com/jsyn/docs/autodocs/com/softsynth/jsyn/RedNoise.html
*
* @author theChillwavves
*
*/

import java.util.*;
import com.softsynth.jsyn.*;
Expand Down
1 change: 0 additions & 1 deletion src/SampleFileStreamer.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Play a file by streaming off of disk.
* Output the synthesized data using SampleQueueOutputStream
Expand Down
9 changes: 6 additions & 3 deletions src/Sine.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
//
// Class to test the Mac Mulittouch API mixed with JSyn.
// Modifying some code shtuffs here
/*
* Sine instrument class. Creates a basic sine wave.
*
* @author theChillwavves
*
*/

import java.util.*;
import com.softsynth.jsyn.*;
Expand Down
18 changes: 8 additions & 10 deletions src/Square.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
//
// Class to test the Mac Mulittouch API mixed with JSyn.
// Modifying some code shtuffs here
/*
* Square instrument class. Uses odd harmonics to create a square wave.
*
* @author theChillwavves
*
*/

import java.util.*;
import com.softsynth.jsyn.*;
Expand All @@ -10,7 +13,6 @@
import java.awt.geom.Ellipse2D;
import java.awt.geom.AffineTransform;


import com.softsynth.jsyn.view102.SynthScope;

public class Square extends Instrument {
Expand Down Expand Up @@ -67,18 +69,14 @@ public void stop()
}

public void adjustFrequencyByOffset(int offset) {



//harmonic mode
int i = 0;
double scaleOffset = getScaleIntervalFromOffset(scale, offset);
int freq = (int)(Math.pow(2,((scaleOffset) / 12)) * BASE_FREQ);

for(SynthInput freqMod : freqMods)
{
//overtone offset
//double scaleOffset = getScaleIntervalFromOffset(scale, (int)inc + overtones[i]);

{
//harmonic offset
freqMod.set(freq * harmonics[i]);
i++;
Expand Down
10 changes: 7 additions & 3 deletions src/Triangle.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
//
// Class to test the Mac Mulittouch API mixed with JSyn.
// Modifying some code shtuffs here
/*
* Triangle instrument class. Creates a basic triangle wave
* using odd harmonics.
*
* @author theChillwavves
*
*/

import java.util.*;
import com.softsynth.jsyn.*;
Expand Down

0 comments on commit 8255674

Please sign in to comment.