diff options
Diffstat (limited to 'src/LV2-render.c')
| -rw-r--r-- | src/LV2-render.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/LV2-render.c b/src/LV2-render.c index 2dd8b40..e882cd4 100644 --- a/src/LV2-render.c +++ b/src/LV2-render.c @@ -25,6 +25,7 @@ #include "LV2-render_internal.h" + #include "lv2/lv2plug.in/ns/ext/atom/atom.h" #include "lv2/lv2plug.in/ns/ext/buf-size/buf-size.h" #include "lv2/lv2plug.in/ns/ext/data-access/data-access.h" @@ -130,9 +131,8 @@ SNDFILE *open_wav_file(char *output_file, float sample_rate, int nchannels, size return outfile; } -int first_event = 1; -int process_midi_cb(fluid_midi_event_t *event, size_t msecs, process_midi_ctx_t *ctx) +int process_midi_cb(fluid_midi_event_t *event, size_t msecs, size_t msecs_since_start, process_midi_ctx_t *ctx) { Jalv *jalv = ctx->jalv; float **pluginAudioIOBuffers = (float **)calloc(jalv->num_ports, sizeof(float *)); @@ -140,25 +140,29 @@ int process_midi_cb(fluid_midi_event_t *event, size_t msecs, process_midi_ctx_t float *pluginAudioPtrs[100]; size_t pluginAudioOutputCount = 0; size_t nframes; - + size_t nframes_since_start; + /* convert msecs */ + nframes_since_start = msecs_since_start * ctx->sample_rate / 1000; nframes = msecs * ctx->sample_rate / 1000; //TODO maybe just get rid of this stuff //ORIGINAL-> sending to evbuf: frame: 13136896, rolling: 1.000000, calc: -1, bar: 0, beat_type: 1146875112, bpb: 1184130760, bpm: 0: need valid if: -787014688 const bool rolling = 1; +//we don't even use this...probably should remove uint8_t pos_buf[256]; LV2_Atom* lv2_pos = (LV2_Atom*)pos_buf; - if (first_event) { + //but here, we can take out this if, right? and just send this new atom with an updated position every time? yeah /* Build an LV2 position object to report change to plugin */ lv2_atom_forge_set_buffer(&jalv->forge, pos_buf, sizeof(pos_buf)); LV2_Atom_Forge* forge = &jalv->forge; LV2_Atom_Forge_Frame frame; lv2_atom_forge_object(forge, &frame, 0, jalv->urids.time_Position); lv2_atom_forge_key(forge, jalv->urids.time_frame); - lv2_atom_forge_long(forge, 13136896); + lv2_atom_forge_long(forge, nframes_since_start); //ok all good? almost, there is one more thing below with fixed nframes, and need to remove first_event ifs. ok + lv2_atom_forge_key(forge, jalv->urids.time_speed); - lv2_atom_forge_float(forge, rolling ? 1.0 : 0.0); + lv2_atom_forge_float(forge, 1.0 ); if (jalv->opts.dump) { char* str = sratom_to_turtle( @@ -167,10 +171,9 @@ int process_midi_cb(fluid_midi_event_t *event, size_t msecs, process_midi_ctx_t printf("\n## Position\n%s\n", str); free(str); } - } /* Update transport state to expected values for next cycle */ - jalv->position = 13136896 + nframes; //rolling ? pos.frame + nframes : pos.frame; + jalv->position = rolling ? nframes_since_start + nframes : nframes_since_start; //wait,shouldn't this just be nframes_since_start? it's how was in original jalv, o i just keep it weird FIXME seems weird to me ok so I should just build and test this? yep jalv->bpm = 120.0; //pos.beats_per_minute; jalv->rolling = rolling; @@ -197,13 +200,13 @@ int process_midi_cb(fluid_midi_event_t *event, size_t msecs, process_midi_ctx_t lv2_evbuf_reset(port->evbuf, true); LV2_Evbuf_Iterator iter = lv2_evbuf_begin(port->evbuf); +///i see what's going on, we only send it on the first event, we need to update it, right? looks so I don't understand &iter, 0, 0 +//but LV2_ATOM_BODY is the size? it's pointer to body of atom ok lv2_pos->size is that the size of the struct? size of body right +//well do we ever update the position? maybe in that part that used to check whether jack transport was rolling? well original jalv send it every time there is change, and jack maybe sending it regurally, and we here send it only one to send bpm and other stuff at first time. interesting seems like this is likely the cause - if(first_event){ - lv2_evbuf_write( + lv2_evbuf_write( &iter, 0, 0, lv2_pos->type, lv2_pos->size, LV2_ATOM_BODY(lv2_pos)); - first_event = 0; - } uint8_t midi_event_buffer[3]; midi_event_buffer[0] = event->type; midi_event_buffer[1] = event->param1; |
