Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ target_link_libraries(Drift
juce::juce_recommended_warning_flags
)
add_dependencies(Drift DriftUIBundle)
# UI-only changes must relink Drift so the post-build bundle copy runs.
set_property(TARGET Drift APPEND PROPERTY LINK_DEPENDS ${DRIFT_UI_OUTPUTS})

add_custom_command(TARGET Drift POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E rm -rf "$<TARGET_FILE_DIR:Drift>/../Resources/ui"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ New contacts are resolved in the table's stable pair order. If simultaneous cont

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.

Proximity currently has two deliberately temporary audition modes. Both derive a loose, linked, or tight coupling level from the smoothed surface gap between every phrase pair, with stable changes taking effect at the next eligible unscheduled bar. **Rhythm profiles** snap nearby phrases toward half-beat or beat grids without changing their notes, durations, or dynamics. **Shared accents** leave timing and density untouched and emphasize notes that already begin together. The selector changes modes on the next bar so the alternatives can be compared during uninterrupted playback; neither is yet designated as the production mapping.
Proximity offers two complementary musical modes. Both derive a loose, linked, or tight coupling level from the smoothed surface gap between every phrase pair, with stable changes taking effect at the next eligible unscheduled bar. **Lock Rhythm** snaps nearby phrases toward half-beat or beat grids without changing their notes, durations, or dynamics. **Accent Together** leaves timing and density untouched and emphasizes notes that already begin together. The musician chooses the behavior, and mode changes take effect on the next bar without interrupting playback.

## Architecture

Expand Down Expand Up @@ -102,7 +102,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, proximity-audition, 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. Unique collisions, stable speed-band crossings, and stable pair-coupling changes queue deterministic changes at the next eligible unscheduled bar. Proximity transforms the resolved collision/speed material rather than selecting another variant. Physics and input pressure remain independent of musical time, and the interface exposes motion state, phrase speeds, activity bands, variants, exact pair proximity and coupling state, audition mode, transition counts, timing, catch-up, queue, coalescing, rejection, and snapshot diagnostics.
The native shell now connects React Play, Stop, Freeze Motion, BPM, MIDI-output, proximity-mode, 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. Unique collisions, stable speed-band crossings, and stable pair-coupling changes queue deterministic changes at the next eligible unscheduled bar. Proximity transforms the resolved collision/speed material rather than selecting another variant. Physics and input pressure remain independent of musical time, and the interface exposes motion state, phrase speeds, activity bands, variants, exact pair proximity and coupling state, proximity mode, 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.

Expand Down
12 changes: 6 additions & 6 deletions docs/TECHNICAL-DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ Initial command set:
| `phrase.move` | Set target position during a drag |
| `phrase.dragEnd` | End direct manipulation without a throw |
| `phrase.throw` | End manipulation with release velocity |
| `proximity.setAuditionMode` | Queue the selected proximity experiment for the next bar |
| `proximity.setAuditionMode` | Queue the selected proximity mode for the next bar |
| `debug.setEnabled` | Enable or disable debug data publication |

Example:
Expand Down Expand Up @@ -428,12 +428,12 @@ Initial mappings:
- `SpeedActivityMapping`: smoothed speed selects sparse, normal, or active material at the next bar.
- `ProximityRhythmMapping`: pairwise proximity selects a rhythmic-coupling state at a configured quantization boundary.

`ProximityRhythmMapping` is being auditioned in two modes. Both run after collision and speed have resolved the active `A`/`B`/`C` phrase material:
`ProximityRhythmMapping` provides two musician-selected modes. Both run after collision and speed have resolved the active `A`/`B`/`C` phrase material:

- **Rhythm profiles:** a phrase takes the strongest coupling it has with any neighbour. Loose leaves authored onsets unchanged, linked snaps them to the nearest half beat, and tight snaps them to the nearest beat. Pitch, duration, and velocity are preserved; chord notes remain simultaneous, and exact duplicate pitch/onset results are coalesced.
- **Shared accents:** timing and density remain unchanged. Exact onsets shared by a pair gain `+12` velocity when linked or `+24` when tight, clamped to MIDI velocity 127. When several neighbours qualify, the maximum boost wins rather than summing boosts.
- **Lock Rhythm** (`rhythmProfiles`): a phrase takes the strongest coupling it has with any neighbour. Loose leaves authored onsets unchanged, linked snaps them to the nearest half beat, and tight snaps them to the nearest beat. Pitch, duration, and velocity are preserved; chord notes remain simultaneous, and exact duplicate pitch/onset results are coalesced.
- **Accent Together** (`sharedAccents`): timing and density remain unchanged. Exact onsets shared by a pair gain `+12` velocity when linked or `+24` when tight, clamped to MIDI velocity 127. When several neighbours qualify, the maximum boost wins rather than summing boosts.

Changing audition mode is itself bar-quantized and does not stop transport or invalidate already-scheduled MIDI. The selector and pair relationship lines are evaluation instrumentation; neither candidate is yet the chosen production mapping.
Changing mode is itself bar-quantized and does not stop transport or invalidate already-scheduled MIDI. Live MIDI evaluation found both behaviors useful with different phrase material, so the selector remains an explicit musical control; Drift does not switch modes automatically or by pair.

`CollisionVariantMapping` uses the six stable unordered pair rules below. The target advances through its authored variant order `A → B → C → A`.

Expand Down Expand Up @@ -610,7 +610,7 @@ The engine records bounded diagnostic counters rather than unbounded logs:
- Active contacts and collision cooldowns.
- Pending and applied intents.
- Raw, smoothed, stable, and pending state for all six proximity pairs.
- Current/pending proximity audition mode and proximity transition/mode counters.
- Current/pending proximity mode and proximity transition/mode counters.
- Current scheduling watermark.

The React debug overlay reads these through snapshots or low-rate debug events.
Expand Down
4 changes: 2 additions & 2 deletions ui/src/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ describe('Drift bridge interface', () => {
expect(screen.getByText('0.125 ms')).toBeTruthy()
expect(screen.getByText('Moving')).toBeTruthy()

fireEvent.change(screen.getByLabelText('Proximity audition mode'), {
fireEvent.change(screen.getByLabelText('Proximity mode'), {
target: { value: 'sharedAccents' },
})
expect(bridge.commands.at(-1)).toMatchObject({
Expand Down Expand Up @@ -408,7 +408,7 @@ describe('Drift bridge interface', () => {
pendingProximity.payload.pendingProximityModeApplyBeat = 4
act(() => bridge.publish(pendingProximity))
expect(container.textContent).toContain('loose → linked')
expect(container.textContent).toContain('Rhythm profiles → Shared accents')
expect(container.textContent).toContain('Lock Rhythm → Accent Together')

const pendingWorld = worldEvent(6)
pendingWorld.payload.phrases[1].pendingVariantId = 'B'
Expand Down
10 changes: 5 additions & 5 deletions ui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export function App({ bridge }: AppProps) {
<label className="proximity-mode-control">
<span>Proximity</span>
<select
aria-label="Proximity audition mode"
aria-label="Proximity mode"
disabled={!controlsReady}
onChange={(event) =>
transportBridge.send(createCommand({
Expand All @@ -167,8 +167,8 @@ export function App({ bridge }: AppProps) {
}
value={proximityModeValue}
>
<option value="rhythmProfiles">Rhythm profiles</option>
<option value="sharedAccents">Shared accents</option>
<option value="rhythmProfiles">Lock Rhythm</option>
<option value="sharedAccents">Accent Together</option>
</select>
</label>
</div>
Expand Down Expand Up @@ -281,9 +281,9 @@ export function App({ bridge }: AppProps) {
<div>
<dt>Proximity mode</dt>
<dd>
{worldSnapshot.proximityMode === 'rhythmProfiles' ? 'Rhythm profiles' : 'Shared accents'}
{worldSnapshot.proximityMode === 'rhythmProfiles' ? 'Lock Rhythm' : 'Accent Together'}
{worldSnapshot.pendingProximityMode
? ` → ${worldSnapshot.pendingProximityMode === 'rhythmProfiles' ? 'Rhythm profiles' : 'Shared accents'}`
? ` → ${worldSnapshot.pendingProximityMode === 'rhythmProfiles' ? 'Lock Rhythm' : 'Accent Together'}`
: ''}
</dd>
</div>
Expand Down