Skip to content

Commit f1699f8

Browse files
committed
add bend_down & bend_up opcodes #3
also minor renames of a couple private functions
1 parent 75d5983 commit f1699f8

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//!
2+
//!
3+
14
pub mod error;
25
pub(crate) mod sfz;
36
pub(crate) mod utils;

src/sfz/instrument.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ impl Instrument {
158158
}
159159
} else {
160160
// an opcode for the <region>
161-
if status.are_regions() {
161+
if status.are_regions_in_current_group() {
162162
#[cfg(debug)]
163163
println!(
164164
" - new region opcode: {:?} (g{} r{})",
@@ -365,7 +365,7 @@ impl InstrumentParsingStatus {
365365
// ensure we are out of the <global> header
366366
self.is_header_global = false;
367367
// ensure we reset the region counter for the current group
368-
self.region_reset();
368+
self.region_reset_in_current_group();
369369
// increment the group counter
370370
self.group_increment();
371371
}
@@ -435,9 +435,9 @@ impl InstrumentParsingStatus {
435435
}
436436

437437
/// Resets the region counter for the group
438-
fn region_reset(&mut self) {
438+
fn region_reset_in_current_group(&mut self) {
439439
#[cfg(debug)]
440-
println!(" status.region_reset()");
440+
println!(" status.region_reset_in_current_group()");
441441
self.region_counter_in_group = None;
442442
}
443443

@@ -463,7 +463,7 @@ impl InstrumentParsingStatus {
463463
}
464464

465465
/// Are there any regions already defined for the current group?
466-
pub fn are_regions(&self) -> bool {
466+
pub fn are_regions_in_current_group(&self) -> bool {
467467
if self.region_counter_in_group == None {
468468
return false;
469469
}

src/sfz/opcodes/defaults.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ pub(crate) static OPCODE_DEFAULT: phf::Map<&'static str, OpcodeType> = phf_map!
1515
"ampeg_hold" => OpcodeType::f32(Some(0.0)),
1616
"ampeg_release" => OpcodeType::f32(Some(0.0)),
1717
"ampeg_sustain" => OpcodeType::f32(Some(100.0)),
18+
"bend_down" => OpcodeType::i16(Some(-200)),
19+
"bend_up" => OpcodeType::i16(Some(200)),
1820
"cutoff" => OpcodeType::f32(None),
1921
"fil_type" => OpcodeType::fil_type(Some(fil_type::lpf_2p)),
2022
"fil_veltrack" => OpcodeType::i16(Some(0)),

src/sfz/opcodes/parse.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ impl Opcode {
172172
("ampeg_sustain", _) => {
173173
utils::check_f32_between(value, 0., 100.).map(Opcode::ampeg_sustain)
174174
}
175+
("bend_down", _) => utils::check_i16_between(value, -9600, 9600).map(Opcode::bend_down),
176+
("bend_up", _) => utils::check_i16_between(value, -9600, 9600).map(Opcode::bend_up),
175177
// NOTE: upper range is SampleRate/2 (it should be checked when sample rate is known)
176178
("cutoff", _) => {
177179
utils::check_f32_between(value, 0., MAX_SAMPLE_RATE).map(Opcode::cutoff)

0 commit comments

Comments
 (0)