Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // .....
- void DX7::run (uint32_t sample_count)
- {
- const LV2_Atom_Sequence* seq = p<LV2_Atom_Sequence> (p_lv2_events_in);
- float* output = p(p_lv2_audio_out_1)
- uint32_t last_frame = 0, num_this_time = 0;
- for (LV2_Atom_Event* ev = lv2_atom_sequence_begin (&seq->body);
- !lv2_atom_sequence_is_end(&seq->body, seq->atom.size, ev);
- ev = lv2_atom_sequence_next (ev))
- {
- num_this_time = ev->time.frames - last_frame;
- // If it's midi, send it to the engine
- if (ev->body.type == m_midi_type)
- ring_buffer_.Write ((uint8_t*) LV2_ATOM_BODY (&ev->body), ev->body.size);
- // render audio from the last frame until the timestamp of this event
- synth_unit_->GetSamples (num_this_time, outbuf16_);
- // i is the index of the engine's buf, which always starts at 0 (i think)
- // j is the index of the plugin's float output buffer which will be the timestamp
- // of the last processed atom event.
- for (uint32_t i = 0, j = last_frame; i < num_this_time; ++i, ++j)
- output[j] = static_cast<float> (outbuf16_[i]) * scaler;
- last_frame = ev->time.frames;
- }
- // render remaining samples if any left
- if (last_frame < sample_count)
- {
- // do the same thing as above except from last frame until the end of
- // the processing cycles last sample. at this point, all events have
- // already been handled.
- num_this_time = sample_count - last_frame;
- synth_unit_->GetSamples (num_this_time, outbuf16_);
- for (uint32_t i = 0, j = last_frame; i < num_this_time; ++i, ++j)
- output[j] = static_cast<float> (outbuf16_[i]) * scaler;
- }
- }
- // ....
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement