feat: shape MIDI phrase dynamics with bounded velocity scaling
This commit is contained in:
parent
77fc5b4c0e
commit
4af18fc33d
9 changed files with 44 additions and 7 deletions
|
|
@ -1342,6 +1342,8 @@ int main(int argc, char **argv)
|
|||
CHECK(xtc_project_get_note(s->project(),0,&quantized)==XTC_OK && quantized.length_tick==3540);
|
||||
edit.type=XTC_MIDI_TRANSFORM_SCALE;edit.root=0;edit.scale=1;CHECK(s->transform_midi(edit)==XTC_OK);
|
||||
CHECK(xtc_project_get_note(s->project(),0,&quantized)==XTC_OK && quantized.pitch==60);
|
||||
edit.type=XTC_MIDI_TRANSFORM_VELOCITY;edit.velocity_percent=50;edit.velocity_offset=10;CHECK(s->transform_midi(edit)==XTC_OK);
|
||||
CHECK(xtc_project_get_note(s->project(),0,&quantized)==XTC_OK && quantized.velocity==60);
|
||||
window.do_callback();
|
||||
}
|
||||
if (failures != 0) return 1;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,22 @@
|
|||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
static void test_velocity(void)
|
||||
{
|
||||
xtc_project *p=NULL;uint64_t t,c,n;xtc_note_info note;xtc_midi_transform edit={0};
|
||||
assert(xtc_project_create(&p)==XTC_OK && xtc_project_add_track(p,"Track",&t)==XTC_OK);
|
||||
assert(xtc_project_add_midi_clip(p,t,0,960,&c)==XTC_OK);
|
||||
assert(xtc_project_add_note(p,c,0,120,61,100,0,&n)==XTC_OK);
|
||||
edit.type=XTC_MIDI_TRANSFORM_VELOCITY;edit.velocity_percent=50;edit.velocity_offset=10;
|
||||
assert(xtc_project_transform_midi(p,&c,1,&edit)==XTC_OK);
|
||||
assert(xtc_project_get_note(p,0,¬e)==XTC_OK && note.velocity==60 && note.pitch==61);
|
||||
edit.velocity_percent=400;assert(xtc_project_transform_midi(p,&c,1,&edit)==XTC_OK);
|
||||
assert(xtc_project_get_note(p,0,¬e)==XTC_OK && note.velocity==127);
|
||||
edit.velocity_percent=0;edit.velocity_offset=-127;assert(xtc_project_transform_midi(p,&c,1,&edit)==XTC_OK);
|
||||
assert(xtc_project_get_note(p,0,¬e)==XTC_OK && note.velocity==1 && note.id==n);
|
||||
edit.velocity_percent=401;assert(xtc_project_transform_midi(p,&c,1,&edit)==XTC_ERR_INVALID_ARGUMENT);
|
||||
xtc_project_destroy(p);
|
||||
}
|
||||
static void test_scale(void)
|
||||
{
|
||||
xtc_project *p=NULL;uint64_t t,c,n;xtc_note_info note;xtc_midi_transform edit={0};
|
||||
|
|
@ -90,7 +106,7 @@ static void test_repeat(void)
|
|||
}
|
||||
int main(void)
|
||||
{
|
||||
test_repeat();test_align_slip();test_swing();test_gate_legato();test_scale();
|
||||
test_repeat();test_align_slip();test_swing();test_gate_legato();test_scale();test_velocity();
|
||||
xtc_project *p=NULL;uint64_t track,a,b,n,ids[2],out[2]={999,999};xtc_clip_info c;
|
||||
size_t tracks,clips,notes;
|
||||
assert(xtc_project_create(&p)==XTC_OK);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue