Feat: demo songs
This commit is contained in:
40
src/init.rs
40
src/init.rs
@@ -65,14 +65,38 @@ pub fn init(args: InitArgs) -> Init {
|
||||
|
||||
let mut app = App::new();
|
||||
|
||||
app.playback.queued_changes.push(StagedChange {
|
||||
change: PatternChange::Start {
|
||||
bank: 0,
|
||||
pattern: 0,
|
||||
},
|
||||
quantization: model::LaunchQuantization::Immediate,
|
||||
sync_mode: model::SyncMode::PhaseLock,
|
||||
});
|
||||
app.ui.load_demo_on_startup = settings.display.load_demo_on_startup;
|
||||
app.ui.demo_index = settings.display.demo_index;
|
||||
|
||||
if app.ui.load_demo_on_startup && !model::demos::DEMOS.is_empty() {
|
||||
let count = model::demos::DEMOS.len();
|
||||
let index = settings.display.demo_index % count;
|
||||
let demo = &model::demos::DEMOS[index];
|
||||
if let Ok(project) = model::load_str(demo.json) {
|
||||
let playing = project.playing_patterns.clone();
|
||||
let tempo = project.tempo;
|
||||
app.project_state.project = project;
|
||||
link.set_tempo(tempo);
|
||||
for (bank, pattern) in playing {
|
||||
app.playback.queued_changes.push(StagedChange {
|
||||
change: PatternChange::Start { bank, pattern },
|
||||
quantization: model::LaunchQuantization::Immediate,
|
||||
sync_mode: model::SyncMode::PhaseLock,
|
||||
});
|
||||
}
|
||||
app.ui.set_status(format!("Demo: {}", demo.name));
|
||||
}
|
||||
app.ui.demo_index = (index + 1) % count;
|
||||
} else {
|
||||
app.playback.queued_changes.push(StagedChange {
|
||||
change: PatternChange::Start {
|
||||
bank: 0,
|
||||
pattern: 0,
|
||||
},
|
||||
quantization: model::LaunchQuantization::Immediate,
|
||||
sync_mode: model::SyncMode::PhaseLock,
|
||||
});
|
||||
}
|
||||
|
||||
app.audio.config.output_device = args.output.or(settings.audio.output_device.clone());
|
||||
app.audio.config.input_device = args.input.or(settings.audio.input_device.clone());
|
||||
|
||||
Reference in New Issue
Block a user