WIP: fix VST3 version
This commit is contained in:
@@ -132,12 +132,11 @@ pub fn create_editor(
|
||||
cagire::state::ColorScheme::default().to_palette();
|
||||
theme::set(cagire_ratatui::theme::build::build(&palette));
|
||||
|
||||
let mut app = App::with_shared(
|
||||
let mut app = App::new_plugin(
|
||||
Arc::clone(&variables),
|
||||
Arc::clone(&dict),
|
||||
Arc::clone(&rng),
|
||||
);
|
||||
app.plugin_mode = true;
|
||||
app.audio.section = cagire::state::EngineSection::Settings;
|
||||
app.audio.setting_kind = cagire::state::SettingKind::Polyphony;
|
||||
|
||||
|
||||
@@ -119,6 +119,7 @@ impl Plugin for CagirePlugin {
|
||||
},
|
||||
}];
|
||||
|
||||
const MIDI_INPUT: MidiConfig = MidiConfig::MidiCCs;
|
||||
const MIDI_OUTPUT: MidiConfig = MidiConfig::MidiCCs;
|
||||
|
||||
fn params(&self) -> Arc<dyn Params> {
|
||||
|
||||
@@ -69,7 +69,7 @@ impl Forth {
|
||||
if writes.is_empty() {
|
||||
return;
|
||||
}
|
||||
let mut new_vars = (**self.vars.load()).clone();
|
||||
let mut new_vars = (*self.vars.load_full()).clone();
|
||||
for (k, v) in writes {
|
||||
new_vars.insert(k, v);
|
||||
}
|
||||
@@ -99,7 +99,7 @@ impl Forth {
|
||||
let mut stack = self.stack.lock();
|
||||
let mut outputs: Vec<String> = Vec::with_capacity(8);
|
||||
let mut cmd = CmdRegister::new();
|
||||
let vars_snapshot = self.vars.load();
|
||||
let vars_snapshot = self.vars.load_full();
|
||||
let mut var_writes: HashMap<String, Value> = HashMap::new();
|
||||
|
||||
self.execute_ops(
|
||||
|
||||
@@ -83,15 +83,19 @@ impl App {
|
||||
let variables = Arc::new(ArcSwap::from_pointee(HashMap::new()));
|
||||
let dict = Arc::new(Mutex::new(HashMap::new()));
|
||||
let rng = Arc::new(Mutex::new(StdRng::seed_from_u64(0)));
|
||||
Self::build(variables, dict, rng)
|
||||
Self::build(variables, dict, rng, false)
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn with_shared(variables: Variables, dict: Dictionary, rng: Rng) -> Self {
|
||||
Self::build(variables, dict, rng)
|
||||
Self::build(variables, dict, rng, false)
|
||||
}
|
||||
|
||||
fn build(variables: Variables, dict: Dictionary, rng: Rng) -> Self {
|
||||
pub fn new_plugin(variables: Variables, dict: Dictionary, rng: Rng) -> Self {
|
||||
Self::build(variables, dict, rng, true)
|
||||
}
|
||||
|
||||
fn build(variables: Variables, dict: Dictionary, rng: Rng, plugin_mode: bool) -> Self {
|
||||
let script_engine =
|
||||
ScriptEngine::new(Arc::clone(&variables), Arc::clone(&dict), Arc::clone(&rng));
|
||||
let live_keys = Arc::new(LiveKeyState::new());
|
||||
@@ -119,11 +123,15 @@ impl App {
|
||||
|
||||
undo: UndoHistory::default(),
|
||||
|
||||
audio: AudioSettings::default(),
|
||||
audio: if plugin_mode {
|
||||
AudioSettings::new_plugin()
|
||||
} else {
|
||||
AudioSettings::default()
|
||||
},
|
||||
options: OptionsState::default(),
|
||||
panel: PanelState::default(),
|
||||
midi: MidiState::new(),
|
||||
plugin_mode: false,
|
||||
plugin_mode,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -867,7 +867,7 @@ impl SequencerState {
|
||||
|
||||
self.speed_overrides.clear();
|
||||
{
|
||||
let vars = self.variables.load();
|
||||
let vars = self.variables.load_full();
|
||||
for id in self.audio_state.active_patterns.keys() {
|
||||
let key = format_speed_key(&mut self.key_buf.speed, id.bank, id.pattern);
|
||||
if let Some(v) = vars.get(key).and_then(|v: &Value| v.as_float().ok()) {
|
||||
@@ -998,7 +998,7 @@ impl SequencerState {
|
||||
};
|
||||
}
|
||||
|
||||
let vars = self.variables.load();
|
||||
let vars = self.variables.load_full();
|
||||
let new_tempo = vars
|
||||
.get("__tempo__")
|
||||
.and_then(|v: &Value| v.as_float().ok());
|
||||
@@ -1026,7 +1026,7 @@ impl SequencerState {
|
||||
}
|
||||
|
||||
if needs_removal {
|
||||
let mut new_vars = (**vars).clone();
|
||||
let mut new_vars = (*vars).clone();
|
||||
new_vars.remove("__tempo__");
|
||||
for id in completed {
|
||||
new_vars.remove(format_chain_key(&mut buf, id.bank, id.pattern));
|
||||
|
||||
@@ -253,6 +253,28 @@ impl Default for AudioSettings {
|
||||
}
|
||||
|
||||
impl AudioSettings {
|
||||
pub fn new_plugin() -> Self {
|
||||
Self {
|
||||
config: AudioConfig::default(),
|
||||
section: EngineSection::default(),
|
||||
device_kind: DeviceKind::default(),
|
||||
setting_kind: SettingKind::default(),
|
||||
output_devices: Vec::new(),
|
||||
input_devices: Vec::new(),
|
||||
output_list: ListSelectState {
|
||||
cursor: 0,
|
||||
scroll_offset: 0,
|
||||
},
|
||||
input_list: ListSelectState {
|
||||
cursor: 0,
|
||||
scroll_offset: 0,
|
||||
},
|
||||
restart_pending: false,
|
||||
error: None,
|
||||
sample_registry: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn refresh_devices(&mut self) {
|
||||
self.output_devices = doux::audio::list_output_devices();
|
||||
self.input_devices = doux::audio::list_input_devices();
|
||||
|
||||
Reference in New Issue
Block a user