|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Canvas devs.musicpackage.SpectrumAnalyzer
public class SpectrumAnalyzer
A user interface component to display the sound pressure for a range of frequencies over time as produced by an audio data stream.
This is the second version of the spectrum analyzer component. It has significantly improved performance with the help of the KJ signal processor package by Kris Fudalewski. KJ signal processor synchronizes processed bytes with the audio output.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.awt.Canvas |
---|
java.awt.Canvas.AccessibleAWTCanvas |
Nested classes/interfaces inherited from class java.awt.Component |
---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary |
---|
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
SpectrumAnalyzer(int freqCount,
int expFftSize)
constructor |
Method Summary | |
---|---|
void |
decoded(com.lightdev.lib.audio.Player p,
byte[] buf,
int byteCount)
unused here |
void |
exception(com.lightdev.lib.audio.Player p,
java.lang.Exception ex)
unused here |
SpectrumAnalyzerListener |
getListener()
|
void |
paint(java.awt.Graphics g)
Paints this component. |
void |
process(float[] samples)
process a range of samples received from the KJ signal processor, i.e. |
void |
progress(com.lightdev.lib.audio.Player p,
long progressValue)
unused here |
void |
setListener(SpectrumAnalyzerListener listener)
|
void |
setSize(java.awt.Dimension d)
set the size of this component |
void |
setSize(int w,
int h)
set the size of this component |
void |
stateChanged(com.lightdev.lib.audio.Player p,
int fromStatus,
int toStatus)
take stateChanged messages from the audio player as a trigger to start and stop the spectrum analyzer |
Methods inherited from class java.awt.Canvas |
---|
addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy, update |
Methods inherited from class java.awt.Component |
---|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public SpectrumAnalyzer(int freqCount, int expFftSize)
freqCount
- int number of level meters to show for one channel (i.e. number of
frequencies to measure amplitudes for)expFftSize
- int the power of two to use to set the size of a fast fourier transform.
When expFftSize is 8 for instance the fft will be of size 2^8 = 256,
i.e. the fft will transform 256 values of the amplitude/time domain to
128 values of the amplitude/frequency domain.Method Detail |
---|
public void paint(java.awt.Graphics g)
paint
in class java.awt.Canvas
g
- the graphics context to use for paintingpublic void setSize(java.awt.Dimension d)
setSize
in class java.awt.Component
d
- Dimension the new sizepublic void setSize(int w, int h)
setSize
in class java.awt.Component
w
- int the widthh
- int the heightpublic void stateChanged(com.lightdev.lib.audio.Player p, int fromStatus, int toStatus)
stateChanged
in interface com.lightdev.lib.audio.PlayerListener
p
- Player the player whose status changedfromStatus
- int the status changed fromtoStatus
- int the status changed topublic void progress(com.lightdev.lib.audio.Player p, long progressValue)
progress
in interface com.lightdev.lib.audio.PlayerListener
p
- Player the player that fired the eventprogressValue
- long the microseconds played so farpublic void exception(com.lightdev.lib.audio.Player p, java.lang.Exception ex)
exception
in interface com.lightdev.lib.audio.PlayerListener
p
- Player the player that fired the eventex
- Exception the exception that occurredpublic void decoded(com.lightdev.lib.audio.Player p, byte[] buf, int byteCount)
decoded
in interface com.lightdev.lib.audio.PlayerListener
p
- Player the player that fired the eventbuf
- byte[] the decoded bytesbyteCount
- int the number of bytes in bufpublic void process(float[] samples)
process
in interface kj.dsp.KJDigitalSignalProcessor
samples
- float[] the samples to processpublic SpectrumAnalyzerListener getListener()
public void setListener(SpectrumAnalyzerListener listener)
listener
- The listener to set.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |