[LAD] Need help with LV2 midi events.

Ulrich Lorenz Schlüter audio-mobster at gmx.de
Fri Jul 24 21:35:17 UTC 2009


Hello list,

I never get a valid event iterator with lv2_event_is_valid(). Can
somebody tell me why please?

Thanks and regards

#include <iostream>
#include <ctime>
#include <lv2plugin.hpp>

#include <lv2_event_helpers.h>
#include <sys/time.h>

using namespace LV2;
using namespace std;


class Delay : public Plugin<Delay, URIMap<true>, EventRef<true> > {
public:

  Delay(double rate)
    : Plugin<Delay, URIMap<true>, EventRef<true> >(7),
    m_midi_type(uri_to_id(LV2_EVENT_URI,
                "http://lv2plug.in/ns/ext/midi#MidiEvent")) {
  }

  void run(uint32_t nframes) {

      // initialise event buffer iterators
      LV2_Event_Buffer* inbuf = p<LV2_Event_Buffer>(*p(6));
      LV2_Event_Iterator in;
      lv2_event_begin(&in, inbuf);

      while (lv2_event_is_valid(&in)) {
        cout << "event\n";
        uint8_t* data;
        LV2_Event* ev = lv2_event_get(&in, &data);
        lv2_event_increment(&in);
        if (ev->type == 0)
            event_unref(ev);
        if (ev->type == m_midi_type) {
            gettimeofday(&m_now,NULL);
            cout << ev->frames << "\n";
            m_last = m_now;
        }
     }
  }

protected:
  uint32_t m_midi_type;

  timeval m_now, m_last;

};


static int _ =
Delay::register_class("http://uli-plugins.sourceforge.net/lv2/mtcsimpledelay");




More information about the Linux-audio-dev mailing list