This commit is contained in:
Johannes Findeisen 2026-10-28 17:16:01 +01:00
commit 02e27a33a2
47 changed files with 882 additions and 62 deletions

102
src/gui/command_palette.hpp Normal file
View file

@ -0,0 +1,102 @@
#ifndef XTC_COMMAND_PALETTE_HPP
#define XTC_COMMAND_PALETTE_HPP
#include "theme.hpp"
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Input.H>
#include <FL/Fl_Hold_Browser.H>
#include <algorithm>
#include <cctype>
#include <string>
#include <vector>
/* UI command search only; execute the chosen action after this modal is gone. */
class CommandPalette : public Fl_Double_Window
{
std::vector<std::string> commands_, visible_;
Fl_Input *search_;
Fl_Hold_Browser *list_;
std::string selected_;
static std::string lower(std::string value)
{
for (auto &c : value)
c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
return value;
}
void filter()
{
list_->clear();
visible_.clear();
const auto query = lower(search_->value());
for (const auto &command : commands_)
if (lower(command).find(query) != std::string::npos) {
visible_.push_back(command);
list_->add(command.c_str());
}
if (!visible_.empty())
list_->select(1);
}
void accept()
{
int i = list_->value();
if (i > 0 && static_cast<size_t>(i) <= visible_.size()) {
selected_ = visible_[static_cast<size_t>(i - 1)];
hide();
}
}
public:
explicit CommandPalette(std::vector<std::string> commands)
: Fl_Double_Window(700, 440, "xtc — Commands"), commands_(std::move(commands))
{
set_modal();
begin();
search_ = new Fl_Input(136, 18, 544, 32, "Search commands");
search_->when(FL_WHEN_CHANGED);
search_->callback([](Fl_Widget *, void *p) { static_cast<CommandPalette *>(p)->filter(); }, this);
list_ = new Fl_Hold_Browser(20, 64, 660, 302);
list_->format_char(0);
list_->callback(
[](Fl_Widget *, void *p) {
if (Fl::event_clicks())
static_cast<CommandPalette *>(p)->accept();
},
this);
auto *cancel = new Fl_Button(450, 390, 100, 30, "Cancel");
cancel->callback([](Fl_Widget *, void *p) { static_cast<CommandPalette *>(p)->hide(); }, this);
auto *run = new Fl_Button(564, 390, 116, 30, "Run command");
run->callback([](Fl_Widget *, void *p) { static_cast<CommandPalette *>(p)->accept(); }, this);
callback([](Fl_Widget *, void *p) { static_cast<CommandPalette *>(p)->hide(); }, this);
end();
xtc_ui::style(this);
filter();
}
int handle(int event) override
{
if (event == FL_KEYDOWN) {
int key = Fl::event_key();
if (key == FL_Enter || key == FL_KP_Enter) {
accept();
return 1;
}
if (key == FL_Escape) {
hide();
return 1;
}
if ((key == FL_Up || key == FL_Down) && !visible_.empty()) {
list_->select(
std::clamp(list_->value() + (key == FL_Up ? -1 : 1), 1, static_cast<int>(visible_.size())));
return 1;
}
}
return Fl_Double_Window::handle(event);
}
std::string run()
{
show();
search_->take_focus();
while (shown())
Fl::wait();
return selected_;
}
};
#endif

View file

@ -8,6 +8,8 @@
#include "snap.hpp"
#include "velocity_lane.hpp"
#include "preferences_dialog.hpp"
#include "command_palette.hpp"
#include <FL/Fl_Value_Input.H>
#include "plugin_library.hpp"
#include <FL/Fl_Check_Button.H>
#include <FL/Fl_Choice.H>
@ -32,6 +34,11 @@
#include <cerrno>
namespace {
bool editing_number(Fl_Value_Input *input)
{
return Fl::focus() == input || Fl::focus() == &input->input || Fl::pushed() == input ||
Fl::pushed() == &input->input;
}
/**
* @brief Updates a box label only when the text differs.
*
@ -103,12 +110,18 @@ MainWindow::MainWindow(bool prompt_unsaved,const char *configuration)
menu->add("Edit/Redo alternate", FL_CTRL + 'y', history_callback, this);
menu->add("Audio/MIDI controller mapping", 0, control_map_callback, this);
menu->add("Audio/Panic", FL_F + 9, panic_callback, this);
menu->add("View/Commands",FL_CTRL+'p',[](Fl_Widget *,void *c){static_cast<MainWindow *>(c)->show_commands();},this);
menu->add("View/Fit song",FL_CTRL+'0',[](Fl_Widget *,void *c){static_cast<MainWindow *>(c)->fit_song();},this);
menu->add("View/Piano roll", FL_CTRL + '4', piano_callback, this);
menu->add("Audio/Record WAV", FL_SHIFT + FL_F + 5, audio_file_callback, this);
menu->add("Track/Load instrument plugin", 0, instrument_callback, this);
menu->add("Track/Use built-in instrument", 0, instrument_callback, this);
menu->add("Track/Live MIDI to selected instrument", 0, instrument_callback, this);
menu->add("Track/Live MIDI to built-in sine", 0, instrument_callback, this);
menu->add("Edit/Insert internal delay on wire", 0, plugin_callback, this);
menu->add("Edit/Insert internal reverb on wire", 0, plugin_callback, this);
menu->add("File/Add internal delay", 0, plugin_callback, this);
menu->add("File/Add internal reverb", 0, plugin_callback, this);
menu->add("File/Load plugin", 0, plugin_callback, this);
menu->add("Edit/Replace selected plugin", 0, plugin_callback, this);
menu->add("Edit/Insert plugin on selected wire", 0, plugin_callback, this);
@ -159,10 +172,43 @@ MainWindow::MainWindow(bool prompt_unsaved,const char *configuration)
indicator_->labelsize(12);
transport_position_ = new Fl_Box(680,40,190,30,"001 : 1 : 000");
transport_position_->tooltip("Musical position: bar : beat : tick (4/4, 960 ticks per beat)");
tempo_display_ = new Fl_Box(880,40,110,30,"120.0 BPM");
auto *hint = new Fl_Box(12,82,1256,28,"xtc / ARRANGEMENT Create tracks, arrange clips and shape your sound.");
hint->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE); hint->resize(12,82,970,28);
loop_button_=new Fl_Check_Button(1000,82,100,28,"Loop");
tempo_display_ = new Fl_Value_Input(880, 40, 78, 30, "BPM");
tempo_display_->align(FL_ALIGN_RIGHT);
tempo_display_->bounds(20, 300);
tempo_display_->step(.1);
tempo_display_->when(FL_WHEN_RELEASE | FL_WHEN_ENTER_KEY);
tempo_display_->tooltip("Project tempo in BPM. Enter or release to apply; undoable. Stops playback.");
tempo_display_->callback(
[](Fl_Widget *, void *c) {
auto *w = static_cast<MainWindow *>(c);
double bpm = w->tempo_display_->value();
xtc_result r = (!std::isfinite(bpm) || bpm < 20 || bpm > 300)
? XTC_ERR_INVALID_ARGUMENT
: w->set_tempo(static_cast<unsigned int>(std::lround(bpm * 1000)));
if (r != XTC_OK)
w->report_error("Tempo unchanged", r);
w->tempo_display_->value(xtc_project_tempo(w->project_.get()) / 1000.0);
w->refresh_status();
},
this);
auto *hint = new Fl_Box(12, 82, 160, 28, "xtc / SESSION");
hint->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
session_info_ = new Fl_Box(180, 82, 280, 28);
session_info_->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
auto *commands = new Fl_Button(480, 82, 120, 28, "Commands");
commands->tooltip("Search actions (Ctrl+P)");
commands->callback([](Fl_Widget *, void *c) { static_cast<MainWindow *>(c)->show_commands(); }, this);
follow_ = new Fl_Check_Button(620, 82, 154, 28, "Follow playhead");
follow_->tooltip("Keep playback visible in the arrangement; pauses while dragging.");
follow_->callback(
[](Fl_Widget *widget, void *c) {
static_cast<MainWindow *>(c)->settings_.follow_playhead = static_cast<Fl_Check_Button *>(widget)->value();
},
this);
auto *fit = new Fl_Button(790, 82, 100, 28, "Fit song");
fit->tooltip("Choose the largest supported zoom that fits the song (Ctrl+0)");
fit->callback([](Fl_Widget *, void *c) { static_cast<MainWindow *>(c)->fit_song(); }, this);
loop_button_ = new Fl_Check_Button(1000, 82, 100, 28, "Loop");
loop_button_->callback([](Fl_Widget *widget,void *c){auto *w=static_cast<MainWindow *>(c);
xtc_result r=w->set_loop(static_cast<uint64_t>(w->settings_.loop_start),static_cast<uint64_t>(w->settings_.loop_end),static_cast<Fl_Check_Button *>(widget)->value()!=0);
if(r!=XTC_OK) w->report_error("Loop unchanged",r);
@ -194,6 +240,7 @@ MainWindow::MainWindow(bool prompt_unsaved,const char *configuration)
timeline_hint->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
timeline_hint->labelsize(12);
auto *timeline_scroll = new Fl_Scroll(228, 206, 1032, 452);
timeline_scroll_=timeline_scroll;
sequencer_ = new SequencerWidget(228, 206, project_.get(), seek, this);
timeline_scroll->end();
sequencer_->before_edit = before_arrangement_edit;
@ -361,11 +408,27 @@ MainWindow::MainWindow(bool prompt_unsaved,const char *configuration)
load->callback(instrument_callback,this);
auto *editor = new Fl_Button(24,344,168,34,"Edit MIDI notes");
editor->callback(piano_callback,this);
auto *selection_title = new Fl_Box(24,404,168,24,"SELECTED TRACK");
auto *selection_title = new Fl_Box(24,404,168,24,"TRACK INSPECTOR");
selection_title->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
selection_info_ = new Fl_Box(24,438,168,170,"Select a track to inspect it.");
selection_info_ = new Fl_Box(24,438,168,82,"Select a track to inspect it.");
selection_info_->align(FL_ALIGN_TOP_LEFT | FL_ALIGN_INSIDE | FL_ALIGN_WRAP);
auto *tip = new Fl_Box(24,620,168,64,"Ctrl+1 Arrange\nCtrl+2 Mixer\nCtrl+3 Routing");
inspector_gain_ = new Fl_Value_Input(78, 528, 114, 26, "Gain");
inspector_gain_->bounds(0, 4);
inspector_gain_->step(.01);
inspector_pan_ = new Fl_Value_Input(78, 562, 114, 26, "Pan");
inspector_pan_->bounds(-1, 1);
inspector_pan_->step(.01);
inspector_mute_ = new Fl_Check_Button(24, 596, 78, 24, "Mute");
inspector_solo_ = new Fl_Check_Button(108, 596, 84, 24, "Solo");
for (auto *control : {static_cast<Fl_Widget *>(inspector_gain_), static_cast<Fl_Widget *>(inspector_pan_),
static_cast<Fl_Widget *>(inspector_mute_), static_cast<Fl_Widget *>(inspector_solo_)}) {
control->when(FL_WHEN_RELEASE);
control->callback(inspector_callback, this);
}
inspector_gain_->tooltip(
"Selected track linear gain: 0 silence, 1 unity, 4 maximum. Automation overrides static gain.");
inspector_pan_->tooltip("Selected track pan: -1 left, 0 center, +1 right.");
auto *tip = new Fl_Box(24, 632, 168, 52, "Ctrl+P Commands\nCtrl+1/2/3 Views\nCtrl+0 Fit song");
tip->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
sidebar->end();
status_ = new Fl_Box(12,714,1256,26,"JACK: not connected");
@ -870,6 +933,7 @@ void MainWindow::timer_callback(void *context)
window->stop_engine();
}
window->refresh_status();
window->follow_playhead();
if (!window->closing_)
Fl::repeat_timeout(static_cast<double>(window->settings_.refresh_ms)/1000,timer_callback,context);
}
@ -1564,41 +1628,97 @@ xtc_result MainWindow::create_track(bool midi)
}
void MainWindow::refresh_workspace()
{
if(loop_button_) {loop_button_->value(settings_.loop_enabled!=0);if(recorder_)loop_button_->deactivate();else loop_button_->activate();}
if (snap_) snap_->value(xtc_ui::snap_index(sequencer_->grid()));
if (loop_button_) {
loop_button_->value(settings_.loop_enabled != 0);
if (recorder_)
loop_button_->deactivate();
else
loop_button_->activate();
}
if (snap_)
snap_->value(xtc_ui::snap_index(sequencer_->grid()));
if (piano_) {
piano_snap_->value(xtc_ui::snap_index(piano_->grid()));
size_t count = 0; bool selected = false; xtc_project_note_count(project_.get(),&count);
size_t count = 0;
bool selected = false;
xtc_project_note_count(project_.get(), &count);
for (size_t i = 0; i < count; ++i) {
xtc_note_info note{}; xtc_project_get_note(project_.get(),i,&note);
xtc_note_info note{};
xtc_project_get_note(project_.get(), i, &note);
if (note.id == piano_->selected_note() && piano_->note_visible(note)) {
selected = true; if (Fl::pushed() != note_velocity_) note_velocity_->value(note.velocity); break;
selected = true;
if (Fl::pushed() != note_velocity_)
note_velocity_->value(note.velocity);
break;
}
}
if (selected) note_velocity_->activate(); else note_velocity_->deactivate();
if (selected)
note_velocity_->activate();
else
note_velocity_->deactivate();
velocity_lane_->redraw();
}
char position[64], tempo[40], info[512];
char position[64], info[512];
uint64_t tick = sequencer_->position();
std::snprintf(position,sizeof(position),"%03llu : %u : %03u",
static_cast<unsigned long long>(tick/3840+1),static_cast<unsigned int>((tick/960)%4+1),
static_cast<unsigned int>(tick%960));
set_label(transport_position_,position);
std::snprintf(tempo,sizeof(tempo),"%.1f BPM",xtc_project_tempo(project_.get())/1000.0);
set_label(tempo_display_,tempo);
size_t tracks = 0, clips = 0; xtc_project_get_counts(project_.get(),&tracks,&clips);
for (size_t i = 0; i < tracks; ++i) {
xtc_track_info track{}; xtc_project_get_track(project_.get(),i,&track);
if (track.id != sequencer_->selected_track()) continue;
xtc_plugin_spec spec{};
bool plugin = xtc_project_get_instrument(project_.get(),track.id,&spec) == XTC_OK;
std::snprintf(info,sizeof(info),"%s\n\n%s\nGain %.2f | Pan %.2f\n%s%s\n\n%s",
track.name,track.is_bus ? "BUS" : "TRACK",static_cast<double>(track.gain),static_cast<double>(track.pan),
track.mute ? "Muted " : "",track.solo ? "Solo" : "",plugin ? spec.label : "Built-in MIDI sine");
set_label(selection_info_,info); return;
std::snprintf(position, sizeof(position), "%03llu : %u : %03u", static_cast<unsigned long long>(tick / 3840 + 1),
static_cast<unsigned int>((tick / 960) % 4 + 1), static_cast<unsigned int>(tick % 960));
set_label(transport_position_, position);
if (!editing_number(tempo_display_))
tempo_display_->value(xtc_project_tempo(project_.get()) / 1000.0);
if (recorder_)
tempo_display_->deactivate();
else
tempo_display_->activate();
size_t tracks = 0, clips = 0;
xtc_project_get_counts(project_.get(), &tracks, &clips);
uint64_t end = 0;
for (size_t i = 0; i < clips; ++i) {
xtc_clip_info clip{};
xtc_project_get_clip(project_.get(), i, &clip);
end = std::max(end, clip.start_tick + clip.length_tick);
}
std::snprintf(info,sizeof(info),"No track selected\n\n%zu tracks / buses\n%zu clips\n\nCreate a MIDI track to start drawing notes, or import a WAV file.",tracks,clips);
set_label(selection_info_,info);
std::snprintf(info, sizeof(info), "%zu tracks / %zu clips / %llu bars", tracks, clips,
static_cast<unsigned long long>((end + 3839) / 3840));
set_label(session_info_, info);
uint64_t target = tabs_->value() == tabs_->child(1) ? mixer_->selected_track() : sequencer_->selected_track();
bool selection_changed = target != inspected_track_;
inspected_track_ = UINT64_MAX;
for (size_t i = 0; i < tracks; ++i) {
xtc_track_info track{};
xtc_project_get_track(project_.get(), i, &track);
if (track.id != target)
continue;
inspected_track_ = track.id;
for (auto *control : {static_cast<Fl_Widget *>(inspector_gain_), static_cast<Fl_Widget *>(inspector_pan_),
static_cast<Fl_Widget *>(inspector_mute_), static_cast<Fl_Widget *>(inspector_solo_)}) {
if (recorder_)
control->deactivate();
else
control->activate();
}
if (selection_changed || !editing_number(inspector_gain_))
inspector_gain_->value(track.gain);
if (selection_changed || !editing_number(inspector_pan_))
inspector_pan_->value(track.pan);
if (Fl::pushed() != inspector_mute_)
inspector_mute_->value(track.mute);
if (Fl::pushed() != inspector_solo_)
inspector_solo_->value(track.solo);
xtc_plugin_spec spec{};
bool plugin = xtc_project_get_instrument(project_.get(), track.id, &spec) == XTC_OK;
std::snprintf(info, sizeof(info), "%s\n%s %s%s\n%s", track.name, track.is_bus ? "BUS" : "TRACK",
track.mute ? "Muted " : "", track.solo ? "Solo" : "",
track.is_bus ? "Bus output"
: plugin ? spec.label
: "Built-in MIDI sine");
set_label(selection_info_, info);
return;
}
for (auto *control : {static_cast<Fl_Widget *>(inspector_gain_), static_cast<Fl_Widget *>(inspector_pan_),
static_cast<Fl_Widget *>(inspector_mute_), static_cast<Fl_Widget *>(inspector_solo_)})
control->deactivate();
std::snprintf(info, sizeof(info), "No track selected\nCreate a MIDI track or import a WAV to begin.");
set_label(selection_info_, info);
}
xtc_result MainWindow::assign_instrument(uint64_t track, const char *path, unsigned int index)
@ -1801,7 +1921,12 @@ void MainWindow::plugin_callback(Fl_Widget *widget, void *context)
auto *menu = static_cast<Fl_Menu_Bar *>(widget);
const char *label = menu->mvalue()->label();
xtc_result r;
if (std::strcmp(label,"Reset selected plugin") == 0) {
if (std::strcmp(label,"Insert internal delay on wire")==0 || std::strcmp(label,"Insert internal reverb on wire")==0) {
xtc_connection_info wire{};
r=w->graph_widget_->selected_connection(wire) ? w->insert_plugin(wire,XTC_BUILTIN_PATH,std::strcmp(label,"Insert internal delay on wire")==0 ? 2U : 3U) : XTC_ERR_INVALID_STATE;
} else if (std::strcmp(label,"Add internal delay") == 0 || std::strcmp(label,"Add internal reverb") == 0) {
size_t id=0; r=w->add_plugin(XTC_BUILTIN_PATH, std::strcmp(label,"Add internal delay")==0 ? 2U : 3U, &id);
} else if (std::strcmp(label,"Reset selected plugin") == 0) {
r = w->reset_plugin(w->graph_widget_->selected_node());
} else if (std::strcmp(label,"Load plugin") == 0 ||
std::strcmp(label,"Replace selected plugin") == 0 ||
@ -1914,6 +2039,7 @@ void MainWindow::collect_preferences()
}
void MainWindow::apply_ui_preferences()
{
follow_->value(static_cast<int>(settings_.follow_playhead));
resize(x(),y(),static_cast<int>(settings_.width),static_cast<int>(settings_.height));
sequencer_->grid(static_cast<uint64_t>(settings_.sequencer_snap));sequencer_->set_zoom(static_cast<int>(settings_.sequencer_zoom));
sequencer_->new_clip_ticks=static_cast<uint64_t>(settings_.clip_ticks);
@ -1940,3 +2066,119 @@ void MainWindow::show_preferences()
if(recorder_) {report_error("Stop recording before preferences",XTC_ERR_INVALID_STATE);return;}
collect_preferences();PreferencesDialog dialog(settings_,configuration_,[this](const xtc_settings &s){return apply_preferences(s);});dialog.run();
}
xtc_result MainWindow::set_tempo(unsigned int milli_bpm)
{
if (recorder_)
return XTC_ERR_INVALID_STATE;
if (milli_bpm < 20000 || milli_bpm > 300000)
return XTC_ERR_INVALID_ARGUMENT;
if (milli_bpm == xtc_project_tempo(project_.get()))
return XTC_OK;
uint64_t track = sequencer_->selected_track(), clip = sequencer_->selected_clip(), mix = mixer_->selected_track();
uint64_t piano_clip = piano_ ? piano_->clip() : UINT64_MAX, note = piano_ ? piano_->selected_note() : UINT64_MAX;
bool piano_visible = piano_window_ && piano_window_->shown();
xtc_project *candidate = nullptr;
xtc_result r = xtc_project_clone(project_.get(), &candidate);
if (r == XTC_OK)
r = xtc_project_set_tempo(candidate, milli_bpm);
if (r == XTC_OK)
r = xtc_history_reserve(history_.get());
if (r == XTC_OK)
r = install_project(candidate, false);
if (r != XTC_OK)
xtc_project_destroy(candidate);
else {
sequencer_->select(track, clip);
mixer_->select_track(mix);
xtc_clip_info info{};
if (piano_ && xtc_project_find_clip(project_.get(), piano_clip, &info) == XTC_OK) {
piano_->set_project(project_.get(), piano_clip);
piano_->select_note(note);
if (piano_visible)
piano_window_->show();
}
mark_dirty();
}
return r;
}
void MainWindow::inspector_callback(Fl_Widget *widget, void *context)
{
auto *w = static_cast<MainWindow *>(context);
const uint64_t id = w->inspected_track_;
float gain = static_cast<float>(w->inspector_gain_->value()), pan = static_cast<float>(w->inspector_pan_->value());
int mute = w->inspector_mute_->value(), solo = w->inspector_solo_->value();
// Editing a single field must not commit another field's unfinished input.
size_t count = 0, clips = 0;
xtc_project_get_counts(w->project_.get(), &count, &clips);
for (size_t i = 0; i < count; ++i) {
xtc_track_info track{};
xtc_project_get_track(w->project_.get(), i, &track);
if (track.id != id)
continue;
if (widget != w->inspector_gain_)
gain = track.gain;
if (widget != w->inspector_pan_)
pan = track.pan;
if (widget != w->inspector_mute_)
mute = track.mute;
if (widget != w->inspector_solo_)
solo = track.solo;
if (gain != track.gain || pan != track.pan || mute != track.mute || solo != track.solo)
if (w->mixer_->select_track(id))
w->mixer_->mix(gain, pan, mute, solo);
break;
}
w->inspected_track_ = UINT64_MAX;
w->refresh_status();
}
void MainWindow::show_commands()
{
std::vector<std::string> commands;
for (int i = 0; i < menu_->size(); ++i) {
const auto &item = menu_->menu()[i];
if (!item.label() || item.submenu() || !item.active())
continue;
char path[512];
if (menu_->item_pathname(path, sizeof(path), &item) == 0)
commands.emplace_back(path);
}
std::string selected;
{
CommandPalette palette(std::move(commands));
selected = palette.run();
}
if (!selected.empty()) {
auto *item = menu_->find_item(selected.c_str());
if (item && item->active())
menu_->picked(item);
}
}
void MainWindow::fit_song()
{
size_t tracks = 0, clips = 0;
uint64_t end = 3840;
xtc_project_get_counts(project_.get(), &tracks, &clips);
for (size_t i = 0; i < clips; ++i) {
xtc_clip_info clip{};
xtc_project_get_clip(project_.get(), i, &clip);
end = std::max(end, clip.start_tick + clip.length_tick + 960);
}
int scale = 24;
for (int candidate : {24, 48, 96, 192, 384})
if (end * static_cast<unsigned int>(candidate) / 960 <=
static_cast<uint64_t>(std::max(1, timeline_scroll_->w() - 204)))
scale = candidate;
sequencer_->set_zoom(scale);
timeline_scroll_->scroll_to(0, 0);
timeline_scroll_->redraw();
}
void MainWindow::follow_playhead()
{
if (!running_ || !follow_->value() || tabs_->value() != tabs_->child(0) || Fl::pushed())
return;
int pixel = static_cast<int>(sequencer_->position() * static_cast<unsigned int>(sequencer_->zoom_level()) / 960);
int screen = sequencer_->x() + 180 + pixel;
if (screen > timeline_scroll_->x() + timeline_scroll_->w() - 48 || screen < timeline_scroll_->x() + 180)
timeline_scroll_->scroll_to(std::max(0, pixel - 160), timeline_scroll_->yposition());
}

View file

@ -21,6 +21,8 @@ class Fl_Tabs;
class Fl_Menu_Bar;
class Fl_Choice;
class Fl_Value_Slider;
class Fl_Value_Input;
class Fl_Scroll;
class Fl_Check_Button;
class MainWindow : public Fl_Double_Window {
@ -29,6 +31,9 @@ class MainWindow : public Fl_Double_Window {
* Preparation stops/resets transport; recording and failed candidates retain
* the current document. No engine/model changes happen in audio callbacks. */
xtc_result create_track(bool midi);
xtc_result set_tempo(unsigned int milli_bpm);
void show_commands();
void fit_song();
const xtc_settings &settings() const { return settings_; }
xtc_result apply_preferences(const xtc_settings &settings);
void show_preferences();
@ -198,7 +203,14 @@ class MainWindow : public Fl_Double_Window {
Fl_Value_Slider *note_velocity_ = nullptr;
Fl_Widget *velocity_lane_ = nullptr;
Fl_Box *transport_position_ = nullptr;
Fl_Box *tempo_display_ = nullptr;
Fl_Value_Input *tempo_display_ = nullptr;
Fl_Value_Input *inspector_gain_=nullptr,*inspector_pan_=nullptr;
Fl_Check_Button *inspector_mute_=nullptr,*inspector_solo_=nullptr,*follow_=nullptr;
Fl_Scroll *timeline_scroll_=nullptr;
Fl_Box *session_info_=nullptr;
uint64_t inspected_track_=UINT64_MAX;
static void inspector_callback(Fl_Widget *,void *);
void follow_playhead();
Fl_Box *selection_info_ = nullptr;
MixerWidget *mixer_ = nullptr;
Fl_Menu_Bar *menu_ = nullptr;

View file

@ -616,6 +616,7 @@ void SequencerWidget::refresh_instruments() try
size_t tracks = 0, clips = 0;
xtc_project_get_counts(project_,&tracks,&clips);
catalog_.clear();
for (unsigned int i=0;i<2;++i) { xtc_plugin_spec s{}; if (xtc_plugin_probe(XTC_BUILTIN_PATH,i,48000,&s)==XTC_OK) catalog_.push_back(s); }
for (size_t i = 0; i < tracks; ++i) {
xtc_track_info t{}; xtc_plugin_spec spec{};
xtc_project_get_track(project_,i,&t);

View file

@ -54,7 +54,7 @@ static int inspect(const xtc_project *project, uint64_t version)
xtc_node_info node; xtc_plugin_spec spec;
xtc_graph_get_node(graph,i,&node);
if (xtc_graph_get_plugin(graph,node.id,&spec) == XTC_OK) {
int available = readable_file(spec.path);
int available = spec.format == XTC_PLUGIN_BUILTIN || readable_file(spec.path);
printf("%s node %zu ID %u descriptor %u ",xtc_plugin_format_name(spec.format),node.id,spec.unique_id,spec.index);
if (spec.identifier[0]) { quoted(spec.identifier); putchar(' '); }
quoted(spec.label); printf(": %s ",available ? "available" : "missing/unreadable");
@ -66,7 +66,7 @@ static int inspect(const xtc_project *project, uint64_t version)
xtc_track_info track; xtc_plugin_spec spec;
xtc_project_get_track(project,i,&track);
if (xtc_project_get_instrument(project,track.id,&spec) == XTC_OK) {
int available = readable_file(spec.path);
int available = spec.format == XTC_PLUGIN_BUILTIN || readable_file(spec.path);
printf("%s instrument track %" PRIu64 " descriptor %u ",xtc_plugin_format_name(spec.format),track.id,spec.index);
quoted(spec.identifier); putchar(' '); quoted(spec.label);
printf(": %s ",available ? "available" : "missing/unreadable"); quoted(spec.path); putchar('\n');

View file

@ -261,7 +261,7 @@ static xtc_result read_project(reader *input, xtc_project *project, const char *
if (!decode_bytes(input->tokens[1],p->path,sizeof(p->path))) return XTC_ERR_FORMAT;
if (format_version >= 11U) {
READ("FORMAT",3U); NUM(1U,value);
if (value > XTC_PLUGIN_VST3) return XTC_ERR_UNSUPPORTED;
if (value > (format_version >= 13U ? XTC_PLUGIN_BUILTIN : XTC_PLUGIN_VST3)) return XTC_ERR_UNSUPPORTED;
p->format = (xtc_plugin_format)value;
if (strcmp(input->tokens[2],"-") && !decode_bytes(input->tokens[2],p->identifier,sizeof(p->identifier))) return XTC_ERR_FORMAT;
}
@ -454,7 +454,7 @@ static xtc_result read_project(reader *input, xtc_project *project, const char *
for (slot = 0; slot < project->track_count && project->tracks[slot].id != track; ++slot) {}
if (slot == project->track_count || project->tracks[slot].is_bus || project->instruments[slot].instrument) return XTC_ERR_FORMAT;
s = project->instruments+slot; s->instrument = 1; s->tempo = project->tempo;
NUM(2U,value); if (value < XTC_PLUGIN_CLAP || value > XTC_PLUGIN_VST3) return XTC_ERR_UNSUPPORTED;
NUM(2U,value); if (value < XTC_PLUGIN_CLAP || value > (format_version >= 13U ? XTC_PLUGIN_BUILTIN : XTC_PLUGIN_VST3)) return XTC_ERR_UNSUPPORTED;
s->format = (xtc_plugin_format)value;
NUM(3U,value); if (value >= 1024) return XTC_ERR_FORMAT; s->index = (unsigned int)value;
NUM(4U,value); if (value > UINT32_MAX) return XTC_ERR_FORMAT; s->unique_id = (unsigned int)value;

149
src/plugin/builtin.c Normal file
View file

@ -0,0 +1,149 @@
/* Original, dependency-free mono devices. All storage is prepared off-thread. */
#include "builtin.h"
#include "xtc/xtc_midi.h"
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#define TAU 6.2831853071795864769
static const char *names[] = {"Soft Keys", "Sub Bass", "Delay", "Reverb"};
static const char *controls[2][3] = {{"Time", "Feedback", "Mix"}, {"Decay", "Damping", "Mix"}};
static const float defaults[2][3] = {{350, .35f, .25f}, {.7f, .45f, .25f}};
static const float lows[2][3] = {{1,0,0},{0,0,0}};
static const float highs[2][3] = {{2000,.95f,1},{.95f,.95f,1}};
typedef struct { double phase, step; float level, velocity; unsigned int note, channel; int active, released, held; } voice;
struct xtc_builtin {
xtc_plugin_spec spec;
double rate;
float attack, release;
size_t max_frames, length, cursor;
float *line, damp[4];
size_t comb[4];
voice voices[32];
double frequencies[128];
int sustain[16];
};
xtc_result xtc_builtin_probe(unsigned int index, xtc_plugin_spec *out)
{
unsigned int i; xtc_plugin_spec s = {0};
if (!out) return XTC_ERR_INVALID_ARGUMENT;
if (index >= 4) return XTC_ERR_NOT_FOUND;
strcpy(s.path,XTC_BUILTIN_PATH); strcpy(s.label,names[index]);
s.format = XTC_PLUGIN_BUILTIN; s.index = index; s.unique_id = 0x58544300U+index;
s.instrument = index < 2; s.inputs = index < 2 ? 0U : 1U; s.tempo = 120000;
s.control_count = index < 2 ? 0U : 3U;
for (i=0;i<s.control_count;++i) { s.ports[i]=i; s.values[i]=defaults[index-2][i]; }
*out=s; return XTC_OK;
}
xtc_result xtc_builtin_validate(const xtc_plugin_spec *s)
{
xtc_plugin_spec a; unsigned int i;
if (!s || xtc_builtin_probe(s->index,&a)!=XTC_OK || strcmp(s->path,a.path) || strcmp(s->label,a.label) ||
s->identifier[0] || s->unique_id!=a.unique_id || s->instrument!=a.instrument || s->inputs!=a.inputs ||
s->control_count!=a.control_count) return XTC_ERR_INVALID_ARGUMENT;
for(i=0;i<s->control_count;++i) if(s->ports[i]!=i || !isfinite(s->values[i]) ||
s->values[i]<lows[s->index-2][i] || s->values[i]>highs[s->index-2][i]) return XTC_ERR_INVALID_ARGUMENT;
for(i=0;i<s->point_count;++i) if(s->index<2 || s->points[i].port>=3 || !isfinite(s->points[i].value) ||
s->points[i].value<lows[s->index-2][s->points[i].port] || s->points[i].value>highs[s->index-2][s->points[i].port]) return XTC_ERR_INVALID_ARGUMENT;
return XTC_OK;
}
xtc_result xtc_builtin_describe(const xtc_plugin_spec *s, xtc_plugin_details *out)
{
unsigned int i;
if (!out || xtc_plugin_spec_validate(s)!=XTC_OK) return XTC_ERR_INVALID_ARGUMENT;
memset(out,0,sizeof(*out)); snprintf(out->name,sizeof(out->name),"%s",s->label);
strcpy(out->maker,"xtc"); strcpy(out->copyright,"See xtc LICENSE"); out->hard_realtime=1;
for(i=0;i<s->control_count;++i) {
xtc_parameter_info *p=out->parameters+i; p->id=i;
strcpy(p->name,controls[s->index-2][i]); if(s->index==2 && i==0) strcpy(p->unit,"ms");
p->minimum=lows[s->index-2][i]; p->maximum=highs[s->index-2][i]; p->default_value=defaults[s->index-2][i];
out->flags[i]=XTC_PLUGIN_BOUNDED_BELOW|XTC_PLUGIN_BOUNDED_ABOVE;
}
return XTC_OK;
}
xtc_result xtc_builtin_create(const xtc_plugin_spec *s, double rate, size_t frames, xtc_builtin **out)
{
xtc_builtin *p; unsigned int i;
if (!out || xtc_plugin_spec_validate(s)!=XTC_OK || !isfinite(rate) || rate<1 || rate>768000 || !frames || frames>65536) return XTC_ERR_INVALID_ARGUMENT;
*out=NULL; p=calloc(1,sizeof(*p)); if(!p) return XTC_ERR_OUT_OF_MEMORY;
p->spec=*s; p->rate=rate; p->attack=(float)(1-exp(-1/(.008*rate))); p->release=(float)exp(-1/(.08*rate)); p->max_frames=frames; p->length=(size_t)ceil(rate*2)+2;
if(!s->instrument) { p->line=calloc(p->length*4,sizeof(float)); if(!p->line) {free(p);return XTC_ERR_OUT_OF_MEMORY;} }
for(i=0;i<128;++i) p->frequencies[i]=440*pow(2,((double)i-69)/12)/rate;
for(i=0;i<4;++i) { static const double times[]={.0297,.0371,.0411,.0437}; p->comb[i]=(size_t)(rate*times[i])+1; }
*out=p; return XTC_OK;
}
void xtc_builtin_destroy(xtc_builtin *p) { if(p) {free(p->line);free(p);} }
static float parameter(const xtc_builtin *p, unsigned int port, uint64_t position)
{
const xtc_plugin_point *a=NULL,*b=NULL; unsigned int i;
double tick=(double)position*p->spec.tempo*XTC_TICKS_PER_QUARTER/(p->rate*60000);
for(i=0;i<p->spec.point_count;++i) { const xtc_plugin_point *q=p->spec.points+i;
if(q->port!=port) continue;
if((double)q->tick<=tick) { if(!a || q->tick>a->tick) a=q; }
else if(!b || q->tick<b->tick) b=q;
}
if(!a) return b ? b->value : p->spec.values[port];
if(!b || a->step) return a->value;
return (float)(a->value+(b->value-a->value)*(tick-(double)a->tick)/(double)(b->tick-a->tick));
}
xtc_result xtc_builtin_process(xtc_builtin *p, const float *in, float *out, size_t frames, uint64_t position)
{
size_t i; unsigned int j;
if(!p || !out || frames>p->max_frames || p->spec.instrument || position>UINT64_MAX-frames) return XTC_ERR_INVALID_ARGUMENT;
for(i=0;i<frames;++i) {
float x=in && isfinite(in[i]) ? in[i] : 0, wet=0;
float a=parameter(p,0,position+i), b=parameter(p,1,position+i), mix=parameter(p,2,position+i);
if(p->spec.index==2) {
size_t delay=(size_t)(a*p->rate/1000); if(!delay) delay=1;
wet=p->line[(p->cursor+p->length-delay)%p->length];
p->line[p->cursor]=x+wet*b;
} else {
for(j=0;j<4;++j) {
float *line=p->line+j*p->length;
float y=line[(p->cursor+p->length-p->comb[j])%p->length];
p->damp[j]=(1-b)*y+b*p->damp[j];
line[p->cursor]=x+a*p->damp[j]; wet+=y*.25f;
}
}
out[i]=(1-mix)*x+mix*wet; p->cursor=(p->cursor+1)%p->length;
}
return XTC_OK;
}
static void midi_event(xtc_builtin *p, const xtc_midi_event *e)
{
unsigned int j,slot=0;
if(e->type==XTC_MIDI_ALL_OFF) { memset(p->voices,0,sizeof(p->voices));memset(p->sustain,0,sizeof(p->sustain));return; }
if(e->type==XTC_MIDI_CONTROL) {
if(e->pitch==64) {p->sustain[e->channel]=e->velocity>=64; if(e->velocity<64) for(j=0;j<32;++j) if(p->voices[j].channel==e->channel && p->voices[j].held) p->voices[j].released=1;}
if(e->pitch==120 || e->pitch==123) for(j=0;j<32;++j) if(p->voices[j].channel==e->channel) p->voices[j].active=0;
return;
}
if(e->type==XTC_MIDI_NOTE_OFF || !e->velocity) {
for(j=0;j<32;++j) if(p->voices[j].channel==e->channel && p->voices[j].note==e->pitch) {
p->voices[j].held=1; p->voices[j].released=!p->sustain[e->channel];
}
return;
}
for(j=0;j<32;++j) { if(!p->voices[j].active) {slot=j;break;} if(p->voices[j].level<p->voices[slot].level) slot=j; }
{voice *v=p->voices+slot; memset(v,0,sizeof(*v));v->active=1;v->note=e->pitch;v->channel=e->channel;v->velocity=(float)e->velocity/127;v->step=p->frequencies[e->pitch];}
}
xtc_result xtc_builtin_midi(xtc_builtin *p, const xtc_midi_event *events, size_t count, float *out, size_t frames)
{
size_t i,k=0; unsigned int j;
if(!p || !p->spec.instrument || !out || frames>p->max_frames || count>256 || (count && !events)) return XTC_ERR_INVALID_ARGUMENT;
for(i=0;i<count;++i) if(events[i].offset>=frames || (i && events[i].offset<events[i-1].offset) ||
events[i].channel>15 || events[i].pitch>127 || events[i].velocity>127 || events[i].type<XTC_MIDI_NOTE_ON || events[i].type>XTC_MIDI_CONTROL) return XTC_ERR_INVALID_ARGUMENT;
for(i=0;i<frames;++i) {
float sum=0; while(k<count && events[k].offset==i) midi_event(p,events+k++);
for(j=0;j<32;++j) { voice *v=p->voices+j; double wave;
if(!v->active) continue;
if(v->released) v->level *= p->release;
else v->level += (1-v->level)*p->attack;
if(v->released && v->level<.00001f) {v->active=0;continue;}
wave=v->step<.49 ? sin(TAU*v->phase) : 0;
if(p->spec.index==0 && v->step<.16) wave+=.3*sin(3*TAU*v->phase);
sum+=(float)wave*v->level*v->velocity*.12f;
v->phase+=v->step; v->phase-=floor(v->phase);
} out[i]=sum;
} return XTC_OK;
}

12
src/plugin/builtin.h Normal file
View file

@ -0,0 +1,12 @@
#ifndef XTC_BUILTIN_H
#define XTC_BUILTIN_H
#include "xtc/xtc_plugin.h"
typedef struct xtc_builtin xtc_builtin;
xtc_result xtc_builtin_probe(unsigned int index, xtc_plugin_spec *out);
xtc_result xtc_builtin_validate(const xtc_plugin_spec *s);
xtc_result xtc_builtin_describe(const xtc_plugin_spec *s, xtc_plugin_details *out);
xtc_result xtc_builtin_create(const xtc_plugin_spec *s, double rate, size_t frames, xtc_builtin **out);
void xtc_builtin_destroy(xtc_builtin *p);
xtc_result xtc_builtin_process(xtc_builtin *p, const float *in, float *out, size_t frames, uint64_t position);
xtc_result xtc_builtin_midi(xtc_builtin *p, const xtc_midi_event *events, size_t count, float *out, size_t frames);
#endif

View file

@ -1,4 +1,5 @@
#include "modern.h"
#include "builtin.h"
#include <dlfcn.h>
#include <math.h>
#include <stdlib.h>
@ -10,14 +11,15 @@ xtc_result xtc_ladspa_describe(const xtc_plugin_spec *, double, xtc_plugin_detai
xtc_result xtc_ladspa_create(const xtc_plugin_spec *, double, size_t, xtc_ladspa_plugin **);
void xtc_ladspa_destroy(xtc_ladspa_plugin *);
xtc_result xtc_ladspa_process_at(xtc_ladspa_plugin *, const float *, float *, size_t, uint64_t);
struct xtc_plugin { xtc_ladspa_plugin *ladspa; xtc_modern *modern; uint64_t next; };
struct xtc_plugin { xtc_ladspa_plugin *ladspa; xtc_modern *modern; xtc_builtin *builtin; uint64_t next; };
const char *xtc_plugin_format_name(xtc_plugin_format f)
{ static const char *names[] = {"LADSPA", "CLAP", "VST2", "VST3"}; return f >= 0 && f <= XTC_PLUGIN_VST3 ? names[f] : "Unknown"; }
{ static const char *names[] = {"LADSPA", "CLAP", "VST2", "VST3", "Internal"}; return f >= 0 && f <= XTC_PLUGIN_BUILTIN ? names[f] : "Unknown"; }
xtc_result xtc_plugin_probe_format(xtc_plugin_format f, const char *path, unsigned int index, double rate, xtc_plugin_spec *out)
{
xtc_modern *p = NULL; xtc_result r;
if (!out || !path || path[0] != '/' || strlen(path) >= 512 || index >= 1024 || !isfinite(rate) || rate < 1 || rate > 768000)
return XTC_ERR_INVALID_ARGUMENT;
if (f == XTC_PLUGIN_BUILTIN) return !strcmp(path,XTC_BUILTIN_PATH) ? xtc_builtin_probe(index,out) : XTC_ERR_INVALID_ARGUMENT;
if (f == XTC_PLUGIN_LADSPA) return xtc_ladspa_probe(path,index,rate,out);
if (f < XTC_PLUGIN_CLAP || f > XTC_PLUGIN_VST3) return XTC_ERR_INVALID_ARGUMENT;
r = xtc_modern_open(f,path,index,rate,256,&p,out);
@ -27,6 +29,7 @@ xtc_result xtc_plugin_probe(const char *path, unsigned int index, double rate, x
{
void *module; xtc_plugin_format f = XTC_PLUGIN_LADSPA;
if (!path || path[0] != '/' || strlen(path) >= 512) return XTC_ERR_INVALID_ARGUMENT;
if (!strcmp(path,XTC_BUILTIN_PATH)) return xtc_plugin_probe_format(XTC_PLUGIN_BUILTIN,path,index,rate,out);
module = dlopen(path,RTLD_NOW | RTLD_LOCAL);
if (!module) return XTC_ERR_NOT_FOUND;
if (dlsym(module,"clap_entry")) f = XTC_PLUGIN_CLAP;
@ -39,6 +42,8 @@ xtc_result xtc_plugin_describe(const xtc_plugin_spec *s, double rate, xtc_plugin
{
xtc_plugin_spec actual; xtc_result r;
if (!out || xtc_plugin_spec_validate(s) != XTC_OK) return XTC_ERR_INVALID_ARGUMENT;
if (!isfinite(rate) || rate < 1 || rate > 768000) return XTC_ERR_INVALID_ARGUMENT;
if (s->format == XTC_PLUGIN_BUILTIN) return xtc_builtin_describe(s,out);
if (s->format == XTC_PLUGIN_LADSPA) return xtc_ladspa_describe(s,rate,out);
r = xtc_plugin_probe_format(s->format,s->path,s->index,rate,&actual);
if (r != XTC_OK) return r;
@ -49,7 +54,7 @@ xtc_result xtc_plugin_describe(const xtc_plugin_spec *s, double rate, xtc_plugin
return XTC_OK;
}
void xtc_plugin_destroy(xtc_plugin *p)
{ if (p) { xtc_ladspa_destroy(p->ladspa); xtc_modern_destroy(p->modern); free(p); } }
{ if (p) { xtc_builtin_destroy(p->builtin); xtc_ladspa_destroy(p->ladspa); xtc_modern_destroy(p->modern); free(p); } }
xtc_result xtc_plugin_create(const xtc_plugin_spec *s, double rate, size_t frames, xtc_plugin **out)
{
xtc_plugin *p; xtc_result r; xtc_plugin_spec actual;
@ -58,7 +63,8 @@ xtc_result xtc_plugin_create(const xtc_plugin_spec *s, double rate, size_t frame
r = xtc_plugin_spec_validate(s); if (r != XTC_OK) return r;
if (!frames || frames > 65536 || !isfinite(rate) || rate < 1 || rate > 768000) return XTC_ERR_INVALID_ARGUMENT;
p = calloc(1,sizeof(*p)); if (!p) return XTC_ERR_OUT_OF_MEMORY;
if (s->format == XTC_PLUGIN_LADSPA) r = xtc_ladspa_create(s,rate,frames,&p->ladspa);
if (s->format == XTC_PLUGIN_BUILTIN) r = xtc_builtin_create(s,rate,frames,&p->builtin);
else if (s->format == XTC_PLUGIN_LADSPA) r = xtc_ladspa_create(s,rate,frames,&p->ladspa);
else {
r = xtc_modern_open(s->format,s->path,s->index,rate,frames,&p->modern,&actual);
if (r == XTC_OK && (actual.instrument != s->instrument || actual.unique_id != s->unique_id || actual.inputs != s->inputs ||
@ -71,12 +77,12 @@ xtc_result xtc_plugin_process_at(xtc_plugin *p, const float *in, float *out, siz
{
xtc_result r;
if (!p) return XTC_ERR_INVALID_ARGUMENT;
r = p->modern ? xtc_modern_process(p->modern,in,out,frames) : xtc_ladspa_process_at(p->ladspa,in,out,frames,position);
r = p->builtin ? xtc_builtin_process(p->builtin,in,out,frames,position) : p->modern ? xtc_modern_process(p->modern,in,out,frames) : xtc_ladspa_process_at(p->ladspa,in,out,frames,position);
if (r == XTC_OK) p->next = position <= UINT64_MAX-frames ? position+frames : 0;
return r;
}
xtc_result xtc_plugin_process_midi(xtc_plugin *p, const xtc_midi_event *events, size_t count, float *out, size_t frames)
{ return p && p->modern ? xtc_modern_process_midi(p->modern,events,count,out,frames) : XTC_ERR_UNSUPPORTED; }
{ return p && p->builtin ? xtc_builtin_midi(p->builtin,events,count,out,frames) : p && p->modern ? xtc_modern_process_midi(p->modern,events,count,out,frames) : XTC_ERR_UNSUPPORTED; }
xtc_result xtc_plugin_process(xtc_plugin *p, const float *in, float *out, size_t frames)
{ return xtc_plugin_process_at(p,in,out,frames,p ? p->next : 0); }
xtc_result xtc_plugin_parameters(const xtc_plugin_spec *s, double rate, xtc_parameter_info out[XTC_PLUGIN_CONTROLS])

View file

@ -16,6 +16,7 @@
/* Header-only optional dependency; absent development header gives explicit
* unsupported stubs, preserving metadata-only load/save of plugin documents. */
#include "config.h"
#include "builtin.h"
static int terminated(const char *s, size_t n) { return memchr(s, 0, n) != NULL; }
xtc_result xtc_plugin_spec_validate(const xtc_plugin_spec *s)
{
@ -24,9 +25,11 @@ xtc_result xtc_plugin_spec_validate(const xtc_plugin_spec *s)
!terminated(s->label,sizeof(s->label)) || !s->label[0] || s->index >= 1024 ||
s->inputs > 1 || s->control_count > XTC_PLUGIN_CONTROLS ||
s->tempo < 20000 || s->tempo > 300000 || s->point_count > XTC_PLUGIN_POINTS) return XTC_ERR_INVALID_ARGUMENT;
if (s->format < XTC_PLUGIN_LADSPA || s->format > XTC_PLUGIN_VST3 ||
if (s->format < XTC_PLUGIN_LADSPA || s->format > XTC_PLUGIN_BUILTIN ||
!terminated(s->identifier,sizeof(s->identifier))) return XTC_ERR_INVALID_ARGUMENT;
if (s->format != XTC_PLUGIN_LADSPA) {
if (s->format == XTC_PLUGIN_BUILTIN) {
if (xtc_builtin_validate(s) != XTC_OK) return XTC_ERR_INVALID_ARGUMENT;
} else if (s->format != XTC_PLUGIN_LADSPA) {
if (s->instrument > 1 || s->inputs != (s->instrument ? 0U : 1U) || s->control_count || s->point_count ||
((s->format == XTC_PLUGIN_CLAP || s->format == XTC_PLUGIN_VST3) && !s->identifier[0]))
return XTC_ERR_UNSUPPORTED;

View file

@ -37,7 +37,8 @@ static const xtc_setting_info schema[] = {
NUM("project_defaults",pan_cc,"New project pan CC (128 disables)",0,128),
NUM("project_defaults",sustain_cc,"New project sustain CC (128 disables)",0,128),
NUM("transport",loop_start,"Loop start, ticks",0,38399999), NUM("transport",loop_end,"Loop end, ticks",1,38400000),
NUM("transport",loop_enabled,"Loop enabled: 0 or 1",0,1)
NUM("transport",loop_enabled,"Loop enabled: 0 or 1",0,1),
NUM("transport",follow_playhead,"Follow playhead: 0 or 1",0,1)
};
#define COUNT (sizeof(schema)/sizeof(schema[0]))
const xtc_setting_info *xtc_settings_schema(size_t *count) { if (count) *count = COUNT; return schema; }