sound
Class Oscillator

java.lang.Object
  extended by sound.Oscillator

public class Oscillator
extends java.lang.Object


Constructor Summary
Oscillator(double frequency, int length)
           
 
Method Summary
 double actualFrequency()
           
static double[] add(double[] a, double[] b)
           
static void asynchronousToneTest()
           
static void beep()
          Plays the system beep.
 void debug()
           
 double[] getAM(double[] sourceSignal)
           
static javax.sound.sampled.AudioFormat getAudioFormat()
           
 double[] getCosineWave()
           
 double getDuration()
           
 double[] getFM()
           
 double[] getFM(double modulationIndex)
           
 double getFrequency()
           
 double[] getRandomWave()
           
 int getSampleRate()
           
 double[] getSawWave()
           
 double[] getSineWave()
           
static double[] getSineWave(int frequency1, int frequency2, long duration)
          Get a tone.
 double[] getSquareWave()
           
 double[] getTriangleWave()
           
static void main(java.lang.String[] arg)
           
static void mix(double[] a, double[] b)
          a = (a + b)/2

A and b are vectors of the same length.

static void mix(double[] a, double[] b, double[] c)
          a = (a + b + c)/3

A, b and c are vectors of the same length.

static double[] mult(double[] d, double a)
           
static void playAndDisplayTone(int frequency)
           
static void playAtonalComposition(double[] durations, double[] frequencies)
           
static void playFmTone(int freq, int durationInMs, double modulationIndex)
           
static void playInputStream(java.io.InputStream bis)
           
static void playLinearData(double[] d)
           
static void playTone(int frequency)
           
static void playTone(int f, int numberOfSamples)
           
 void setModulationFrequency(double fm)
           
 void setModulationIndex(double I)
           
 int sign(double d)
           
static void testAudioDft()
           
static void testAudioFft()
           
static void testPlayAndDisplayTone()
           
static void testPlayTone()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Oscillator

public Oscillator(double frequency,
                  int length)
Parameters:
frequency - is in hz
length - number of samples in the array.
Method Detail

beep

public static void beep()
Plays the system beep. I only put this here because I did not know where else to put it. After all, it uses the AWT tool kit, and how does that make any sense?


testPlayTone

public static void testPlayTone()

playTone

public static void playTone(int f,
                            int numberOfSamples)

asynchronousToneTest

public static void asynchronousToneTest()

testPlayAndDisplayTone

public static void testPlayAndDisplayTone()

playAndDisplayTone

public static void playAndDisplayTone(int frequency)

playTone

public static void playTone(int frequency)

actualFrequency

public double actualFrequency()

debug

public void debug()

getCosineWave

public double[] getCosineWave()

getSineWave

public double[] getSineWave()

getRandomWave

public double[] getRandomWave()
Returns:
noise at 0.98 amplitude

getSineWave

public static double[] getSineWave(int frequency1,
                                   int frequency2,
                                   long duration)
Get a tone.

Parameters:
frequency1 - the first tone
frequency2 - the second tone
duration - the duration, in ms
Returns:
an array that ranges from -1 to 1

getSquareWave

public double[] getSquareWave()

getSawWave

public double[] getSawWave()

getTriangleWave

public double[] getTriangleWave()

sign

public int sign(double d)

getDuration

public double getDuration()

getSampleRate

public int getSampleRate()

getFrequency

public double getFrequency()

setModulationIndex

public void setModulationIndex(double I)

setModulationFrequency

public void setModulationFrequency(double fm)

getFM

public double[] getFM()

getFM

public double[] getFM(double modulationIndex)

getAM

public double[] getAM(double[] sourceSignal)

testAudioFft

public static void testAudioFft()

testAudioDft

public static void testAudioDft()

mult

public static double[] mult(double[] d,
                            double a)

add

public static double[] add(double[] a,
                           double[] b)

playLinearData

public static void playLinearData(double[] d)
                           throws javax.sound.sampled.LineUnavailableException,
                                  java.io.IOException
Throws:
javax.sound.sampled.LineUnavailableException
java.io.IOException

playInputStream

public static void playInputStream(java.io.InputStream bis)
                            throws javax.sound.sampled.LineUnavailableException,
                                   java.io.IOException
Throws:
javax.sound.sampled.LineUnavailableException
java.io.IOException

getAudioFormat

public static javax.sound.sampled.AudioFormat getAudioFormat()

mix

public static void mix(double[] a,
                       double[] b)
a = (a + b)/2

A and b are vectors of the same length.

Parameters:
a - is vector changed by the invocation
b - is a vector that is added to a.

mix

public static void mix(double[] a,
                       double[] b,
                       double[] c)
a = (a + b + c)/3

A, b and c are vectors of the same length.

Parameters:
a - is vector changed by the invocation
b - is a vector that is added to a.
c - is a vector that is added to a.

playAtonalComposition

public static void playAtonalComposition(double[] durations,
                                         double[] frequencies)
                                  throws javax.sound.sampled.LineUnavailableException,
                                         java.io.IOException
Throws:
javax.sound.sampled.LineUnavailableException
java.io.IOException

playFmTone

public static void playFmTone(int freq,
                              int durationInMs,
                              double modulationIndex)
                       throws java.io.IOException,
                              javax.sound.sampled.LineUnavailableException
Throws:
java.io.IOException
javax.sound.sampled.LineUnavailableException

main

public static void main(java.lang.String[] arg)
                 throws java.io.IOException,
                        javax.sound.sampled.LineUnavailableException,
                        java.text.ParseException
Throws:
java.io.IOException
javax.sound.sampled.LineUnavailableException
java.text.ParseException