Skip to content

Commit

Permalink
#160 Make parameters other than the first one accessible in expression
Browse files Browse the repository at this point in the history
  • Loading branch information
helgoboss committed Mar 9, 2021
1 parent f1ee57a commit 654310c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
13 changes: 10 additions & 3 deletions main/src/domain/unresolved_reaper_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::core::hash_util;
use crate::domain::{
ActionInvocationType, DomainGlobal, ExtendedProcessorContext, ParameterArray, ProcessorContext,
ReaperTarget, SoloBehavior, TouchedParameterType, TrackExclusivity, TransportAction,
PLUGIN_PARAMETER_COUNT,
};
use derive_more::{Display, Error};
use fasteval::{Compiler, Evaler, Instruction, Slab};
Expand Down Expand Up @@ -408,10 +409,16 @@ impl ExpressionEvaluator {
fn evaluate_internal(&self, params: &ParameterArray) -> Result<f64, fasteval::Error> {
use fasteval::eval_compiled_ref;
let mut cb = |name: &str, args: Vec<f64>| -> Option<f64> {
match name {
"p1" => Some(params[0] as _),
_ => None,
if !name.starts_with('p') {
return None;
}
let value: u32 = name[1..].parse().ok()?;
if !(1..=PLUGIN_PARAMETER_COUNT).contains(&value) {
return None;
}
let index = (value - 1) as usize;
let param_value = params[index];
Some(param_value as f64)
};
let val = eval_compiled_ref!(&self.instruction, &self.slab, &mut cb);
Ok(val)
Expand Down
1 change: 1 addition & 0 deletions main/src/infrastructure/ui/realearn.rc
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ BEGIN
LTEXT "Address", ID_SOURCE_OSC_ADDRESS_LABEL_TEXT, 11, 201, 30, 9, NOT WS_GROUP | SS_LEFT, WS_EX_LEFT
COMBOBOX ID_TARGET_LINE_2_COMBO_BOX_1, 220, 116, 58, 30, WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_LEFT
EDITTEXT ID_TARGET_LINE_2_EDIT_CONTROL, 282, 115, 127, 14, ES_AUTOHSCROLL, WS_EX_LEFT
LTEXT "Hint", ID_TARGET_LINE_2_LABEL_3, 412, 118, 26, 9, NOT WS_GROUP | SS_LEFT, WS_EX_LEFT
END


Expand Down
1 change: 1 addition & 0 deletions main/src/infrastructure/ui/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@
#define ID_MAPPING_ACTIVATION_SETTING_1_LABEL_TEXT 40082
#define ID_TARGET_LINE_2_COMBO_BOX_2 40082
#define ID_MAPPING_ACTIVATION_SETTING_2_COMBO_BOX 40083
#define ID_TARGET_LINE_2_LABEL_3 40083
#define ID_MAPPING_ACTIVATION_SETTING_2_CHECK_BOX 40084
#define ID_TARGET_CATEGORY_COMBO_BOX 40085
#define ID_TARGET_FX_ANCHOR_COMBO_BOX 40086
Expand Down

0 comments on commit 654310c

Please sign in to comment.