[LAD] Need help with LV2 midi events.

From: Ulrich Lorenz Schlüter <audio-mobster@email-addr-hidden>
Date: Sat Jul 25 2009 - 00:35:17 EEST

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");

_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/mailman/listinfo/linux-audio-dev
Received on Sat Jul 25 04:15:03 2009

This archive was generated by hypermail 2.1.8 : Sat Jul 25 2009 - 04:15:03 EEST