Package net.paulhertz.pixelaudio
Class WaveData
java.lang.Object
net.paulhertz.pixelaudio.WaveData
Data storage for WaveSynth operator data.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionfloatamplitudeintTODO animSteps is an external value from a WaveSynth and application context -- is there a better way to handle it?floatDC offset/bias to add to generated amplitude values, a new setting, default 0static intconvenience variable, 30 seconds of animation at 24 frames per second, also context dependentfloatfrequencybooleanruntime variable for mutingfloatfraction of TWO_PI in the range 0..1,floatnumber of times to cycle through TWO_PI over the duration of the animationfloatincrement to the phase for each step of animation = (cycles * TWO_PI)/(animation steps) Should be set when animation begins, otherwise is set to 0, unchanging.static final booleansupport for old JSON format where phase was already scaled by TWO_PI in the new format phase ranges over the open interval (0, 1), so we scale it by TWO_PI and store the result in phaseTwoPi, which tracks phase information.floatTWO_PI * phase, used internally to calculate wave valueintcolor associated with the wavetracking variable for mute, solo, etc. -
Constructor Summary
ConstructorsConstructorDescriptionWaveData()WaveData(float f, float a, float p, float dc, float cycles, int c) Constructor for WaveData when animation steps are not knownWaveData(float f, float a, float p, float dc, float cycles, int c, int steps) Preferred constructor for WaveDataWaveData(float f, float a, float p, float dc, float cycles, int c, int animSteps, boolean phaseScalesTwoPi) -
Method Summary
Modifier and TypeMethodDescriptionclone()static floatmapToPositivePhase(float value, float a, float b) Maps a value to a specified range (of a cyclic function) Explanation: 1.floatphaseAtFrame(int frame) floatrawPhaseAtFrame(int frame) floatscaledPhaseAtFrame(int frame) voidsetAmp(float a) voidsetAnimationSteps(int newSteps) voidsetCycles(float cycles) voidsetCycles(float cycles, int steps) voidsetDc(float newDc) voidsetFreq(float f) voidsetPhase(float p) voidsetPhase(float p, boolean phaseScalesTwoPi) voidsetWaveColor(int c) voidsetWaveState(WaveData.WaveState newWaveState) toString()voidupdateWaveData(float f, float a, float p, float cycles, int c, int steps) waveDataListCopy(ArrayList<WaveData> wdList) floatwaveValue(int frame, int pos, float mapInc) floatwaveValue(int frame, int pos, float freqShift, float mapInc) Experimenting with noise to change the wave forms.
-
Field Details
-
freq
public float freqfrequency -
amp
public float ampamplitude -
phase
public float phasefraction of TWO_PI in the range 0..1, -
phaseTwoPi
public float phaseTwoPiTWO_PI * phase, used internally to calculate wave value -
phaseCycles
public float phaseCyclesnumber of times to cycle through TWO_PI over the duration of the animation -
phaseInc
public float phaseIncincrement to the phase for each step of animation = (cycles * TWO_PI)/(animation steps) Should be set when animation begins, otherwise is set to 0, unchanging. -
dc
public float dcDC offset/bias to add to generated amplitude values, a new setting, default 0 -
waveColor
public int waveColorcolor associated with the wave -
isMuted
public boolean isMutedruntime variable for muting -
waveState
tracking variable for mute, solo, etc. -
animSteps
public int animStepsTODO animSteps is an external value from a WaveSynth and application context -- is there a better way to handle it? -
defaultAnimSteps
public static int defaultAnimStepsconvenience variable, 30 seconds of animation at 24 frames per second, also context dependent -
phaseScalesTwoPI
public static final boolean phaseScalesTwoPIsupport for old JSON format where phase was already scaled by TWO_PI in the new format phase ranges over the open interval (0, 1), so we scale it by TWO_PI and store the result in phaseTwoPi, which tracks phase information.- See Also:
-
-
Constructor Details
-
WaveData
public WaveData(float f, float a, float p, float dc, float cycles, int c, int animSteps, boolean phaseScalesTwoPi) -
WaveData
public WaveData(float f, float a, float p, float dc, float cycles, int c, int steps) Preferred constructor for WaveData- Parameters:
f- frequencya- amplitudep- phase, decimal fraction of TWO_PI, typically in the range [0..1]dc- DC component added to wave valuescycles- number of cyles over one animation periodc- color associated with this WaveData objectsteps- number of frames for animation
-
WaveData
public WaveData(float f, float a, float p, float dc, float cycles, int c) Constructor for WaveData when animation steps are not known- Parameters:
f- frequencya- amplitudep- phase, decimal fraction of TWO_PI, typically in the range [0..1]dc- DC component added to wave valuescycles- number of cyles over one animation periodc- color associated with this WaveData object
-
WaveData
public WaveData()
-
-
Method Details
-
updateWaveData
public void updateWaveData(float f, float a, float p, float cycles, int c, int steps) -
setFreq
public void setFreq(float f) -
setAmp
public void setAmp(float a) -
setPhase
public void setPhase(float p, boolean phaseScalesTwoPi) -
setPhase
public void setPhase(float p) -
setCycles
public void setCycles(float cycles, int steps) -
setCycles
public void setCycles(float cycles) -
setAnimationSteps
public void setAnimationSteps(int newSteps) -
setDc
public void setDc(float newDc) -
setWaveColor
public void setWaveColor(int c) -
setWaveState
-
waveValue
public float waveValue(int frame, int pos, float freqShift, float mapInc) Experimenting with noise to change the wave forms.- Parameters:
frame- current framepos- pixel/audio sample index on signal pathfreqShift- experiment with shifting frequencymapInc- the increment in phase over the image pixels, typically TWO_PI / image size- Returns:
- amplitude value of wave for frame and pos
-
waveValue
public float waveValue(int frame, int pos, float mapInc) - Parameters:
frame- current framepos- pixel/audio sample index on signal pathmapInc- the increment in phase over the image pixels, typically TWO_PI / image size- Returns:
- amplitude value of wave for frame and pos
-
rawPhaseAtFrame
public float rawPhaseAtFrame(int frame) -
phaseAtFrame
public float phaseAtFrame(int frame) -
scaledPhaseAtFrame
public float scaledPhaseAtFrame(int frame) -
mapToPositivePhase
public static float mapToPositivePhase(float value, float a, float b) Maps a value to a specified range (of a cyclic function) Explanation: 1. Subtract a: Translates the interval to [0,b−a)[0,b−a). 2. value % range: Reduces the value to (−range,range). 3. Adding range: Ensures the result is positive. 4. Final % range: Maps the result to [0,range)[0,range). 5. Adding a: Shifts the result back to the original interval [a,b).- Parameters:
value- float value to be mappeda- lower boundb- upper bound- Returns:
- value mapped to interval [a,b)
-
waveDataListCopy
-
clone
-
toString
-