Sonosthesia unity extractor
npm install com.sonosthesia.extractorExtraction helpers for turning interaction events into normalized values that can drive other Sonosthesia systems.
This package provides static and dynamic extractors that convert incoming events into typed data (for example float, Vector3, or other structs you add). Extractors can be composed with processors from com.sonosthesia.processing and configured as ScriptableObject assets to re-use extraction strategies across scenes.
Static extractors (IStaticExtractor) map a single event to a value, which is useful when only the first event is available (for example MIDI note properties). The StaticExtractorSettings base class is generic so you can target any data type and lets you combine:
- A raw extraction strategy, such as PeakFloatStaticExtractorSettings or PeakVectorStaticExtractorSettings for selecting peak magnitude, strength, duration, a constant value, or a custom extractor tailored to the output type.
- Post-processing via the configured IProcessor instance.
- Optional composition with other extractors through the InterfaceReference field.
Dynamic extractors (IDynamicExtractor) create sessions that react to event streams over time. The DynamicExtractorSettings pipeline is also generic so it can be applied to any structured value. Built-in follow strategies include:
- Float: Initial, Track, Relative, and Normalized via FloatDynamicExtractorSettings (relative and normalized variants derive values from the first sample).
- Vector: Initial, Track, and Relative via VectorDynamicExtractorSettings.
- Custom: implement your own typed follow strategies by extending DynamicExtractorSettings and pairing it with a session processor suited to your data.
Session processors such as FuncExtractionSessionProcessor, InitialSession, and RelativeSession make it easy to wrap custom logic around existing sessions while keeping implementations stateless when needed.
Both static and dynamic extractors can be authored as plain C# classes implementing IStaticExtractor or IDynamicExtractor, then wrapped in SettingsStaticExtractor or SettingsDynamicExtractor so they can be serialized as assets. Editor drawers (FloatStaticExtractorSettingsDrawer, FloatDynamicExtractorSettingsDrawer) provide an inspector-friendly way to configure follow strategy, processors, and custom extractor references.
Other Sonosthesia packages build on these extractors to translate domain events into reusable control signals:
- Pointer: Provides FloatPointerStaticExtractorSettings and FloatPointerDynamicExtractorSettings that pull pressure, scroll, raycast, or screen-space data from PointerEvent streams, and feeds those values into affordances such as PointerTriggerConfiguration. FloatPointerStaticExtractorSettings.cs FloatPointerDynamicExtractorSettings.cs PointerTriggerConfiguration.cs
- Touch: Provides static and dynamic extractor settings for TouchEvent that modulate values based on actor data, and routes the outputs into trigger/affordance configurations like TouchTriggerConfiguration. FloatTouchDynamicExtractorSettings.cs FloatTouchStaticExtractorSettings.cs TouchTriggerConfiguration.cs
- Interaction: Consumes IStaticExtractor and IDynamicExtractor outputs to drive envelope playback, pairing dynamic value extraction with static attack/release extraction inside InteractiveTriggerSettings. IInteractiveTriggerSettings.cs
- Trigger: Consumes multiple static extractor outputs inside SignalTriggerConfiguration to calculate value and timing before firing envelopes. SignalTriggerConfiguration.cs
- VFX: Consumes static extractor outputs in VFXEventAffordance to set per-attribute values before dispatching visual effect events. VFXEventAffordance.cs
- Instrument: Consumes touch extractor outputs in TouchMIDINoteConfiguration to derive channel, pitch, and expressive MIDI data from touch events. TouchMIDINoteConfiguration.cs