diff --git a/CMakeLists.txt b/CMakeLists.txt index d12df43..e7a0bdc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,6 +62,8 @@ add_library(DriftEngine STATIC Source/Engine/EngineCommandQueue.h Source/Engine/SpatialWorld.cpp Source/Engine/SpatialWorld.h + Source/Engine/SpeedActivityMapping.cpp + Source/Engine/SpeedActivityMapping.h Source/Engine/TransportEngine.cpp Source/Engine/TransportEngine.h Source/Music/MidiSink.cpp diff --git a/README.md b/README.md index 2fa1b1b..c5bf411 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,8 @@ Every collision pair has one explicit target: New contacts are resolved in the table's stable pair order. If simultaneous contacts target the same phrase, the first accepted request wins and that phrase keeps one unambiguous pending transition until the next eligible bar. +Phrase speed also selects authored material. Native velocity magnitude is normalized against the maximum throw speed and smoothed with a deterministic 250 ms filter. Each phrase begins normal (`A`), slows into sparse (`C`), or accelerates into active (`B`). Hysteresis keeps the bands stable: normal enters sparse at `0.015` and sparse returns at `0.040`; normal enters active at `0.450` and active returns at `0.300`. Band changes take effect at the next eligible bar. Speed observation pauses during Freeze Motion and direct dragging, while audio playback continues. A collision targeting the same phrase and bar replaces a pending speed change. + ## Architecture Drift is designed as a native **JUCE** desktop application with an embedded **React** interface. **PixiJS** is the initial renderer for the spatial world. @@ -98,7 +100,7 @@ Drift is in the design and initial implementation phase. The first development b 5. [Prove transport stability under simulated UI stress](https://github.com/datashaman/drift/issues/5) 6. [Validate ten-minute playback through a real MIDI device](https://github.com/datashaman/drift/issues/6) -The native shell now connects React Play, Stop, Freeze Motion, BPM, MIDI-output, and direct phrase-drag controls to a native-owned monotonic transport and a four-role composition: drums, bass, chords, and melody. Stop freezes both playback and movement; Freeze Motion pauses only autonomous movement so phrases can be caught and repositioned while MIDI continues uninterrupted. Untouched phrases retain their velocity for resume, while a phrase manipulated during the freeze is released stationary. Drift schedules every phrase from the same transport to its assigned MIDI channel and advances the phrase bodies in a bounded normalized world at a fixed 120 Hz. Validated pointer intent crosses a bounded, coalescing command queue; PixiJS follows the pointer optimistically and reconciles to latest-state native snapshots at 30 Hz. A bounded recent pointer sample window gives each release a native-owned throw velocity, while stationary releases settle and edge or corner throws reflect inside the field. Every phrase now has three compatible authored variants, and every unique phrase collision queues a deterministic target phrase advance exactly once at the next eligible unscheduled bar. Physics and input pressure remain independent of musical time, and the interface exposes motion state, every phrase's current/pending variant, all pair mappings, contacts, cooldowns, transition counts, timing, catch-up, queue, coalescing, rejection, and snapshot diagnostics. +The native shell now connects React Play, Stop, Freeze Motion, BPM, MIDI-output, and direct phrase-drag controls to a native-owned monotonic transport and a four-role composition: drums, bass, chords, and melody. Stop freezes both playback and movement; Freeze Motion pauses only autonomous movement so phrases can be caught and repositioned while MIDI continues uninterrupted. Untouched phrases retain their velocity for resume, while a phrase manipulated during the freeze is released stationary. Drift schedules every phrase from the same transport to its assigned MIDI channel and advances the phrase bodies in a bounded normalized world at a fixed 120 Hz. Validated pointer intent crosses a bounded, coalescing command queue; PixiJS follows the pointer optimistically and reconciles to latest-state native snapshots at 30 Hz. A bounded recent pointer sample window gives each release a native-owned throw velocity, while stationary releases settle and edge or corner throws reflect inside the field. Every phrase now has three compatible authored variants. Both unique phrase collisions and stable speed-band crossings queue deterministic changes at the next eligible unscheduled bar, with collisions taking priority at a shared boundary. Physics and input pressure remain independent of musical time, and the interface exposes motion state, raw and smoothed phrase speed, stable and pending activity bands, current/pending variants, pair mappings, transition counts, timing, catch-up, queue, coalescing, rejection, and snapshot diagnostics. The native/UI bridge uses a validated protocol-versioned envelope. Invalid commands produce structured rejection events without mutating engine state, and every React load performs a fresh handshake that restores the current authoritative transport state without restarting playback. diff --git a/Source/App/MainComponent.cpp b/Source/App/MainComponent.cpp index 729d95f..d759265 100644 --- a/Source/App/MainComponent.cpp +++ b/Source/App/MainComponent.cpp @@ -231,6 +231,14 @@ void MainComponent::publishState() "collisionTransitionAppliedCount", static_cast ( state.transport.diagnostics.collisionTransitionAppliedCount)); + diagnostics->setProperty ("speedBandChangeCount", static_cast ( + state.transport.diagnostics.speedBandChangeCount)); + diagnostics->setProperty ("speedIntentQueuedCount", static_cast ( + state.transport.diagnostics.speedIntentQueuedCount)); + diagnostics->setProperty ("speedIntentSuppressedCount", static_cast ( + state.transport.diagnostics.speedIntentSuppressedCount)); + diagnostics->setProperty ("speedTransitionAppliedCount", static_cast ( + state.transport.diagnostics.speedTransitionAppliedCount)); diagnostics->setProperty ( "commandQueueDepth", static_cast (state.commandQueue.queueDepth)); diagnostics->setProperty ( @@ -304,6 +312,16 @@ void MainComponent::publishWorldSnapshot (const drift::engine::ControllerSnapsho phrase.pendingVariantApplyBeat ? juce::var { *phrase.pendingVariantApplyBeat } : juce::var {}); + phraseObject->setProperty ("rawNormalizedSpeed", phrase.rawNormalizedSpeed); + phraseObject->setProperty ( + "smoothedNormalizedSpeed", phrase.smoothedNormalizedSpeed); + phraseObject->setProperty ( + "activityBand", drift::engine::activityBandName (phrase.activityBand)); + phraseObject->setProperty ( + "pendingActivityBand", + phrase.pendingActivityBand + ? juce::var { drift::engine::activityBandName (*phrase.pendingActivityBand) } + : juce::var {}); phraseObject->setProperty ("midiChannel", phrase.midiChannel); phraseObject->setProperty ("playing", phrase.playing); @@ -361,6 +379,14 @@ void MainComponent::publishWorldSnapshot (const drift::engine::ControllerSnapsho "collisionTransitionAppliedCount", static_cast ( state.transport.diagnostics.collisionTransitionAppliedCount)); + diagnostics->setProperty ("speedBandChangeCount", static_cast ( + state.transport.diagnostics.speedBandChangeCount)); + diagnostics->setProperty ("speedIntentQueuedCount", static_cast ( + state.transport.diagnostics.speedIntentQueuedCount)); + diagnostics->setProperty ("speedIntentSuppressedCount", static_cast ( + state.transport.diagnostics.speedIntentSuppressedCount)); + diagnostics->setProperty ("speedTransitionAppliedCount", static_cast ( + state.transport.diagnostics.speedTransitionAppliedCount)); diagnostics->setProperty ( "droppedSnapshotCount", static_cast (droppedWorldSnapshotCount)); diagnostics->setProperty ( diff --git a/Source/Engine/SpeedActivityMapping.cpp b/Source/Engine/SpeedActivityMapping.cpp new file mode 100644 index 0000000..e24cc55 --- /dev/null +++ b/Source/Engine/SpeedActivityMapping.cpp @@ -0,0 +1,89 @@ +#include "Engine/SpeedActivityMapping.h" + +#include "Engine/SpatialWorld.h" + +#include +#include + +namespace drift::engine +{ +const char* activityBandName (ActivityBand band) noexcept +{ + switch (band) + { + case ActivityBand::sparse: return "sparse"; + case ActivityBand::normal: return "normal"; + case ActivityBand::active: return "active"; + } + + return "normal"; +} + +const char* variantIdForActivityBand (ActivityBand band) noexcept +{ + switch (band) + { + case ActivityBand::sparse: return "C"; + case ActivityBand::normal: return "A"; + case ActivityBand::active: return "B"; + } + + return "A"; +} + +ActivityBand activityBandAfterObservation (ActivityBand current, + double speed) noexcept +{ + speed = std::clamp (speed, 0.0, 1.0); + switch (current) + { + case ActivityBand::sparse: + return speed >= SpeedActivityTracker::sparseToNormalThreshold + ? ActivityBand::normal : current; + case ActivityBand::normal: + if (speed <= SpeedActivityTracker::normalToSparseThreshold) + return ActivityBand::sparse; + if (speed >= SpeedActivityTracker::normalToActiveThreshold) + return ActivityBand::active; + return current; + case ActivityBand::active: + return speed <= SpeedActivityTracker::activeToNormalThreshold + ? ActivityBand::normal : current; + } + return ActivityBand::normal; +} + +std::optional SpeedActivityTracker::observe ( + double normalizedSpeed, + std::size_t fixedStepCount, + bool suspended) +{ + rawSpeed = std::clamp (normalizedSpeed, 0.0, 1.0); + + if (! initialized) + { + smoothedSpeed = rawSpeed; + initialized = true; + } + + if (suspended || fixedStepCount == 0) + return std::nullopt; + + const auto alpha = 1.0 - std::exp ( + -SpatialWorld::fixedStepSeconds / smoothingTimeConstantSeconds); + for (std::size_t step = 0; step < fixedStepCount; ++step) + smoothedSpeed += alpha * (rawSpeed - smoothedSpeed); + + const auto nextBand = activityBandAfterObservation (band, smoothedSpeed); + + if (nextBand == band) + return std::nullopt; + + band = nextBand; + return band; +} + +double SpeedActivityTracker::rawNormalizedSpeed() const noexcept { return rawSpeed; } +double SpeedActivityTracker::smoothedNormalizedSpeed() const noexcept { return smoothedSpeed; } +ActivityBand SpeedActivityTracker::stableBand() const noexcept { return band; } +} // namespace drift::engine diff --git a/Source/Engine/SpeedActivityMapping.h b/Source/Engine/SpeedActivityMapping.h new file mode 100644 index 0000000..96de6c4 --- /dev/null +++ b/Source/Engine/SpeedActivityMapping.h @@ -0,0 +1,44 @@ +#pragma once + +#include +#include +#include + +namespace drift::engine +{ +enum class ActivityBand +{ + sparse, + normal, + active, +}; + +const char* activityBandName (ActivityBand band) noexcept; +const char* variantIdForActivityBand (ActivityBand band) noexcept; +ActivityBand activityBandAfterObservation (ActivityBand current, + double smoothedNormalizedSpeed) noexcept; + +class SpeedActivityTracker +{ +public: + static constexpr double smoothingTimeConstantSeconds = 0.250; + static constexpr double normalToSparseThreshold = 0.015; + static constexpr double sparseToNormalThreshold = 0.040; + static constexpr double normalToActiveThreshold = 0.450; + static constexpr double activeToNormalThreshold = 0.300; + + std::optional observe (double normalizedSpeed, + std::size_t fixedStepCount, + bool suspended); + + double rawNormalizedSpeed() const noexcept; + double smoothedNormalizedSpeed() const noexcept; + ActivityBand stableBand() const noexcept; + +private: + double rawSpeed = 0.0; + double smoothedSpeed = 0.0; + ActivityBand band = ActivityBand::normal; + bool initialized = false; +}; +} // namespace drift::engine diff --git a/Source/Engine/TransportEngine.cpp b/Source/Engine/TransportEngine.cpp index 341c73f..e5ac4c4 100644 --- a/Source/Engine/TransportEngine.cpp +++ b/Source/Engine/TransportEngine.cpp @@ -62,6 +62,18 @@ TransportEngine::TransportEngine (Clock& clockIn, music::MidiSink& sinkIn) world (makePhraseBodies (phrases), clockIn.nowSeconds()) { world.setMotionPaused (true); + const auto& bodies = world.bodies(); + for (std::size_t index = 0; index < phrases.size(); ++index) + { + const auto& phrase = phrases[index]; + speedTrackers.emplace (phrase.id, SpeedActivityTracker {}); + pendingSpeedBands.emplace (phrase.id, std::nullopt); + const auto& velocity = bodies[index].velocity; + speedTrackers.at (phrase.id).observe ( + std::hypot (velocity.x, velocity.y) / SpatialWorld::maximumThrowSpeed, + 0, + true); + } } void TransportEngine::play() @@ -88,6 +100,7 @@ void TransportEngine::stop() { phrase.pendingVariantId.reset(); phrase.pendingVariantApplyBeat.reset(); + pendingSpeedBands[phrase.id].reset(); } } @@ -130,8 +143,12 @@ void TransportEngine::recordBridgeReconnect() void TransportEngine::tick() { world.advanceTo (clock.nowSeconds()); + const auto physicsStepCount = world.diagnostics().physicsStepCount; + const auto fixedSteps = physicsStepCount - observedPhysicsStepCount; + observedPhysicsStepCount = physicsStepCount; const auto state = transport.snapshot(); processCollisionContacts (state.beatPosition); + processSpeedActivity (state.beatPosition, fixedSteps); applyDueIntents (state.beatPosition); if (! state.playing) @@ -177,8 +194,8 @@ void TransportEngine::processCollisionContacts (double currentBeat) continue; ++diagnostics.collisionContactBeginCount; - const auto* target = findPhrase (rule->targetPhraseId); - if (target == nullptr || target->pendingVariantId) + auto* target = findPhrase (rule->targetPhraseId); + if (target == nullptr) continue; const auto variantId = nextVariantId (*target); @@ -193,11 +210,63 @@ void TransportEngine::processCollisionContacts (double currentBeat) *variantId, music::quantizeForward (earliestUnscheduledBeat, barLengthBeats), }; - if (queueIntent (intent)) + auto& pendingSpeedBand = pendingSpeedBands[target->id]; + if (target->pendingVariantId && target->pendingVariantApplyBeat + && pendingSpeedBand + && std::abs (*target->pendingVariantApplyBeat - intent.applyAtBeat) + <= timingToleranceSeconds) + { + target->pendingVariantId = intent.variantId; + target->pendingVariantApplyBeat = intent.applyAtBeat; + pendingSpeedBand.reset(); + ++diagnostics.collisionIntentQueuedCount; + } + else if (queueIntent (intent)) ++diagnostics.collisionIntentQueuedCount; } } +void TransportEngine::processSpeedActivity (double currentBeat, + std::size_t fixedStepCount) +{ + const auto& bodies = world.bodies(); + for (std::size_t index = 0; index < phrases.size(); ++index) + { + auto& phrase = phrases[index]; + const auto& body = bodies[index]; + const auto normalizedSpeed = std::hypot (body.velocity.x, body.velocity.y) + / SpatialWorld::maximumThrowSpeed; + auto& tracker = speedTrackers[phrase.id]; + const auto change = tracker.observe ( + normalizedSpeed, fixedStepCount, world.motionPaused() || body.dragged); + if (! change) + continue; + + ++diagnostics.speedBandChangeCount; + const auto variantId = std::string { variantIdForActivityBand (*change) }; + if (variantId == phrase.currentVariantId) + continue; + + const auto earliestUnscheduledBeat = std::max (currentBeat, scheduledThroughBeat) + + timingToleranceSeconds; + const MusicalIntent intent { + phrase.id, + MusicalIntentType::changeVariant, + variantId, + music::quantizeForward (earliestUnscheduledBeat, barLengthBeats), + }; + if (queueIntent (intent)) + { + pendingSpeedBands[phrase.id] = *change; + ++diagnostics.speedIntentQueuedCount; + } + else + { + ++diagnostics.speedIntentSuppressedCount; + } + } +} + bool TransportEngine::queueIntent (const MusicalIntent& intent) { if (intent.type != MusicalIntentType::changeVariant) @@ -227,8 +296,15 @@ void TransportEngine::applyDueIntents (double currentBeat) } const auto variantId = *phrase.pendingVariantId; + const auto wasSpeedIntent = pendingSpeedBands[phrase.id].has_value(); if (music::applyVariant (phrase, variantId)) - ++diagnostics.collisionTransitionAppliedCount; + { + if (wasSpeedIntent) + ++diagnostics.speedTransitionAppliedCount; + else + ++diagnostics.collisionTransitionAppliedCount; + } + pendingSpeedBands[phrase.id].reset(); } } @@ -317,6 +393,7 @@ EngineSnapshot TransportEngine::snapshot() const { const auto& phrase = phrases[index]; const auto& body = bodies[index]; + const auto& tracker = speedTrackers.at (phrase.id); phraseSnapshots.push_back ({ phrase.id, phrase.name, @@ -324,6 +401,10 @@ EngineSnapshot TransportEngine::snapshot() const phrase.currentVariantId, phrase.pendingVariantId, phrase.pendingVariantApplyBeat, + tracker.rawNormalizedSpeed(), + tracker.smoothedNormalizedSpeed(), + tracker.stableBand(), + pendingSpeedBands.at (phrase.id), phrase.midiChannel, body.position, body.velocity, diff --git a/Source/Engine/TransportEngine.h b/Source/Engine/TransportEngine.h index 6006b43..eda74c8 100644 --- a/Source/Engine/TransportEngine.h +++ b/Source/Engine/TransportEngine.h @@ -2,6 +2,7 @@ #include "Engine/Clock.h" #include "Engine/SpatialWorld.h" +#include "Engine/SpeedActivityMapping.h" #include "Music/MidiSink.h" #include "Music/Phrase.h" #include "Music/PhraseScheduler.h" @@ -9,6 +10,7 @@ #include #include +#include #include #include @@ -26,6 +28,10 @@ struct EngineDiagnostics std::size_t collisionContactBeginCount = 0; std::size_t collisionIntentQueuedCount = 0; std::size_t collisionTransitionAppliedCount = 0; + std::size_t speedBandChangeCount = 0; + std::size_t speedIntentQueuedCount = 0; + std::size_t speedIntentSuppressedCount = 0; + std::size_t speedTransitionAppliedCount = 0; }; struct PhraseSnapshot @@ -36,6 +42,10 @@ struct PhraseSnapshot std::string currentVariantId; std::optional pendingVariantId; std::optional pendingVariantApplyBeat; + double rawNormalizedSpeed = 0.0; + double smoothedNormalizedSpeed = 0.0; + ActivityBand activityBand = ActivityBand::normal; + std::optional pendingActivityBand; int midiChannel = 1; music::NormalizedPosition position; music::NormalizedVelocity velocity; @@ -113,6 +123,7 @@ class TransportEngine static constexpr double barLengthBeats = 4.0; void processCollisionContacts (double currentBeat); + void processSpeedActivity (double currentBeat, std::size_t fixedStepCount); bool queueIntent (const MusicalIntent& intent); void applyDueIntents (double currentBeat); void schedulePhraseRange (const music::Phrase& phrase, @@ -129,5 +140,8 @@ class TransportEngine music::PhraseScheduler scheduler; double scheduledThroughBeat = 0.0; EngineDiagnostics diagnostics; + std::map speedTrackers; + std::map> pendingSpeedBands; + std::size_t observedPhysicsStepCount = 0; }; } // namespace drift::engine diff --git a/Tests/DriftTests.cpp b/Tests/DriftTests.cpp index 326cc47..43b7f36 100644 --- a/Tests/DriftTests.cpp +++ b/Tests/DriftTests.cpp @@ -3,6 +3,7 @@ #include "Engine/EngineCommandQueue.h" #include "Engine/SpatialWorld.h" #include "Engine/TransportEngine.h" +#include "Engine/SpeedActivityMapping.h" #include "Music/MidiSink.h" #include "Music/MidiOutput.h" #include "Music/PhraseScheduler.h" @@ -408,6 +409,55 @@ void testInitialCompositionIsAuthoritative() expect (uniqueIds.size() == phrases.size(), "Phrase IDs are unique"); } +void testSpeedActivityMappingAndSmoothing() +{ + using drift::engine::ActivityBand; + using drift::engine::SpeedActivityTracker; + using drift::engine::activityBandAfterObservation; + + expect (std::string { drift::engine::variantIdForActivityBand (ActivityBand::sparse) } + == "C" + && std::string { drift::engine::variantIdForActivityBand (ActivityBand::normal) } + == "A" + && std::string { drift::engine::variantIdForActivityBand (ActivityBand::active) } + == "B", + "Sparse, normal, and active bands map to authored C, A, and B variants"); + expect (activityBandAfterObservation (ActivityBand::normal, 0.015) + == ActivityBand::sparse + && activityBandAfterObservation (ActivityBand::sparse, 0.039) + == ActivityBand::sparse + && activityBandAfterObservation (ActivityBand::sparse, 0.040) + == ActivityBand::normal, + "Sparse hysteresis includes both exact thresholds and holds between them"); + expect (activityBandAfterObservation (ActivityBand::normal, 0.450) + == ActivityBand::active + && activityBandAfterObservation (ActivityBand::active, 0.301) + == ActivityBand::active + && activityBandAfterObservation (ActivityBand::active, 0.300) + == ActivityBand::normal, + "Active hysteresis includes both exact thresholds and holds between them"); + + SpeedActivityTracker smoothing; + smoothing.observe (0.03, 0, false); + smoothing.observe (1.0, 1, false); + const auto alpha = 1.0 - std::exp ( + -drift::engine::SpatialWorld::fixedStepSeconds + / SpeedActivityTracker::smoothingTimeConstantSeconds); + expectNear (smoothing.smoothedNormalizedSpeed(), 0.03 + alpha * 0.97, + "Speed smoothing advances by the deterministic 120 Hz exponential step"); + const auto beforeSuspension = smoothing.smoothedNormalizedSpeed(); + smoothing.observe (0.0, 1000, true); + expectNear (smoothing.smoothedNormalizedSpeed(), beforeSuspension, + "Suspended speed observation does not advance smoothing or bands"); + + SpeedActivityTracker jitter; + jitter.observe (0.03, 0, false); + for (auto step = 0; step < 1000; ++step) + jitter.observe (step % 2 == 0 ? 0.02 : 0.039, 1, false); + expect (jitter.stableBand() == ActivityBand::normal, + "Speed jitter inside the hysteresis window does not chatter bands"); +} + void testCollisionVariantRulesAndCycle() { const std::array, 6> expected {{ @@ -1076,6 +1126,152 @@ void testSimultaneousCollisionsUseStablePriority() "Simultaneous variant changes preserve paired MIDI output"); } +void testSpeedActivityQueuesQuantizedVariantsAndCollisionWins() +{ + const auto phraseById = [] (const drift::engine::EngineSnapshot& snapshot, + const std::string& phraseId) + -> const drift::engine::PhraseSnapshot& { + const auto phrase = std::find_if ( + snapshot.phrases.begin(), snapshot.phrases.end(), [&] (const auto& candidate) { + return candidate.id == phraseId; + }); + if (phrase == snapshot.phrases.end()) + throw std::runtime_error ("Missing phrase snapshot"); + return *phrase; + }; + + FakeClock clock; + drift::music::RecordingMidiSink sink; + drift::engine::TransportEngine engine { clock, sink }; + engine.play(); + expect (engine.beginPhraseDrag ("bass") + && engine.throwPhrase ("bass", { 0.0, -1.5 }), + "A maximum native throw can drive the bass activity tracker"); + + for (auto step = 0; step < 60; ++step) + { + clock.advance (drift::engine::SpatialWorld::fixedStepSeconds); + engine.tick(); + } + + auto snapshot = engine.snapshot(); + auto bass = phraseById (snapshot, "bass"); + expect (bass.activityBand == drift::engine::ActivityBand::active + && bass.pendingActivityBand == drift::engine::ActivityBand::active, + "A fast phrase settles into active and publishes its pending speed band"); + expect (bass.currentVariantId == "A" && bass.pendingVariantId == "B" + && bass.pendingVariantApplyBeat == 4.0, + "Active speed queues authored variant B at the next unscheduled bar"); + expect (snapshot.diagnostics.speedBandChangeCount == 1 + && snapshot.diagnostics.speedIntentQueuedCount == 1, + "A stable speed crossing emits exactly one observable intent"); + + expect (engine.beginPhraseDrag ("drums"), + "The priority fixture can move drums into the fast bass"); + expect (engine.moveDraggedPhrase ("drums", bass.position), + "The priority fixture creates a bass-drums contact"); + clock.advance (drift::engine::SpatialWorld::fixedStepSeconds); + engine.tick(); + snapshot = engine.snapshot(); + bass = phraseById (snapshot, "bass"); + expect (bass.pendingVariantId == "B" && ! bass.pendingActivityBand, + "A collision replaces a speed intent aimed at the same musical boundary"); + expect (snapshot.diagnostics.collisionIntentQueuedCount == 1, + "The replacing collision is counted as the accepted boundary intent"); + + while (engine.snapshot().beatPosition + 1.0e-9 < 4.0) + { + clock.advance (0.002); + engine.tick(); + } + snapshot = engine.snapshot(); + expect (phraseById (snapshot, "bass").currentVariantId == "B" + && snapshot.diagnostics.collisionTransitionAppliedCount == 1 + && snapshot.diagnostics.speedTransitionAppliedCount == 0, + "The boundary applies the collision transition once, not the displaced speed intent"); + expect (sink.activeNoteCount() == 0 && snapshot.diagnostics.lateMidiEventCount == 0, + "Speed/collision arbitration preserves paired, on-time MIDI"); + + FakeClock sameTickClock; + drift::music::RecordingMidiSink sameTickSink; + drift::engine::TransportEngine sameTickEngine { sameTickClock, sameTickSink }; + sameTickEngine.play(); + sameTickEngine.beginPhraseDrag ("bass"); + sameTickEngine.throwPhrase ("bass", { 0.0, -1.5 }); + for (auto step = 0; step < 16; ++step) + { + sameTickClock.advance (drift::engine::SpatialWorld::fixedStepSeconds); + sameTickEngine.tick(); + } + expect (phraseById (sameTickEngine.snapshot(), "bass").activityBand + == drift::engine::ActivityBand::normal, + "The simultaneous fixture stops immediately below the active threshold"); + sameTickEngine.beginPhraseDrag ("drums"); + sameTickEngine.moveDraggedPhrase ( + "drums", phraseById (sameTickEngine.snapshot(), "bass").position); + sameTickClock.advance (drift::engine::SpatialWorld::fixedStepSeconds); + sameTickEngine.tick(); + const auto sameTick = sameTickEngine.snapshot(); + const auto& sameTickBass = phraseById (sameTick, "bass"); + expect (sameTickBass.activityBand == drift::engine::ActivityBand::active + && sameTickBass.pendingVariantId == "B" + && ! sameTickBass.pendingActivityBand, + "A same-tick collision wins while the observed speed band still advances"); + expect (sameTick.diagnostics.speedIntentSuppressedCount == 1 + && sameTick.diagnostics.collisionIntentQueuedCount == 1, + "Same-tick collision priority records the suppressed speed intent exactly once"); + + FakeClock pausedClock; + drift::music::RecordingMidiSink pausedSink; + drift::engine::TransportEngine pausedEngine { pausedClock, pausedSink }; + pausedEngine.play(); + pausedEngine.beginPhraseDrag ("melody"); + pausedEngine.throwPhrase ("melody", { 1.5, 0.0 }); + pausedEngine.setMotionPaused (true); + for (auto step = 0; step < 120; ++step) + { + pausedClock.advance (drift::engine::SpatialWorld::fixedStepSeconds); + pausedEngine.tick(); + } + expect (phraseById (pausedEngine.snapshot(), "melody").activityBand + == drift::engine::ActivityBand::normal, + "Freeze Motion suspends speed-band observation without changing musical activity"); + pausedEngine.setMotionPaused (false); + for (auto step = 0; step < 60; ++step) + { + pausedClock.advance (drift::engine::SpatialWorld::fixedStepSeconds); + pausedEngine.tick(); + } + expect (phraseById (pausedEngine.snapshot(), "melody").activityBand + == drift::engine::ActivityBand::active, + "Speed observation resumes from stored native velocity after motion resumes"); + + FakeClock draggedClock; + drift::music::RecordingMidiSink draggedSink; + drift::engine::TransportEngine draggedEngine { draggedClock, draggedSink }; + draggedEngine.play(); + draggedEngine.beginPhraseDrag ("chords"); + draggedEngine.throwPhrase ("chords", { -1.5, 0.0 }); + draggedEngine.beginPhraseDrag ("chords"); + for (auto step = 0; step < 120; ++step) + { + draggedClock.advance (drift::engine::SpatialWorld::fixedStepSeconds); + draggedEngine.tick(); + } + expect (phraseById (draggedEngine.snapshot(), "chords").activityBand + == drift::engine::ActivityBand::normal, + "Direct dragging suspends speed observation even while native velocity is retained"); + draggedEngine.endPhraseDrag ("chords"); + for (auto step = 0; step < 60; ++step) + { + draggedClock.advance (drift::engine::SpatialWorld::fixedStepSeconds); + draggedEngine.tick(); + } + expect (phraseById (draggedEngine.snapshot(), "chords").activityBand + == drift::engine::ActivityBand::active, + "Ending a drag resumes observation from the retained native velocity"); +} + void testFourPhrasesShareOneTransport() { FakeClock clock; @@ -1645,6 +1841,7 @@ int main() testQuantizationBoundaries(); testPhraseSchedulingAcrossLoopAndBar(); testInitialCompositionIsAuthoritative(); + testSpeedActivityMappingAndSmoothing(); testCollisionVariantRulesAndCycle(); testSpatialWorldFixedStepAndBoundaries(); testSpatialWorldBoundsCatchUpWork(); @@ -1656,6 +1853,7 @@ int main() testCollisionQueuesAndAppliesBassVariantAtBar(); testEveryCollisionPairQueuesItsMappedTarget(); testSimultaneousCollisionsUseStablePriority(); + testSpeedActivityQueuesQuantizedVariantsAndCollisionWins(); testFourPhrasesShareOneTransport(); testMotionPauseDoesNotInterruptPlayback(); testEngineIsIndependentOfUiUpdateTiming(); diff --git a/Tests/TransportStressTests.cpp b/Tests/TransportStressTests.cpp index fb3d0b7..55407f7 100644 --- a/Tests/TransportStressTests.cpp +++ b/Tests/TransportStressTests.cpp @@ -303,6 +303,10 @@ int main() require (stressed.snapshot.diagnostics.collisionIntentQueuedCount >= 1 && stressed.snapshot.diagnostics.collisionTransitionAppliedCount >= 1, "the stress run did not exercise the collision transition path"); + require (stressed.snapshot.diagnostics.speedBandChangeCount >= 1 + && stressed.snapshot.diagnostics.speedIntentQueuedCount >= 1 + && stressed.snapshot.diagnostics.speedTransitionAppliedCount >= 1, + "the stress run did not exercise quantized speed activity transitions"); std::cout << std::fixed << std::setprecision (9) << "Drift deterministic timing stress report\n" @@ -327,6 +331,14 @@ int main() << stressed.snapshot.diagnostics.collisionIntentQueuedCount << '\n' << "Collision transitions applied: " << stressed.snapshot.diagnostics.collisionTransitionAppliedCount << '\n' + << "Speed band changes: " + << stressed.snapshot.diagnostics.speedBandChangeCount << '\n' + << "Speed intents queued: " + << stressed.snapshot.diagnostics.speedIntentQueuedCount << '\n' + << "Speed intents suppressed: " + << stressed.snapshot.diagnostics.speedIntentSuppressedCount << '\n' + << "Speed transitions applied: " + << stressed.snapshot.diagnostics.speedTransitionAppliedCount << '\n' << "Recorded MIDI messages: " << stressed.messages.size() << '\n' << "Scheduling watermark: " << stressed.snapshot.diagnostics.schedulingWatermarkBeat << " beats\n" diff --git a/docs/TECHNICAL-DESIGN.md b/docs/TECHNICAL-DESIGN.md index 1afed21..22802ce 100644 --- a/docs/TECHNICAL-DESIGN.md +++ b/docs/TECHNICAL-DESIGN.md @@ -268,7 +268,10 @@ Positions and velocities use normalized world coordinates so UI size and display "radius": 0.06, "variant": "B", "pendingVariant": null, - "activity": 0.48, + "rawNormalizedSpeed": 0.52, + "smoothedNormalizedSpeed": 0.48, + "activityBand": "active", + "pendingActivityBand": null, "dragged": false, "playing": true } @@ -358,7 +361,16 @@ spatial observation Only the intent processor may change a phrase's musical variant because of spatial behavior. This creates a testable seam between physics and music. -Continuous inputs such as speed and proximity should be smoothed and quantized into stable states to prevent rapid variant flapping. Hysteresis is preferred over reacting to every small numeric change. +Speed is normalized as velocity magnitude divided by `SpatialWorld::maximumThrowSpeed`, clamped to `[0, 1]`, then filtered once per 120 Hz physics step with a deterministic 250 ms exponential time constant. The tracker starts in normal and uses these inclusive hysteresis transitions: + +| Current band | Next band | Smoothed threshold | Variant | +| --- | --- | --- | --- | +| Normal | Sparse | `≤ 0.015` | `C` | +| Sparse | Normal | `≥ 0.040` | `A` | +| Normal | Active | `≥ 0.450` | `B` | +| Active | Normal | `≤ 0.300` | `A` | + +Observation is suspended while world motion is paused or the phrase is dragged: raw speed remains observable, but smoothing and the stable band do not advance. Observation resumes from the released native velocity. Only stable band changes emit intents, and accepted changes are quantized to the next eligible bar. ### 9.3 MIDI scheduling pipeline @@ -403,9 +415,9 @@ Initial mappings: | `chords`, `melody` | `chords` | | `drums`, `melody` | `melody` | -Contact begins are sorted lexicographically by their stable ordered phrase IDs before evaluation. A phrase accepts at most one pending variant transition; subsequent same-tick or pre-boundary contacts targeting that phrase are observed but do not replace the accepted intent. This makes simultaneous outcomes independent of physics-body iteration order and prevents contradictory pending state. +Contact begins are sorted lexicographically by their stable ordered phrase IDs before evaluation. A phrase accepts at most one collision intent; subsequent same-tick contacts targeting that phrase are observed but do not replace the accepted collision. This makes simultaneous outcomes independent of physics-body iteration order and prevents contradictory pending state. -If two mappings request incompatible changes for the same phrase and boundary, a deterministic policy resolves them. For the POC, explicit collision changes should take priority over continuous speed/proximity changes. +If collision and speed request incompatible changes for the same phrase and boundary, the explicit collision wins. A collision replaces an already-pending speed intent for that boundary; a speed crossing observed after a collision is suppressed. The stable speed band still advances and a suppressed crossing is not retried until another threshold crossing, preventing a delayed speed intent from undoing the collision one bar later. ## 11. React and PixiJS design diff --git a/ui/src/App.test.tsx b/ui/src/App.test.tsx index bac17c7..8bdc7ed 100644 --- a/ui/src/App.test.tsx +++ b/ui/src/App.test.tsx @@ -58,6 +58,10 @@ function worldEvent( collisionContactBeginCount: 2, collisionIntentQueuedCount: 1, collisionTransitionAppliedCount: 0, + speedBandChangeCount: 0, + speedIntentQueuedCount: 0, + speedIntentSuppressedCount: 0, + speedTransitionAppliedCount: 0, droppedSnapshotCount: 112, maximumSnapshotIntervalMs: 34.2, commandQueueDepth: 2, @@ -82,6 +86,10 @@ function worldEvent( currentVariantId: 'A', pendingVariantId: null, pendingVariantApplyBeat: null, + rawNormalizedSpeed: 0.043, + smoothedNormalizedSpeed: 0.043, + activityBand: 'normal', + pendingActivityBand: null, midiChannel: 10, position: { x: 0.78, y: 0.58 }, velocity: { x: -0.055, y: -0.035 }, @@ -97,6 +105,10 @@ function worldEvent( currentVariantId: 'A', pendingVariantId: null, pendingVariantApplyBeat: null, + rawNormalizedSpeed: 0.034, + smoothedNormalizedSpeed: 0.034, + activityBand: 'normal', + pendingActivityBand: null, midiChannel: 1, position: { x: 0.2, y: 0.28 }, velocity: { x: 0.045, y: 0.025 }, @@ -112,6 +124,10 @@ function worldEvent( currentVariantId: 'A', pendingVariantId: null, pendingVariantApplyBeat: null, + rawNormalizedSpeed: 0.035, + smoothedNormalizedSpeed: 0.035, + activityBand: 'normal', + pendingActivityBand: null, midiChannel: 2, position: { x: 0.45, y: 0.76 }, velocity: { x: 0.035, y: -0.04 }, @@ -127,6 +143,10 @@ function worldEvent( currentVariantId: 'A', pendingVariantId: null, pendingVariantApplyBeat: null, + rawNormalizedSpeed: 0.043, + smoothedNormalizedSpeed: 0.043, + activityBand: 'normal', + pendingActivityBand: null, midiChannel: 3, position: { x: 0.74, y: 0.2 }, velocity: { x: -0.04, y: 0.05 }, @@ -214,6 +234,10 @@ describe('Drift bridge interface', () => { collisionContactBeginCount: 2, collisionIntentQueuedCount: 1, collisionTransitionAppliedCount: 0, + speedBandChangeCount: 0, + speedIntentQueuedCount: 0, + speedIntentSuppressedCount: 0, + speedTransitionAppliedCount: 0, commandQueueDepth: 2, maximumCommandQueueDepth: 7, coalescedMoveCount: 12, @@ -341,7 +365,7 @@ describe('Drift bridge interface', () => { const appliedWorld = worldEvent(6) appliedWorld.payload.phrases[1].currentVariantId = 'B' act(() => bridge.publish(appliedWorld)) - expect(screen.getByText(/BASS · B · playing/)).toBeTruthy() + expect(screen.getByText(/BASS · B · normal · speed .* · playing/)).toBeTruthy() expect(container.textContent).not.toContain('BASS · A → B') act(() => { @@ -419,7 +443,7 @@ describe('Drift bridge interface', () => { const selectedWorld = worldEvent(5) selectedWorld.payload.phrases[1].dragged = true act(() => bridge.publish(selectedWorld)) - expect(screen.getByText(/BASS · A · playing · moving · selected/)).toBeTruthy() + expect(screen.getByText(/BASS · A · normal · speed .* · playing · moving · selected/)).toBeTruthy() }) it('ends an interrupted pointer lifecycle without throwing', () => { diff --git a/ui/src/App.tsx b/ui/src/App.tsx index 1a1df1d..9c917b2 100644 --- a/ui/src/App.tsx +++ b/ui/src/App.tsx @@ -276,6 +276,24 @@ export function App({ bridge }: AppProps) { {worldSnapshot.diagnostics.collisionTransitionAppliedCount} applied + {worldSnapshot.phrases.map((phrase) => ( +
+
{phrase.name} speed
+
+ {phrase.activityBand}{phrase.pendingActivityBand ? ` → ${phrase.pendingActivityBand}` : ''} /{' '} + {phrase.rawNormalizedSpeed.toFixed(3)} raw / {phrase.smoothedNormalizedSpeed.toFixed(3)} smooth +
+
+ ))} +
+
Speed activity
+
+ {worldSnapshot.diagnostics.speedBandChangeCount} bands /{' '} + {worldSnapshot.diagnostics.speedIntentQueuedCount} queued /{' '} + {worldSnapshot.diagnostics.speedIntentSuppressedCount} suppressed /{' '} + {worldSnapshot.diagnostics.speedTransitionAppliedCount} applied +
+
Catch-up
diff --git a/ui/src/PhraseWorld.tsx b/ui/src/PhraseWorld.tsx index 751dc1b..e6647f1 100644 --- a/ui/src/PhraseWorld.tsx +++ b/ui/src/PhraseWorld.tsx @@ -79,6 +79,12 @@ function variantLabel(phrase: PhraseSnapshot) { : phrase.currentVariantId } +function activityToken(phrase: PhraseSnapshot) { + const token = { sparse: 'S', normal: 'N', active: 'A' }[phrase.activityBand] + if (!phrase.pendingActivityBand) return token + return `${token}→${{ sparse: 'S', normal: 'N', active: 'A' }[phrase.pendingActivityBand]}` +} + export function PhraseWorld({ snapshot, onDragStart, @@ -177,7 +183,7 @@ export function PhraseWorld({ .circle(0, 0, 1) .stroke({ color: 0xeef1e8, width: 0.1, alpha: 0.82 }) const label = new Text({ - text: `${phrase.name} · ${variantLabel(phrase)}`, + text: `${phrase.name} · ${variantLabel(phrase)} · ${activityToken(phrase)}`, style: { fill: colour, fontFamily: 'SFMono-Regular, Consolas, monospace', @@ -225,7 +231,7 @@ export function PhraseWorld({ node.selection.visible = phrase.dragged || isOptimisticallyDragged node.selection.scale.set(radiusPixels * 1.28) node.label.position.set(radiusPixels + 10, -7) - node.label.text = `${phrase.name} · ${variantLabel(phrase)}` + node.label.text = `${phrase.name} · ${variantLabel(phrase)} · ${activityToken(phrase)}` } } @@ -339,7 +345,7 @@ export function PhraseWorld({
    {snapshot.phrases.map((phrase) => (
  • - {phrase.name} · {variantLabel(phrase)} · {phrase.playing ? 'playing' : 'stopped'} · {snapshot.motionPaused ? 'motion frozen' : 'moving'} · {phrase.dragged ? 'selected' : 'free'} + {phrase.name} · {variantLabel(phrase)} · {phrase.activityBand}{phrase.pendingActivityBand ? ` to ${phrase.pendingActivityBand} pending` : ''} · speed {phrase.rawNormalizedSpeed.toFixed(3)} raw, {phrase.smoothedNormalizedSpeed.toFixed(3)} smoothed · {phrase.playing ? 'playing' : 'stopped'} · {snapshot.motionPaused ? 'motion frozen' : 'moving'} · {phrase.dragged ? 'selected' : 'free'}
  • ))}
diff --git a/ui/src/bridge/transportBridge.ts b/ui/src/bridge/transportBridge.ts index 99a066b..0d6d8b7 100644 --- a/ui/src/bridge/transportBridge.ts +++ b/ui/src/bridge/transportBridge.ts @@ -20,6 +20,10 @@ export interface EngineDiagnostics { collisionContactBeginCount: number collisionIntentQueuedCount: number collisionTransitionAppliedCount: number + speedBandChangeCount: number + speedIntentQueuedCount: number + speedIntentSuppressedCount: number + speedTransitionAppliedCount: number commandQueueDepth: number maximumCommandQueueDepth: number coalescedMoveCount: number @@ -28,6 +32,7 @@ export interface EngineDiagnostics { } export type PhraseRole = 'rhythm' | 'bass' | 'harmony' | 'lead' +export type ActivityBand = 'sparse' | 'normal' | 'active' export interface PhraseSnapshot { id: string @@ -36,6 +41,10 @@ export interface PhraseSnapshot { currentVariantId: string pendingVariantId: string | null pendingVariantApplyBeat: number | null + rawNormalizedSpeed: number + smoothedNormalizedSpeed: number + activityBand: ActivityBand + pendingActivityBand: ActivityBand | null midiChannel: number position: { x: number; y: number } velocity: { x: number; y: number } @@ -52,6 +61,10 @@ export interface WorldDiagnostics { collisionContactBeginCount: number collisionIntentQueuedCount: number collisionTransitionAppliedCount: number + speedBandChangeCount: number + speedIntentQueuedCount: number + speedIntentSuppressedCount: number + speedTransitionAppliedCount: number droppedSnapshotCount: number maximumSnapshotIntervalMs: number commandQueueDepth: number @@ -120,6 +133,10 @@ export const initialTransportState: TransportState = { collisionContactBeginCount: 0, collisionIntentQueuedCount: 0, collisionTransitionAppliedCount: 0, + speedBandChangeCount: 0, + speedIntentQueuedCount: 0, + speedIntentSuppressedCount: 0, + speedTransitionAppliedCount: 0, commandQueueDepth: 0, maximumCommandQueueDepth: 0, coalescedMoveCount: 0, @@ -142,6 +159,10 @@ export const initialWorldSnapshot: WorldSnapshot = { collisionContactBeginCount: 0, collisionIntentQueuedCount: 0, collisionTransitionAppliedCount: 0, + speedBandChangeCount: 0, + speedIntentQueuedCount: 0, + speedIntentSuppressedCount: 0, + speedTransitionAppliedCount: 0, droppedSnapshotCount: 0, maximumSnapshotIntervalMs: 0, commandQueueDepth: 0, @@ -300,6 +321,10 @@ function isTransportState(payload: unknown): payload is TransportState { typeof diagnostics.collisionContactBeginCount === 'number' && typeof diagnostics.collisionIntentQueuedCount === 'number' && typeof diagnostics.collisionTransitionAppliedCount === 'number' && + typeof diagnostics.speedBandChangeCount === 'number' && + typeof diagnostics.speedIntentQueuedCount === 'number' && + typeof diagnostics.speedIntentSuppressedCount === 'number' && + typeof diagnostics.speedTransitionAppliedCount === 'number' && typeof diagnostics.commandQueueDepth === 'number' && typeof diagnostics.maximumCommandQueueDepth === 'number' && typeof diagnostics.coalescedMoveCount === 'number' && @@ -344,6 +369,14 @@ function isWorldSnapshot(payload: unknown): payload is WorldSnapshot { (diagnostics.collisionIntentQueuedCount ?? -1) < 0 || !Number.isSafeInteger(diagnostics.collisionTransitionAppliedCount) || (diagnostics.collisionTransitionAppliedCount ?? -1) < 0 || + !Number.isSafeInteger(diagnostics.speedBandChangeCount) || + (diagnostics.speedBandChangeCount ?? -1) < 0 || + !Number.isSafeInteger(diagnostics.speedIntentQueuedCount) || + (diagnostics.speedIntentQueuedCount ?? -1) < 0 || + !Number.isSafeInteger(diagnostics.speedIntentSuppressedCount) || + (diagnostics.speedIntentSuppressedCount ?? -1) < 0 || + !Number.isSafeInteger(diagnostics.speedTransitionAppliedCount) || + (diagnostics.speedTransitionAppliedCount ?? -1) < 0 || !Number.isSafeInteger(diagnostics.droppedSnapshotCount) || (diagnostics.droppedSnapshotCount ?? -1) < 0 || !isFiniteNumber(diagnostics.maximumSnapshotIntervalMs) || @@ -381,6 +414,15 @@ function isWorldSnapshot(payload: unknown): payload is WorldSnapshot { candidate.pendingVariantApplyBeat >= 0)) && ((candidate.pendingVariantId === null) === (candidate.pendingVariantApplyBeat === null)) && + isFiniteNumber(candidate.rawNormalizedSpeed) && + candidate.rawNormalizedSpeed >= 0 && + candidate.rawNormalizedSpeed <= 1 && + isFiniteNumber(candidate.smoothedNormalizedSpeed) && + candidate.smoothedNormalizedSpeed >= 0 && + candidate.smoothedNormalizedSpeed <= 1 && + ['sparse', 'normal', 'active'].includes(candidate.activityBand ?? '') && + (candidate.pendingActivityBand === null || + ['sparse', 'normal', 'active'].includes(candidate.pendingActivityBand ?? '')) && Number.isSafeInteger(candidate.midiChannel) && (candidate.midiChannel ?? 0) >= 1 && (candidate.midiChannel ?? 0) <= 16 && diff --git a/ui/src/dragInteraction.test.ts b/ui/src/dragInteraction.test.ts index b397790..5832647 100644 --- a/ui/src/dragInteraction.test.ts +++ b/ui/src/dragInteraction.test.ts @@ -19,6 +19,10 @@ const bass: PhraseSnapshot = { currentVariantId: 'A', pendingVariantId: null, pendingVariantApplyBeat: null, + rawNormalizedSpeed: 0.034, + smoothedNormalizedSpeed: 0.034, + activityBand: 'normal', + pendingActivityBand: null, midiChannel: 1, position: { x: 0.2, y: 0.28 }, velocity: { x: 0.045, y: 0.025 }, @@ -43,6 +47,10 @@ function snapshot(sequence: number, dragged = false): WorldSnapshot { collisionContactBeginCount: 0, collisionIntentQueuedCount: 0, collisionTransitionAppliedCount: 0, + speedBandChangeCount: 0, + speedIntentQueuedCount: 0, + speedIntentSuppressedCount: 0, + speedTransitionAppliedCount: 0, droppedSnapshotCount: 0, maximumSnapshotIntervalMs: 0, commandQueueDepth: 0, diff --git a/ui/src/worldInterpolation.test.ts b/ui/src/worldInterpolation.test.ts index b706e60..c1b1be5 100644 --- a/ui/src/worldInterpolation.test.ts +++ b/ui/src/worldInterpolation.test.ts @@ -17,6 +17,10 @@ function snapshot(sequence: number, x: number, y: number): WorldSnapshot { currentVariantId: 'A', pendingVariantId: null, pendingVariantApplyBeat: null, + rawNormalizedSpeed: 0.033, + smoothedNormalizedSpeed: 0.033, + activityBand: 'normal', + pendingActivityBand: null, midiChannel: 1, position: { x, y }, velocity: { x: 0.03, y: 0.04 }, @@ -34,6 +38,10 @@ function snapshot(sequence: number, x: number, y: number): WorldSnapshot { collisionContactBeginCount: 0, collisionIntentQueuedCount: 0, collisionTransitionAppliedCount: 0, + speedBandChangeCount: 0, + speedIntentQueuedCount: 0, + speedIntentSuppressedCount: 0, + speedTransitionAppliedCount: 0, droppedSnapshotCount: sequence * 3, maximumSnapshotIntervalMs: 34, commandQueueDepth: 0,