public class AudioSpectrogram extends VisualisationImpl<float[]>
Modifier and Type | Class and Description |
---|---|
static interface |
AudioSpectrogram.SpectrogramCompleteListener
A listener for when the spectrogram has completed processing.
|
JPanel.AccessibleJPanel
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
clearBeforeDraw, data, visImage
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
AudioSpectrogram()
Create a spectrogram that can be added to as and when it's necessary.
|
AudioSpectrogram(int w,
int h)
Construct a visualisation of the given size
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(AudioSpectrogram.SpectrogramCompleteListener l)
Add the given listener
|
int |
getCurrentDrawPosition()
Get the position at which the next spectrum will be drawn.
|
Float[] |
getCurrentPositionLineColour()
Get the colour of the current position line
|
double[] |
getFrequencyBands()
Get the frequency bands which are being drawn in Hz.
|
boolean |
isComplete()
Returns whether the spectragram image is complete.
|
boolean |
isDrawCurrentPositionLine()
Returns whether the current position line is being drawn
|
boolean |
isDrawFreqBands()
Returns whether the frequency bands are being drawn.
|
void |
process(SampleChunk s)
Processes a single sample chunk: calculates the FFT, gets the magnitudes,
copies the format (if it's the first chunk), and then goes on to update the image.
|
void |
processStream(AudioStream as)
Process the entire stream (or as much data will fit into the
visualisation window).
|
void |
removeListener(AudioSpectrogram.SpectrogramCompleteListener l)
Remove the given listener
|
void |
setCurrentPositionLineColour(Float[] currentPositionLineColour)
Set the colour of the line which is showning the current draw position.
|
void |
setData(float[] data)
Set the data to be visualised.
|
void |
setData(SampleChunk sc)
Add the given sample chunk into the spectrogram.
|
void |
setDrawCurrentPositionLine(boolean drawCurrentPositionLine)
Set whether to draw the position at which the current spectra will be drawn
|
void |
setDrawFreqBands(boolean drawFreqBands)
Set whether to overlay the frequency bands onto the image.
|
void |
setFrequencyBands(double[] frequencyBands)
Set the frequency bands to overlay on the image in Hz.
|
void |
update()
Called to update the visualisation.
|
addOverlay, componentHidden, componentMoved, componentResized, componentShown, getRequiredSize, getVisualisationImage, isAllowResize, newVisualisationAvailable, paint, removeOverlay, setAllowResize, setClearBeforeDraw, setRequiredSize, showWindow, update, updateVis, updateVis
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public AudioSpectrogram()
public AudioSpectrogram(int w, int h)
w
- Width of the required visualisationh
- Height of the required visualisationpublic void addListener(AudioSpectrogram.SpectrogramCompleteListener l)
l
- The listenerpublic void removeListener(AudioSpectrogram.SpectrogramCompleteListener l)
l
- The listener to removepublic void processStream(AudioStream as)
data
field of this class.as
- The stream to processpublic void process(SampleChunk s)
s
- The sample chunk to processpublic void setData(float[] data)
setData
in interface Visualisation<float[]>
setData
in class VisualisationImpl<float[]>
data
- The data to be visualisedVisualisationImpl.setData(java.lang.Object)
public void setData(SampleChunk sc)
sc
- The sample chunk to add.public boolean isComplete()
public void update()
visImage
member to be available and of the correct size.
The method simply needs to draw the visualisation to this MBFImage
.
You should wrap any drawing code in a synchronized block, synchronized on
the visImage - this stops the image being repainted to the screen half way
through drawing.
Update is called from the paint() method so should ideally not force a repaint() as this will call a continuous repaint loop.
update
in class VisualisationImpl<float[]>
VisualisationImpl.update()
public boolean isDrawFreqBands()
public void setDrawFreqBands(boolean drawFreqBands)
drawFreqBands
- TRUE to draw the frequency bands; FALSE otherwisepublic double[] getFrequencyBands()
public void setFrequencyBands(double[] frequencyBands)
frequencyBands
- the frequency bands to drawpublic boolean isDrawCurrentPositionLine()
public void setDrawCurrentPositionLine(boolean drawCurrentPositionLine)
drawCurrentPositionLine
- TRUE to draw the current position linepublic Float[] getCurrentPositionLineColour()
public void setCurrentPositionLineColour(Float[] currentPositionLineColour)
currentPositionLineColour
- The colour of the current draw position.public int getCurrentDrawPosition()