sequencer play fix.

This commit is contained in:
Johannes Findeisen 2026-11-06 22:00:35 +01:00
commit d6ded83beb
16 changed files with 372 additions and 16 deletions

View file

@ -913,13 +913,16 @@ void MainWindow::start_engine()
if (result != XTC_OK)
report_error("Start failed; check audio and saved MIDI devices in Preferences", result);
else {
set_label(error_, "");
set_label(error_, midi_route_warning_.c_str());
const char *issue = xtc_backend_asset_issue(backend_);
if (issue[0]) {
char message[640];
std::snprintf(message, sizeof(message),
"Missing/unreadable audio (silent): %s. Use File/Relink selected audio or Load sampler WAV to repair.", issue);
set_label(error_, message);
std::string warning=midi_route_warning_;
if(!warning.empty())warning+=" ";
warning+=message;
set_label(error_, warning.c_str());
}
}
refresh_status();
@ -2573,8 +2576,41 @@ std::vector<std::string> MainWindow::midi_devices(bool input)
}
xtc_result MainWindow::start_configured_backend()
{
midi_route_warning_.clear();
const char *input=settings_.midi_input_port, *output=settings_.midi_output_port;
// Saved production devices are optional. Keep their names so a later start
// reconnects them, but do not ask the strict backend API to route absent ports.
auto available=[this](const char *name, xtc_port_direction direction, bool &found) {
struct Search { const char *name; bool found; } search{name,false};
xtc_result result=xtc_backend_visit_midi_ports(backend_,direction,
[](const char *port,void *context) {
auto &search=*static_cast<Search *>(context);
search.found=std::strcmp(port,search.name)==0;
return search.found ? 1 : 0;
},&search);
found=search.found;
return result;
};
auto optional_route=[&](const char *&name,xtc_port_direction direction) {
if(!*name)return XTC_OK;
bool found=false;
xtc_result result=available(name,direction,found);
if(result==XTC_OK && !found) {
if(midi_route_warning_.empty())midi_route_warning_="MIDI device unavailable: ";
else midi_route_warning_+=", ";
midi_route_warning_+=name;
name="";
}
return result;
};
xtc_result r=xtc_backend_set_midi_options(backend_,static_cast<int>(settings_.midi_input_channel),static_cast<int>(settings_.midi_output_channel),settings_.midi_thru!=0);
if(r==XTC_OK)r=xtc_backend_start_routed(backend_,settings_.midi_input_port,settings_.midi_output_port);
if(r==XTC_OK)r=optional_route(input,XTC_PORT_OUTPUT);
if(r==XTC_OK)r=optional_route(output,XTC_PORT_INPUT);
if(r==XTC_OK)r=xtc_backend_start_routed(backend_,input,output);
if(r==XTC_OK) {
if(!midi_route_warning_.empty())midi_route_warning_+=". Playback continues; saved device choices are kept.";
set_label(error_,midi_route_warning_.c_str());
}
return r;
}
void MainWindow::show_preferences()

View file

@ -254,6 +254,7 @@ class MainWindow : public Fl_Double_Window {
bool transport_detached_=false, mixer_detached_=false;
xtc_settings settings_{};
std::string configuration_;
std::string midi_route_warning_;
bool configuration_valid_=true;
Fl_Check_Button *loop_button_=nullptr;
xtc_result configure_loop(const xtc_project *project,const xtc_settings &settings);

View file

@ -84,7 +84,7 @@ class PreferencesDialog : public Fl_Double_Window {
}
if(scroll) { scroll->end(); group->end(); } tabs->end();
tabs->begin();auto *midi_info=new Fl_Group(12,82,1026,478,"MIDI help");
auto *help=new Fl_Box(42,110,950,190,"Choose JACK/PipeWire MIDI ports on the midi tab. Refresh to see newly connected devices.\nYou can also type a remembered port name while it is offline; blank means no automatic route.\nRouting is restored on Play/Record; missing ports are reported without deleting preferences.\nInput/output channels use 0..15 for MIDI channels 1..16. MIDI thru defaults off.\nNote length/velocity/channel defaults are on editing; CC defaults are on project_defaults.\nHardware MIDI devices must be exposed by your host JACK/PipeWire MIDI bridge.");
auto *help=new Fl_Box(42,110,950,190,"Choose JACK/PipeWire MIDI ports on the midi tab. Refresh to see newly connected devices.\nYou can also type a remembered port name while it is offline; blank means no automatic route.\nRouting is restored on Play/Record; missing ports are skipped with a warning; playback continues and choices stay saved.\nInput/output channels use 0..15 for MIDI channels 1..16. MIDI thru defaults off.\nNote length/velocity/channel defaults are on editing; CC defaults are on project_defaults.\nHardware MIDI devices must be exposed by your host JACK/PipeWire MIDI bridge.");
help->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE|FL_ALIGN_WRAP);midi_info->end();tabs->end();
refresh_devices();
auto *refresh=new Fl_Button(16,614,200,30,"Refresh MIDI devices");