Package ca.corbett.extras.audio
Class WaveformConfig
java.lang.Object
ca.corbett.extras.properties.AbstractProperty
ca.corbett.extras.audio.WaveformConfig
Represents a preferences object that can be used with AudioUtil.generateWaveform().
- Since:
- 2018-01-03
- Author:
- scorbo2
-
Field Summary
Fields inherited from class ca.corbett.extras.properties.AbstractProperty
categoryName, DEFAULT_CATEGORY, DEFAULT_PROPERTY_NAME, extraAttributes, fullyQualifiedName, helpText, isEnabled, isExposed, isInitiallyEditable, isInitiallyVisible, propertyLabel, propertyName, subCategoryName -
Constructor Summary
ConstructorsConstructorDescriptionWaveformConfig(String fullyQualifiedName) Creates a WaveFormPreferences instance with all defaulted values: White background Black outline Light grey fill Dark grey baseline Outline line thickness of 1 Horizontal scale of 1/1024 Vertical scale of 1/64 Top half of waveform will be channel 0 Bottom half will be channel 1 (or mirror of channel 0 if single channel). -
Method Summary
Modifier and TypeMethodDescriptionstatic WaveformConfigclonePreferences(WaveformConfig other) Returns a clone of the given WaveformConfig instance.protected FormFieldDescendant classes must implement this method to generate a FormField associated with this property.Returns the current baseline colour - this is the colour for the center line of the waveform.intReturns the pixel width for the baseline, if it is enabled.Returns the current background colour - this is the colour for the area of the image behind the waveform.intReturns the channel inde that will be used for the bottom half of the waveform.Returns the current fill colour - this is the colour that will be used to fill the waveform.Returns the current outline colour - this is the colour of the line to be drawn on the outline of the waveform.intReturns the thickness of the outline.intReturns the channel index that will be used for the top half of the waveform.booleanReturns whether the drawing of a baseline at the center of the waveform is enabled.booleanReturns whether the drawing of an outline around the waveform is enabled.voidloadFromFormField(FormField field) Populates this Property's value(s) from the given form field, assuming the field is of the correct type.voidloadFromProps(Properties props) Loads the value(s) for this property from the given Properties instance, overwriting any current value.voidsaveToProps(Properties props) Saves the current value(s) of this property to the given Properties instance.voidsetBaselineColor(Color baselineColor) Sets the colour to use to draw the horizontal center line.voidsetBaselineEnabled(boolean enable) Enables or disables the drawing of the baseline at the center of the waveform.voidsetBaselineThickness(int width) Sets the pixel thickness of the baseline, if it is enabled.voidsetBgColor(Color bgColor) Sets the colour to use for the background behind the waveform.voidsetBottomChannelIndex(int bottomChannelIndex) Sets the index of the audio channel to use for the bottom half of the waveform.voidsetCompression(WaveformConfigField.Compression compression) voidsetFillColor(Color fillColor) Sets the colour to use to fill the waveform.voidsetOutlineColor(Color outlineColor) Sets the colour to use to outline the waveform.voidsetOutlineEnabled(boolean enable) Enables or disables the drawing of an outline around the waveform.voidsetOutlineThickness(int thickness) Sets the line thickness to use for the outline of the waveform.voidsetTopChannelIndex(int topChannelIndex) Sets the index of the audio channel to use for the top half of the waveform.voidMethods inherited from class ca.corbett.extras.properties.AbstractProperty
addAllExtraAttributes, addFormFieldChangeListener, clearExtraAttribute, clearExtraAttributes, equals, fireFormFieldChangedEvent, generateFormField, generateFormField, getCategoryName, getExtraAttribute, getFullyQualifiedName, getHelpText, getPropertyLabel, getPropertyName, getSubCategoryName, hashCode, isEnabled, isExposed, isInitiallyEditable, isInitiallyVisible, removeAllListeners, removeFormFieldChangeListener, setAllExtraAttributes, setEnabled, setExposed, setExtraAttribute, setHelpText, setInitiallyEditable, setInitiallyVisible, setPropertyLabel
-
Constructor Details
-
WaveformConfig
public WaveformConfig() -
WaveformConfig
Creates a WaveFormPreferences instance with all defaulted values:- White background
- Black outline
- Light grey fill
- Dark grey baseline
- Outline line thickness of 1
- Horizontal scale of 1/1024
- Vertical scale of 1/64
- Top half of waveform will be channel 0
- Bottom half will be channel 1 (or mirror of channel 0 if single channel).
-
-
Method Details
-
clonePreferences
Returns a clone of the given WaveformConfig instance. If you pass in null, you will receive a WaveformConfig instance with all default values, the same as if you had used new WaveformConfig() instead.- Parameters:
other- The WaveformConfig instance from which to copy. May be null.- Returns:
- A clone of the given WaveformConfig, or a defaulted WaveformConfig.
-
setOutlineEnabled
public void setOutlineEnabled(boolean enable) Enables or disables the drawing of an outline around the waveform. If enabled, you should also call setOutlineColor() to choose a colour for the outline. You may also call setOutlineThickness() to set the pixel width of the outline.- Parameters:
enable- Whether to enable or disable the outline.
-
isOutlineEnabled
public boolean isOutlineEnabled()Returns whether the drawing of an outline around the waveform is enabled. See also the getOutlineColor() and getOutlineThickness() methods.- Returns:
- Whether an outline will be drawn around the waveform.
-
getOutlineColor
Returns the current outline colour - this is the colour of the line to be drawn on the outline of the waveform.- Returns:
- The outline colour.
-
getFillColor
Returns the current fill colour - this is the colour that will be used to fill the waveform.- Returns:
- The fill colour.
-
getBgColor
Returns the current background colour - this is the colour for the area of the image behind the waveform.- Returns:
- The background color.
-
setBaselineEnabled
public void setBaselineEnabled(boolean enable) Enables or disables the drawing of the baseline at the center of the waveform. If enabled, you should also call setBaselineColor() to choose a colour for the baseline. You may also call setBaselineThickness() to set the pixel width of the outline.- Parameters:
enable- Whether to enable or disable the baseline.
-
isBaselineEnabled
public boolean isBaselineEnabled()Returns whether the drawing of a baseline at the center of the waveform is enabled. See also the getBaselineColor() and getBaselineThickness() methods.- Returns:
- Whether a baseline will be drawn at the center of the waveform.
-
setBaselineThickness
public void setBaselineThickness(int width) Sets the pixel thickness of the baseline, if it is enabled.- Parameters:
width- The number of pixels wide for drawing the baseline.
-
getBaselineThickness
public int getBaselineThickness()Returns the pixel width for the baseline, if it is enabled.- Returns:
- the number of pixels thick for the baseline.
-
getBaselineColor
Returns the current baseline colour - this is the colour for the center line of the waveform. Set it to the same as fillColor to disable the baseline.- Returns:
- The baseline color.
-
getOutlineThickness
public int getOutlineThickness()Returns the thickness of the outline. Default is 1 pixel.- Returns:
- The pixel width of the line to use to outline the waveform.
-
getTopChannelIndex
public int getTopChannelIndex()Returns the channel index that will be used for the top half of the waveform.- Returns:
- The index of the channel for the top half of the waveform.
-
getBottomChannelIndex
public int getBottomChannelIndex()Returns the channel inde that will be used for the bottom half of the waveform. If this is the same index as topChannelIndex, the waveform will be a mirror.- Returns:
- The index of the channel for the bottom half of the waveform.
-
getCompression
-
setCompression
-
getWidthLimit
-
setWidthLimit
-
setOutlineColor
Sets the colour to use to outline the waveform. Set this to the same as fillColor or bgColor to disable the outline.- Parameters:
outlineColor- The colour to use to outline the waveform.
-
setFillColor
Sets the colour to use to fill the waveform. Set this to the same as bgColor to disable the fill.- Parameters:
fillColor- The colour to use to fill the waveform.
-
setBaselineColor
Sets the colour to use to draw the horizontal center line. Set this to the same as fillColor to disable the baseline.- Parameters:
baselineColor- The colour for the horizontal center line.
-
setOutlineThickness
public void setOutlineThickness(int thickness) Sets the line thickness to use for the outline of the waveform. Set this to 0 to disable the outline. Values less than 0 or greater than 10 are ignored.- Parameters:
thickness- The pixel width of the line that outlines the waveform.
-
setBgColor
Sets the colour to use for the background behind the waveform.- Parameters:
bgColor- The colour to use for the background.
-
setTopChannelIndex
public void setTopChannelIndex(int topChannelIndex) Sets the index of the audio channel to use for the top half of the waveform. This defaults to 0 and generally shouldn't be changed unless you're doing something unusual. Values will be clipped as needed - for example, if this value is less than 0, or greater than the highest available channel index, it is clipped to be within that range.- Parameters:
topChannelIndex- The index of the audio channel for the top half of the waveform.
-
setBottomChannelIndex
public void setBottomChannelIndex(int bottomChannelIndex) Sets the index of the audio channel to use for the bottom half of the waveform. This defafults to 1 and generally shouldn't be changed unless you're doing something unusual. Values will be clipped as needed - for example, if this value is less than 0, or greater than the highest available channel index, it is clipped to be within that range. Set this to the same as topChannelIndex if you want a mirror waveform (this will happen automatically in the case of mono audio input).- Parameters:
bottomChannelIndex- The index of the audio channel for the bottom half of the waveform.
-
saveToProps
Description copied from class:AbstractPropertySaves the current value(s) of this property to the given Properties instance.- Specified by:
saveToPropsin classAbstractProperty- Parameters:
props- Any Properties instance which will receive the value(s) of this property.
-
loadFromProps
Description copied from class:AbstractPropertyLoads the value(s) for this property from the given Properties instance, overwriting any current value. The current value of this property will be used as a default value in the event that this property does not exist in the given Properties instance.- Specified by:
loadFromPropsin classAbstractProperty- Parameters:
props- Any Properties instance which contains value(s) for this property.
-
generateFormFieldImpl
Description copied from class:AbstractPropertyDescendant classes must implement this method to generate a FormField associated with this property. The generateFormField() method in this class will call this abstract method to create the FormField, which will then be augmented with our fully qualified name, read-only state, help text, and extra attributes.- Specified by:
generateFormFieldImplin classAbstractProperty- Returns:
- A FormField associated with this property.
-
loadFromFormField
Description copied from class:AbstractPropertyPopulates this Property's value(s) from the given form field, assuming the field is of the correct type.- Specified by:
loadFromFormFieldin classAbstractProperty- Parameters:
field- The FormField containing a value for this property.
-