com.icdif.audio.examples
Class ExampleRealTimePlot

java.lang.Object
  extended by com.icdif.audio.examples.ExampleRealTimePlot

public class ExampleRealTimePlot
extends java.lang.Object

A simple example on how to do real-time plotting. First all samples from an mp3 file are read in and plotted, 1024 samples per pixel. Next we open a new MP3Decoder and an AudioDevice and play back the music. While doing this we also set a marker in the plot that shows us the current position of the music playback. The marker position is calculated in pixels by measuring the elapsed time between the start of the playback and the current time. The elapsed time is then multiplied by the frequency divided by the sample window size (1024 samples in this case). This gives us the x-coordinate of the marker in the plot. After writting a sample window to the audio device and setting the marker we sleep for 20ms to give the Swing GUI thread time to repaint the plot with the updated marker position.

Author:
wanderer

Constructor Summary
ExampleRealTimePlot()
           
 
Method Summary
static void main(java.lang.String[] argv)
           
static float[] readInAllSamples(java.lang.String file)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExampleRealTimePlot

public ExampleRealTimePlot()
Method Detail

main

public static void main(java.lang.String[] argv)
                 throws java.io.FileNotFoundException,
                        java.lang.Exception
Throws:
java.io.FileNotFoundException
java.lang.Exception

readInAllSamples

public static float[] readInAllSamples(java.lang.String file)
                                throws java.io.FileNotFoundException,
                                       java.lang.Exception
Throws:
java.io.FileNotFoundException
java.lang.Exception