sound
Class SoundUtils

java.lang.Object
  extended by sound.SoundUtils

public class SoundUtils
extends java.lang.Object

Created by IntelliJ IDEA. User: Douglas Lyon Date: Dec 20, 2004 Time: 6:06:44 PM Copyright DocJava, Inc.


Field Summary
static javax.sound.midi.MidiChannel[] channels
           
static boolean DEBUG
           
 
Constructor Summary
SoundUtils()
           
 
Method Summary
static double[] bandpassFilter(double[] d, int lowFreq, int highFreq, double squelch)
           
static void beep()
           
static javax.media.protocol.DataSource createDataSource(javax.media.Format format)
           
static void echo(double[] linearSamples)
           
static void echo(int numberOfEchos, double decay, double[] linearSamples)
           
static int freqToMidiPitch(double freq)
          Convert a frequency into a MIDI note pitch.
static void getAuFilePlayAndDisplay()
           
static int[] getBandpassedHarmonics(int[] frequencies, int lowFreq, int highFreq)
           
static javax.media.protocol.DataSource getCaptureDataSource(javax.media.format.VideoFormat vf)
           
static javax.media.protocol.DataSource getCaptureDataSource(javax.media.format.VideoFormat vf, javax.media.format.AudioFormat af)
           
static javax.media.CaptureDeviceInfo[] getCaptureDeviceList()
           
static javax.media.CaptureDeviceInfo[] getCaptureDevices()
           
static javax.media.CaptureDeviceInfo getDevice()
           
static javax.sound.sampled.LineListener getLineListener()
           
static javax.sound.midi.MidiDevice.Info getMidiDeviceInfo(java.lang.String strDeviceName, boolean forOutput)
           
static double getMidiFrequency(int midiNoteNumber)
           
static int[] getMidiNoteNumbers(int[] frequencies)
          Get only valid midi note numbers from an array of frequencies.
static int getMidiNumber(double freq)
           
static int[] getNoteClassesFromMidiNN(int[] nn)
           
static int getNoteClassFromMidiNN(int nn)
           
static javax.sound.sampled.SourceDataLine getSourceDataLine(javax.sound.sampled.AudioFormat defaultAudioFormat)
           
static javax.sound.sampled.AudioFormat getSupportedInputAudioFormat()
           
static javax.sound.midi.Synthesizer getSynthesizer()
           
static javax.sound.sampled.TargetDataLine getTargetDataLine(javax.sound.sampled.AudioFormat audioFormat)
           
static javax.sound.sampled.TargetDataLine getTargetDataLine(javax.sound.sampled.Mixer.Info mixerInfo, javax.sound.sampled.AudioFormat audioFormat, int nBufferSize)
           
static int[] getWholeNotesFromNoteClass(int[] noteClasses)
           
static void listDevicesAndExit(boolean forInput, boolean forOutput)
           
static void main(java.lang.String[] args)
           
static void noteOff(int nNoteNumber)
           
static void noteOn(int nNoteNumber)
           
static void noteOn(int nNoteNumber, int nVelocity)
           
static void play(int nn)
           
static void play(int[] ia, int dur)
           
static void play(int[] ia, int vel, int dur)
           
static void play(int nn, int dur)
           
static void play(int nn, int vel, int dur)
           
static void play(javax.sound.midi.Synthesizer synth, int nNoteNumber, int nVelocity, int nDuration)
           
static void playNote(int nNoteNumber, int nVelocity, int nDuration)
           
static void playSound()
           
static void playSound(java.net.URL f)
           
static void playThread(int[] ia, int vel, int dur)
           
static void playWaveFile(java.io.File readFile)
           
static void printSupportedLines()
           
static void processData(ByteProcessor bp, javax.sound.sampled.AudioFormat audioFormat)
           
static void processData(ShortProcessor sp)
           
static void setCaptureFormat(javax.media.protocol.CaptureDevice cdev, javax.media.Format format)
           
static void setInstrumentGui()
           
static void showInfoDialog()
           
static void sleep(int nDuration)
           
static void testPlay()
           
static void testPlayClip()
           
static void testRecorder()
           
static int[] transpose(int[] ia, int bias)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

channels

public static javax.sound.midi.MidiChannel[] channels

DEBUG

public static boolean DEBUG
Constructor Detail

SoundUtils

public SoundUtils()
Method Detail

getLineListener

public static javax.sound.sampled.LineListener getLineListener()

getAuFilePlayAndDisplay

public static void getAuFilePlayAndDisplay()

showInfoDialog

public static void showInfoDialog()

play

public static void play(int[] ia,
                        int vel,
                        int dur)

play

public static void play(int nn)

play

public static void play(int nn,
                        int dur)

play

public static void play(int nn,
                        int vel,
                        int dur)

playThread

public static void playThread(int[] ia,
                              int vel,
                              int dur)

play

public static void play(int[] ia,
                        int dur)

transpose

public static int[] transpose(int[] ia,
                              int bias)

getSynthesizer

public static javax.sound.midi.Synthesizer getSynthesizer()

echo

public static void echo(double[] linearSamples)

echo

public static void echo(int numberOfEchos,
                        double decay,
                        double[] linearSamples)

play

public static void play(javax.sound.midi.Synthesizer synth,
                        int nNoteNumber,
                        int nVelocity,
                        int nDuration)

noteOff

public static void noteOff(int nNoteNumber)

noteOn

public static void noteOn(int nNoteNumber)

noteOn

public static void noteOn(int nNoteNumber,
                          int nVelocity)

sleep

public static void sleep(int nDuration)

getTargetDataLine

public static javax.sound.sampled.TargetDataLine getTargetDataLine(javax.sound.sampled.AudioFormat audioFormat)
                                                            throws javax.sound.sampled.LineUnavailableException
Throws:
javax.sound.sampled.LineUnavailableException

getTargetDataLine

public static javax.sound.sampled.TargetDataLine getTargetDataLine(javax.sound.sampled.Mixer.Info mixerInfo,
                                                                   javax.sound.sampled.AudioFormat audioFormat,
                                                                   int nBufferSize)
                                                            throws javax.sound.sampled.LineUnavailableException
Throws:
javax.sound.sampled.LineUnavailableException

playSound

public static void playSound(java.net.URL f)

playSound

public static void playSound()

testPlay

public static void testPlay()

testPlayClip

public static void testPlayClip()

getCaptureDataSource

public static javax.media.protocol.DataSource getCaptureDataSource(javax.media.format.VideoFormat vf,
                                                                   javax.media.format.AudioFormat af)

getCaptureDataSource

public static javax.media.protocol.DataSource getCaptureDataSource(javax.media.format.VideoFormat vf)

getDevice

public static javax.media.CaptureDeviceInfo getDevice()

getMidiFrequency

public static double getMidiFrequency(int midiNoteNumber)

freqToMidiPitch

public static int freqToMidiPitch(double freq)
Convert a frequency into a MIDI note pitch. Assumes A440 and equal tempered intonation. Adapted from C code written by Andrew Botros.

Parameters:
freq - The frequency value to convert.
Returns:
int The MIDI pitch number closest to the input frequency.

getMidiNumber

public static int getMidiNumber(double freq)

getCaptureDeviceList

public static javax.media.CaptureDeviceInfo[] getCaptureDeviceList()

createDataSource

public static javax.media.protocol.DataSource createDataSource(javax.media.Format format)

setCaptureFormat

public static void setCaptureFormat(javax.media.protocol.CaptureDevice cdev,
                                    javax.media.Format format)

testRecorder

public static void testRecorder()

playNote

public static void playNote(int nNoteNumber,
                            int nVelocity,
                            int nDuration)
Parameters:
nNoteNumber - 0..127
nVelocity - 0..127
nDuration - in ms

listDevicesAndExit

public static void listDevicesAndExit(boolean forInput,
                                      boolean forOutput)
                               throws javax.sound.sampled.LineUnavailableException
Throws:
javax.sound.sampled.LineUnavailableException

getCaptureDevices

public static javax.media.CaptureDeviceInfo[] getCaptureDevices()

getMidiDeviceInfo

public static javax.sound.midi.MidiDevice.Info getMidiDeviceInfo(java.lang.String strDeviceName,
                                                                 boolean forOutput)

playWaveFile

public static void playWaveFile(java.io.File readFile)

printSupportedLines

public static void printSupportedLines()

getSourceDataLine

public static javax.sound.sampled.SourceDataLine getSourceDataLine(javax.sound.sampled.AudioFormat defaultAudioFormat)

processData

public static void processData(ShortProcessor sp)
                        throws javax.sound.sampled.LineUnavailableException
Throws:
javax.sound.sampled.LineUnavailableException

processData

public static void processData(ByteProcessor bp,
                               javax.sound.sampled.AudioFormat audioFormat)
                        throws javax.sound.sampled.LineUnavailableException
Throws:
javax.sound.sampled.LineUnavailableException

setInstrumentGui

public static void setInstrumentGui()

beep

public static void beep()

getSupportedInputAudioFormat

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

main

public static void main(java.lang.String[] args)
                 throws javax.sound.sampled.LineUnavailableException,
                        java.lang.InterruptedException
Throws:
javax.sound.sampled.LineUnavailableException
java.lang.InterruptedException

getMidiNoteNumbers

public static int[] getMidiNoteNumbers(int[] frequencies)
Get only valid midi note numbers from an array of frequencies.

Parameters:
frequencies -
Returns:

getNoteClassesFromMidiNN

public static int[] getNoteClassesFromMidiNN(int[] nn)

getBandpassedHarmonics

public static int[] getBandpassedHarmonics(int[] frequencies,
                                           int lowFreq,
                                           int highFreq)

getWholeNotesFromNoteClass

public static int[] getWholeNotesFromNoteClass(int[] noteClasses)

getNoteClassFromMidiNN

public static int getNoteClassFromMidiNN(int nn)

bandpassFilter

public static double[] bandpassFilter(double[] d,
                                      int lowFreq,
                                      int highFreq,
                                      double squelch)