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
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ jobs:
done
pactl info
cargo test -p amp-player --bin amp-player dj_logic::tests::regular_playlist_automatic_preload_shuffle_cancel_and_handoff --locked -- --ignored --exact --test-threads=1 --nocapture
cargo test -p amp-player --bin amp-player dj_logic::tests::ten_ungridded_auto_handoffs_apply_time_effects_and_record_grid_skips --locked -- --ignored --exact --test-threads=1 --nocapture
cargo test -p amp-player --bin amp-player dj_logic::tests::dislike_regular_skips_immediately_and_persists_membership --locked -- --ignored --exact --test-threads=1 --nocapture
cargo test -p amp-player --bin amp-player dj_logic::tests::smart_cycle_only_consumes_audible_loads_not_cancelled_preloads --locked -- --ignored --exact --test-threads=1
cargo test -p amp-player --bin amp-player deck_rack::cards::tests::actual_live_button_preserves_three_clocked_sources_and_manual_state --locked -- --ignored --exact --test-threads=1 --nocapture
Expand Down
7 changes: 6 additions & 1 deletion apps/amp-player/src/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1693,8 +1693,13 @@ mod tests {
#[test]
fn live_start_waits_for_capability_and_times_out_readably() {
let temp = tempfile::tempdir().unwrap();
let mut dashboard = Dashboard::default();
let (mut dashboard, commands, _) = mock_dashboard();
dashboard.request_live(true);
assert!(matches!(commands.recv().unwrap(), Command::Connect(..)));
assert!(
dashboard.worker_guard.is_none(),
"Timeout checks must not contact a real station"
);
assert!(dashboard.busy);
assert!(dashboard.live_player_only);
assert_eq!(dashboard.endpoint().0, "127.0.0.1:8787");
Expand Down
114 changes: 114 additions & 0 deletions apps/amp-player/src/dj_settings.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,119 @@
//! One settings window for top-level DJ choices; no nested selection menus.
use super::*;
impl Player {
fn trick_grid_summary(&mut self, ui: &mut egui::Ui) {
type Cached = (String, u64, u64, std::sync::Arc<Vec<PathBuf>>, usize);
let id = egui::Id::unique("trick-grid-summary");
let key = format!(
"{}:{:?}:{:?}:{}",
self.root.display(),
self.run.playlist,
self.run.profile.as_ref().map(|p| &p.id),
self.queue.len()
);
let cached = ui.ctx().data(|d| d.get_temp::<Cached>(id));
let cached = cached.filter(|(old, generation, revision, _, _)| {
old == &key
&& *generation == self.library_generation
&& *revision == self.preparer.grid.revision
});
let (_, _, _, paths, reliable) = cached.unwrap_or_else(|| {
let paths: Vec<PathBuf> = self
.library
.as_ref()
.map(|lib| {
if let Some(profile) = &self.run.profile {
lib.tracks
.iter()
.filter(|t| amp_core::show::eligible(profile, t))
.map(|t| t.path.clone())
.collect()
} else if self.run.has_regular_playlist() {
self.playlist_snapshot
.as_ref()
.filter(|(_, p)| self.run.playlist.as_deref() == Some(p.name.as_str()))
.map(|(_, p)| p.tracks.clone())
.unwrap_or_else(|| {
self.queue
.iter()
.filter_map(|i| lib.tracks.get(*i).map(|t| t.path.clone()))
.collect()
})
} else {
Vec::new()
}
})
.unwrap_or_default();
let reliable = self
.library
.as_ref()
.map(|lib| {
let tracks: std::collections::HashMap<_, _> = lib
.tracks
.iter()
.map(|t| {
(
&t.path,
amp_core::mix_schedule::timing_reliable(&t.preparation),
)
})
.collect();
paths
.iter()
.filter(|p| tracks.get(p).copied().unwrap_or(false))
.count()
})
.unwrap_or(0);
let value = (
key,
self.library_generation,
self.preparer.grid.revision,
std::sync::Arc::new(paths),
reliable,
);
ui.ctx().data_mut(|d| d.insert_temp(id, value.clone()));
value
});
ui.horizontal_wrapped(|ui| {
ui.label(format!(
"Reliable beat grids: {reliable} / {} songs",
paths.len()
));
if ui
.add_enabled(!paths.is_empty(), egui::Button::new("Review grids…"))
.clicked()
&& let Some(lib) = &self.library
&& let Some(track) = paths
.iter()
.filter_map(|p| lib.tracks.iter().find(|t| &t.path == p))
.find(|t| amp_core::grid_review::status(&t.preparation).needs_review())
.or_else(|| {
paths
.first()
.and_then(|p| lib.tracks.iter().find(|t| &t.path == p))
})
{
self.preparer
.grid
.select(&self.root, track, paths.as_ref().clone());
self.library_open = true;
self.library_page = 0;
self.workspace.pane = 1;
}
if ui.button("Refresh count").clicked() {
ui.ctx().data_mut(|d| d.remove::<Cached>(id));
}
});
if let Some(error) = self.run.trick_history_failure() {
ui.weak(format!("Technique history: {error}"));
}
if !self.run.trick_decision.reason.is_empty() {
ui.label(format!("Last mix: {}", self.run.trick_decision.reason));
for attempt in &self.run.trick_decision.skipped {
ui.weak(format!("{}: {}", attempt.style.label(), attempt.reason));
}
}
}
pub(super) fn open_dj_settings(&self, ctx: &egui::Context) {
ctx.data_mut(|d| {
d.insert_temp(egui::Id::unique("dj-settings-open"), true);
Expand Down Expand Up @@ -34,6 +147,7 @@ impl Player {
if old!=self.fade_seconds && let Err(error)=crossfade_settings::save(self.fade_seconds){self.status=error.to_string();}
ui.separator();
egui::CollapsingHeader::new("Transitions and effects").show(ui, |ui| {
self.trick_grid_summary(ui);
let previous = self.run.transitions;
if transition_controls::inline(ui, &mut self.run.transitions, &mut self.wave_span,
self.run.auto && self.run.pending.is_none() && !self.audio.as_ref().is_some_and(|a| a.fading())) {
Expand Down
1 change: 1 addition & 0 deletions apps/amp-player/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ mod track_columns;
mod track_sort;
mod transition_controls;
mod transition_styles;
mod trick_history;
#[allow(dead_code)] // Shared implementation also used by the standalone installer binary.
mod update_package;
mod v1_profile;
Expand Down
17 changes: 14 additions & 3 deletions apps/amp-player/src/mixer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3179,12 +3179,12 @@ impl Engine {
grid,
})
}
pub fn scratch_crossfade(
pub fn scratch_plan(
&self,
seconds: f32,
mut grid: crate::mix_schedule::Grid,
beat: f32,
) -> Result<(), String> {
) -> Result<crate::mix_schedule::Grid, String> {
let incoming = self.controls.pair_indices()[usize::from(self.fader() < 0.5)];
let outgoing = self.controls.other(incoming);
if !seconds.is_finite()
Expand Down Expand Up @@ -3228,13 +3228,24 @@ impl Engine {
{
return Err("Not enough audio for a scratch-in".into());
}
Ok(grid)
}
pub fn scratch_crossfade(
&self,
seconds: f32,
grid: crate::mix_schedule::Grid,
beat: f32,
) -> Result<(), String> {
let grid = self.scratch_plan(seconds, grid, beat)?;
let incoming = self.controls.pair_indices()[usize::from(self.fader() < 0.5)];
self.send(Command::ScratchFade {
to: (incoming % 2) as f32,
seconds,
seconds: seconds.min(beat),
beat,
grid,
})
}

pub fn scheduled_crossfade(
&self,
seconds: f32,
Expand Down
Loading
Loading