Class AudioWorm

  • java.lang.Object
    • at.ofai.music.worm.AudioWorm


  • public class AudioWorm
    extends java.lang.Object
    AudioWorm is the class that does the hard work. The constructor initialises the audio objects which process the data. Each call to nextBlock() reads in a new block of data and sends it to the output device, as well as processing it and sending a new tempo estimate to the Worm object. If the output buffer is not too low, the the Worm object is asked to update its display and the audio processing sleeps for 75ms to allow this to happen.
    • Constructor Summary

      Constructors 
      Constructor and Description
      AudioWorm(Worm w) 
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      static double checkAudioFormats(javax.sound.sampled.AudioFormat out, javax.sound.sampled.AudioFormat in)
      Returns the relative difference |a-b| / ((a+b)/2) in sample rates, or 2.0 if the formats do not match in some other characteristic, or -1 if AudioFormat `out' allows all sampling rates; normal return value is in [0,2).
      protected void init(Worm w)
      Normal initialisation of AudioWorm for reading from a PCM file or for reading compressed data which is uncompressed by AudioSystem.
      protected void initSoundCardInput(Worm w) 
      boolean nextBlock() 
      void pause() 
      protected double processWindow()
      Reads a block of audio data, summing the channels and returning the normalised (in the range 0.0-1.0) RMS average of the sample values.
      protected void resetAudioFile() 
      static double rms(double[] data)
      Returns the RMS average of an array of double.
      protected void skipAudio()
      For input from an audio file, performs repositioning within the file, after a call to the public method skipTo().
      void skipTo(double time)
      Reposition the audio file input to a new point in seconds.
      void skipTo(int thousandths)
      Reposition the audio file input (from Scrollbar) on a scale of 0 (beginning of file) to 1000 (end of file).
      void start() 
      void stop() 
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AudioWorm

        public AudioWorm(Worm w)
    • Method Detail

      • resetAudioFile

        protected void resetAudioFile()
      • initSoundCardInput

        protected void initSoundCardInput(Worm w)
      • init

        protected void init(Worm w)
        Normal initialisation of AudioWorm for reading from a PCM file or for reading compressed data which is uncompressed by AudioSystem.
      • start

        public void start()
      • pause

        public void pause()
      • stop

        public void stop()
      • nextBlock

        public boolean nextBlock()
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • processWindow

        protected double processWindow()
                                throws java.io.IOException
        Reads a block of audio data, summing the channels and returning the normalised (in the range 0.0-1.0) RMS average of the sample values. Assumes sufficient data is queued, or else blocks while it waits for the buffer to fill sufficiently.
        Throws:
        java.io.IOException
      • checkAudioFormats

        public static double checkAudioFormats(javax.sound.sampled.AudioFormat out,
                                               javax.sound.sampled.AudioFormat in)
        Returns the relative difference |a-b| / ((a+b)/2) in sample rates, or 2.0 if the formats do not match in some other characteristic, or -1 if AudioFormat `out' allows all sampling rates; normal return value is in [0,2).
      • rms

        public static double rms(double[] data)
        Returns the RMS average of an array of double.
      • skipTo

        public void skipTo(double time)
        Reposition the audio file input to a new point in seconds.
      • skipTo

        public void skipTo(int thousandths)
        Reposition the audio file input (from Scrollbar) on a scale of 0 (beginning of file) to 1000 (end of file).
      • skipAudio

        protected void skipAudio()
        For input from an audio file, performs repositioning within the file, after a call to the public method skipTo().