feat(engine): render prepared per-track insert graphs (phase 82)
This commit is contained in:
parent
7489f86351
commit
62cee7a7b0
10 changed files with 215 additions and 5 deletions
|
|
@ -2,6 +2,7 @@
|
|||
#include "xtc/xtc_dsp.h"
|
||||
#include "xtc/xtc_plugin.h"
|
||||
#include "../mixer/mix_internal.h"
|
||||
#include "../mixer/track_fx.h"
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
|
@ -33,6 +34,7 @@ struct xtc_midi_plan {
|
|||
unsigned int sustain[16];
|
||||
unsigned char control_map[16][3];
|
||||
xtc_mix_snapshot mix;
|
||||
xtc_track_fx *fx;
|
||||
span notes[XTC_PROJECT_MAX_NOTES];
|
||||
xtc_plugin *plugins[XTC_PROJECT_MAX_TRACKS];
|
||||
size_t live_track;
|
||||
|
|
@ -209,6 +211,7 @@ xtc_result xtc_midi_plan_create(const xtc_project *project, unsigned int rate, x
|
|||
}
|
||||
if (project->live_instrument == p->mix.tracks[i].id) p->live_track = i;
|
||||
}
|
||||
{xtc_result r=xtc_track_fx_create(project,rate,1,&p->fx);if(r!=XTC_OK){xtc_midi_plan_destroy(p);return r;}}
|
||||
memcpy(p->control_map,project->control_map,sizeof(p->control_map));
|
||||
p->controller_frames = rate / 200U;
|
||||
if (!p->controller_frames) p->controller_frames = 1;
|
||||
|
|
@ -228,6 +231,7 @@ void xtc_midi_plan_destroy(xtc_midi_plan *p)
|
|||
size_t i;
|
||||
if (!p) return;
|
||||
for (i = 0; i < XTC_PROJECT_MAX_TRACKS; ++i) xtc_plugin_destroy(p->plugins[i]);
|
||||
xtc_track_fx_destroy(p->fx);
|
||||
free(p);
|
||||
}
|
||||
|
||||
|
|
@ -362,6 +366,7 @@ static void segment(xtc_midi_plan *p, uint64_t position, float *out, float *righ
|
|||
if (distance < p->fade_frames)
|
||||
sample *= (float)distance / (float)p->fade_frames;
|
||||
}
|
||||
if(xtc_track_fx_add(p->fx,s->track,(size_t)(position-p->monitor_position)+j,sample))continue;
|
||||
if (p->monitor) xtc_mix_monitor(&p->mix, p->monitor, p->monitor_stride, s->track, position+j,
|
||||
(size_t)(position-p->monitor_position)+j, sample, right != NULL);
|
||||
out[j] += sample * xtc_mix_level(&p->mix, s->track, position + j, right ? 0U : 2U);
|
||||
|
|
@ -445,6 +450,7 @@ static xtc_result instruments(xtc_midi_plan *p, uint64_t position, const xtc_mid
|
|||
if (r != XTC_OK) return r;
|
||||
for (j = 0; j < n; ++j) {
|
||||
float sample = p->scratch[j];
|
||||
if(xtc_track_fx_add(p->fx,track,offset+j,sample))continue;
|
||||
if (p->monitor) xtc_mix_monitor(&p->mix,p->monitor,p->monitor_stride,track,begin+j,offset+j,sample,right != NULL);
|
||||
out[offset+j] += sample*xtc_mix_level(&p->mix,track,begin+j,right ? 0U : 2U);
|
||||
if (right) right[offset+j] += sample*xtc_mix_level(&p->mix,track,begin+j,1);
|
||||
|
|
@ -486,6 +492,7 @@ xtc_result xtc_midi_plan_render_stereo(xtc_midi_plan *p, uint64_t position, cons
|
|||
return XTC_OK;
|
||||
if (p->next_position != position)
|
||||
xtc_midi_plan_reset(p);
|
||||
xtc_track_fx_begin(p->fx,position,frames);
|
||||
memset(out, 0, frames * sizeof(*out));
|
||||
if (right)
|
||||
memset(right, 0, frames * sizeof(*right));
|
||||
|
|
@ -504,6 +511,8 @@ xtc_result xtc_midi_plan_render_stereo(xtc_midi_plan *p, uint64_t position, cons
|
|||
xtc_midi_plan_reset(p); return r;
|
||||
}
|
||||
}
|
||||
{xtc_result r=xtc_track_fx_finish(p->fx,&p->mix,position,out,right,frames,p->monitor,p->monitor_stride);
|
||||
if(r!=XTC_OK){memset(out,0,frames*sizeof(*out));if(right)memset(right,0,frames*sizeof(*right));xtc_midi_plan_reset(p);return r;}}
|
||||
for (i = 0; i < frames; ++i) {
|
||||
out[i] = xtc_dsp_finite(out[i]);
|
||||
if (right) right[i] = xtc_dsp_finite(right[i]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue