Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. // .....
  2.  
  3. void DX7::run (uint32_t sample_count)
  4. {
  5. const LV2_Atom_Sequence* seq = p<LV2_Atom_Sequence> (p_lv2_events_in);
  6. float* output = p(p_lv2_audio_out_1)
  7. uint32_t last_frame = 0, num_this_time = 0;
  8.  
  9. for (LV2_Atom_Event* ev = lv2_atom_sequence_begin (&seq->body);
  10. !lv2_atom_sequence_is_end(&seq->body, seq->atom.size, ev);
  11. ev = lv2_atom_sequence_next (ev))
  12. {
  13. num_this_time = ev->time.frames - last_frame;
  14.  
  15. // If it's midi, send it to the engine
  16. if (ev->body.type == m_midi_type)
  17. ring_buffer_.Write ((uint8_t*) LV2_ATOM_BODY (&ev->body), ev->body.size);
  18.  
  19. // render audio from the last frame until the timestamp of this event
  20. synth_unit_->GetSamples (num_this_time, outbuf16_);
  21.  
  22. // i is the index of the engine's buf, which always starts at 0 (i think)
  23. // j is the index of the plugin's float output buffer which will be the timestamp
  24. // of the last processed atom event.
  25. for (uint32_t i = 0, j = last_frame; i < num_this_time; ++i, ++j)
  26. output[j] = static_cast<float> (outbuf16_[i]) * scaler;
  27.  
  28. last_frame = ev->time.frames;
  29. }
  30.  
  31. // render remaining samples if any left
  32. if (last_frame < sample_count)
  33. {
  34. // do the same thing as above except from last frame until the end of
  35. // the processing cycles last sample. at this point, all events have
  36. // already been handled.
  37. num_this_time = sample_count - last_frame;
  38. synth_unit_->GetSamples (num_this_time, outbuf16_);
  39. for (uint32_t i = 0, j = last_frame; i < num_this_time; ++i, ++j)
  40. output[j] = static_cast<float> (outbuf16_[i]) * scaler;
  41. }
  42. }
  43.  
  44. // ....
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement