Class GestureEventParams
All arrays (when present) are parallel arrays with the same cardinality n
matching the GestureSchedule.size() used to
generate them.
Design intent:
startIndicesis the primary "mapping result" (typically fromPixelAudioMapper).- Optional arrays (
pan,gain, andpitchRatio) overrideGestureGranularParamsdefaults per event. - Persist and reuse this object across re-triggers; refresh only the fields that depend on buffer/mapping.
Immutability note: By default, this class defensively copies arrays in GestureEventParams.Builder.build().
If you want to avoid copying for performance, call GestureEventParams.Builder.noCopy() and treat the provided
arrays as immutable thereafter.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA builder for creating instances of GestureEventParams. -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal float[]Optional per-event linear gain scalar; length equalsn, or null to useGestureGranularParams.gainLinear.final intNumber of events; must match the associated gesture schedule size.final float[]Optional per-event pan in [-1, 1]; length equalsn, or null to useGestureGranularParams.pan.final float[]Optional per-event pitch ratio greater than 0; length equalsn, or null to useGestureGranularParams.pitchRatio.final intOptional: a free-form identity marker for debugging/caching.final int[]Required per-event start indices into a mono source buffer; length equalsn.final intOptional user-managed version tag. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivatePrivate constructor; use Builder to create instances. -
Method Summary
Modifier and TypeMethodDescriptionstatic GestureEventParams.Builderbuilder(int n) Creates a builder for the given number of gesture events.private static floatclampPan(float p) floatgainAt(int i, float defaultGain) Returns the gain value for one event.static GestureEventParamsofStartIndices(int[] startIndices) Creates a parameter set with only the required start-index array.floatpanAt(int i, float defaultPan) Returns the pan value for one event.floatpitchAt(int i, float defaultPitch) Returns the pitch ratio for one event.toString()String representation of this object's settings and array lengths (not contents).withGain(float[] newGain) Returns a copy with an updated per-event gain array and all other fields preserved.withPan(float[] newPan) Returns a copy with an updated per-event pan array and all other fields preserved.withPitchRatio(float[] newPitchRatio) Returns a copy with an updated per-event pitch-ratio array and all other fields preserved.withStartIndices(int[] newStartIndices) Returns a copy with updated start indices and all other fields preserved.
-
Field Details
-
n
public final int nNumber of events; must match the associated gesture schedule size. -
startIndices
public final int[] startIndicesRequired per-event start indices into a mono source buffer; length equalsn. -
pan
public final float[] panOptional per-event pan in [-1, 1]; length equalsn, or null to useGestureGranularParams.pan. -
gain
public final float[] gainOptional per-event linear gain scalar; length equalsn, or null to useGestureGranularParams.gainLinear. -
pitchRatio
public final float[] pitchRatioOptional per-event pitch ratio greater than 0; length equalsn, or null to useGestureGranularParams.pitchRatio. -
version
public final int versionOptional user-managed version tag. Handy for invalidation/caching in app code. (e.g., mapperVersion, bufferRotationVersion, etc.) -
scheduleId
public final int scheduleIdOptional: a free-form identity marker for debugging/caching. Example: System.identityHashCode(schedule), or a stable schedule id in your app.
-
-
Constructor Details
-
GestureEventParams
Private constructor; use Builder to create instances.- Parameters:
b- a GestureEventParams.Builder instance
-
-
Method Details
-
builder
Creates a builder for the given number of gesture events.- Parameters:
n- the number of schedule events this parameter set will describe- Returns:
- a new builder
- Throws:
IllegalArgumentException- ifn < 1
-
ofStartIndices
Creates a parameter set with only the required start-index array.- Parameters:
startIndices- per-event start indices into the mono source buffer- Returns:
- a new parameter set whose
nequalsstartIndices.length - Throws:
NullPointerException- ifstartIndicesis null
-
withStartIndices
Returns a copy with updated start indices and all other fields preserved.- Parameters:
newStartIndices- replacement per-event start indices; length must equaln- Returns:
- a new parameter set with the supplied start indices
- Throws:
NullPointerException- ifnewStartIndicesis nullIllegalArgumentException- ifnewStartIndices.length != n
-
withPan
Returns a copy with an updated per-event pan array and all other fields preserved.Pass null to clear the per-event override and use
GestureGranularParams.pan.- Parameters:
newPan- replacement per-event pan values; null is allowed, otherwise length must equaln- Returns:
- a new parameter set with the supplied pan array
- Throws:
IllegalArgumentException- ifnewPanis non-null andnewPan.length != n
-
withGain
Returns a copy with an updated per-event gain array and all other fields preserved.Pass null to clear the per-event override and use
GestureGranularParams.gainLinear.- Parameters:
newGain- replacement per-event gain values; null is allowed, otherwise length must equaln- Returns:
- a new parameter set with the supplied gain array
- Throws:
IllegalArgumentException- ifnewGainis non-null andnewGain.length != n
-
withPitchRatio
Returns a copy with an updated per-event pitch-ratio array and all other fields preserved.Pass null to clear the per-event override and use
GestureGranularParams.pitchRatio.- Parameters:
newPitchRatio- replacement per-event pitch ratios; null is allowed, otherwise length must equaln- Returns:
- a new parameter set with the supplied pitch-ratio array
- Throws:
IllegalArgumentException- ifnewPitchRatiois non-null andnewPitchRatio.length != n
-
panAt
public float panAt(int i, float defaultPan) Returns the pan value for one event.If no per-event pan array is present, this method returns
defaultPan. Otherwise it returnspan[i]clamped to the range [-1, 1].- Parameters:
i- event indexdefaultPan- pan value to use when no per-event pan array is present- Returns:
- the resolved pan value
- Throws:
ArrayIndexOutOfBoundsException- ifiis outside the pan array
-
gainAt
public float gainAt(int i, float defaultGain) Returns the gain value for one event.If no per-event gain array is present, this method returns
defaultGain. Otherwise it returnsgain[i], with negative values clamped to 0.- Parameters:
i- event indexdefaultGain- gain value to use when no per-event gain array is present- Returns:
- the resolved gain value
- Throws:
ArrayIndexOutOfBoundsException- ifiis outside the gain array
-
pitchAt
public float pitchAt(int i, float defaultPitch) Returns the pitch ratio for one event.If no per-event pitch-ratio array is present, this method returns
defaultPitch. Otherwise it returnspitchRatio[i], falling back todefaultPitchfor non-positive values.- Parameters:
i- event indexdefaultPitch- pitch ratio to use when no per-event pitch-ratio array is present- Returns:
- the resolved pitch ratio
- Throws:
ArrayIndexOutOfBoundsException- ifiis outside the pitch-ratio array
-
toString
String representation of this object's settings and array lengths (not contents). -
clampPan
private static float clampPan(float p)
-