Skip to content
Merged
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
1,710 changes: 860 additions & 850 deletions app/src/main/cpp/AudioEngine.cpp

Large diffs are not rendered by default.

32 changes: 7 additions & 25 deletions app/src/main/cpp/AutoDJProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,12 @@ AutoDJDecision AutoDJProcessor::evaluate(
if (nextStage == TrackLifecycleStage::STREAM_RESOLVED) {
return AutoDJDecision::DECODE_HEAD_WINDOW;
}
if (nextStage == TrackLifecycleStage::DECODING_HEAD_WINDOW) {
return AutoDJDecision::ARM_STANDBY;
}
return AutoDJDecision::DO_NOTHING;
}

const int64_t remainingMs = std::max<int64_t>(0, durationMs - currentPositionMs);
const int64_t leadWindowMs = m_latencyEstimator.calculateDynamicLeadWindowMs(transitionDurationMs);
const int64_t armLeadThresholdMs = ADVANCE_ARM_LEAD_MS + transitionDurationMs; // 40s + transition

// 5. Track finished or at transition edge
// 5. Track finished: remainingMs <= 0
if (remainingMs <= 0) {
if (nextStage == TrackLifecycleStage::ARMED_READY) {
return AutoDJDecision::TRIGGER_TRANSITION;
Expand All @@ -74,33 +69,20 @@ AutoDJDecision AutoDJProcessor::evaluate(

// 6. Active playback progression
if (isPlaying) {
// Trigger transition right at exit cue
// Trigger transition right at exit cue ONLY if armed and ready
if (remainingMs <= transitionDurationMs && nextStage == TrackLifecycleStage::ARMED_READY) {
return AutoDJDecision::TRIGGER_TRANSITION;
}

// Keep index + 1 fully armed at least 40s before planned exit cue
if (remainingMs <= armLeadThresholdMs) {
if (nextStage == TrackLifecycleStage::STREAM_RESOLVED) {
return AutoDJDecision::DECODE_HEAD_WINDOW;
}
if (nextStage == TrackLifecycleStage::DECODING_HEAD_WINDOW) {
return AutoDJDecision::ARM_STANDBY;
}
}

// Never wait until track end: start resolving immediate next track as early as leadWindowMs
// (or immediately at track start)
// Immediate eager prefetch and pre-decode:
if (nextStage == TrackLifecycleStage::QUEUED) {
return AutoDJDecision::RESOLVE_NEXT_STREAM;
}

// If inside transition window and next track is still in-flight
if (remainingMs <= transitionDurationMs &&
(nextStage == TrackLifecycleStage::RESOLVING_STREAM ||
nextStage == TrackLifecycleStage::DECODING_HEAD_WINDOW)) {
return AutoDJDecision::WAIT_FOR_LATE_TRACK;
if (nextStage == TrackLifecycleStage::STREAM_RESOLVED) {
return AutoDJDecision::DECODE_HEAD_WINDOW;
}

// At transition edge, if not armed ready, return DO_NOTHING so Deck A plays naturally to end
}

return AutoDJDecision::DO_NOTHING;
Expand Down
18 changes: 18 additions & 0 deletions app/src/main/cpp/AutoMixBridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,24 @@ Java_com_lastwave_app_playback_NativeAutoMixEngine_nativeGetDeckBLeadingTrimFram
return (engine != nullptr) ? static_cast<jlong>(engine->getDeckBLeadingTrimFrames()) : 0L;
}

JNIEXPORT jfloat JNICALL
Java_com_lastwave_app_playback_NativeAutoMixEngine_nativeGetDeckBAvailableSeconds(
JNIEnv*,
jclass,
jlong handle) {
auto* engine = fromHandle(handle);
return (engine != nullptr) ? engine->getDeckBAvailableSeconds() : 0.0F;
}

JNIEXPORT jlong JNICALL
Java_com_lastwave_app_playback_NativeAutoMixEngine_nativeGetDeckBAvailableFrames(
JNIEnv*,
jclass,
jlong handle) {
auto* engine = fromHandle(handle);
return (engine != nullptr) ? static_cast<jlong>(engine->getDeckBAvailableFrames()) : 0L;
}

JNIEXPORT jfloat JNICALL
Java_com_lastwave_app_playback_NativeAutoMixEngine_nativeGetDeckABpm(
JNIEnv*,
Expand Down
Loading
Loading