summaryrefslogtreecommitdiff
path: root/src/event.h
diff options
context:
space:
mode:
authordeva <deva>2011-03-01 19:19:02 +0000
committerdeva <deva>2011-03-01 19:19:02 +0000
commite190d38057892b69246391841b234a368bc2b4ad (patch)
tree34f946bc1c3b86997d4cd45e63c433ef07b36486 /src/event.h
parentc393edc920f8ee126d1bced3500b6bc1ecf86f83 (diff)
MAJOR rewrite of the internals. New input/output 'plugin' system. Still a lot missing.
Diffstat (limited to 'src/event.h')
-rw-r--r--src/event.h99
1 files changed, 86 insertions, 13 deletions
diff --git a/src/event.h b/src/event.h
index b721df0..2128386 100644
--- a/src/event.h
+++ b/src/event.h
@@ -2,8 +2,8 @@
/***************************************************************************
* event.h
*
- * Mon Jul 21 10:56:01 CEST 2008
- * Copyright 2008 Bent Bisballe Nyeng
+ * Sat Sep 18 22:02:16 CEST 2010
+ * Copyright 2010 Bent Bisballe Nyeng
* deva@aasimon.org
****************************************************************************/
@@ -27,24 +27,97 @@
#ifndef __DRUMGIZMO_EVENT_H__
#define __DRUMGIZMO_EVENT_H__
-#include <jack/jack.h>
+#include <map>
+#include <stdio.h>
+#include <string>
+#include <sndfile.h>
-#include <set>
-#include "audiofile.h"
+#include "audio.h"
+#include "mutex.h"
+
+typedef unsigned int timepos_t;
class Event {
public:
- Event(jack_port_t *port, AudioFile *sample, size_t time, size_t duration = 0);
- ~Event();
+ typedef enum {
+ sine,
+ noise,
+ sample
+ } type_t;
+
+ virtual type_t type() = 0;
+
+ channel_t channel;
+ timepos_t offset;
+};
+
+class EventSine : public Event {
+public:
+ EventSine(channel_t c, float f, float g, timepos_t l)
+ {
+ channel = c;
+ freq = f;
+ gain = g;
+ len = l;
+ t = 0;
+ }
+ Event::type_t type() { return Event::sine; }
+
+ float freq;
+ float gain;
+ timepos_t len;
+
+ unsigned int t;
+};
+
+class EventNoise : public Event {
+public:
+ EventNoise(channel_t c, float g, timepos_t l)
+ {
+ channel = c;
+ gain = g;
+ len = l;
+ t = 0;
+ }
+ Event::type_t type() { return Event::noise; }
+
+ float gain;
+ timepos_t len;
+
+ unsigned int t;
+};
+
+class EventSample : public Event {
+public:
+ EventSample(channel_t c, float g, std::string f)
+ {
+ channel = c;
+ gain = g;
+ t = 0;
+ file = f;
+ }
+
+ Event::type_t type() { return Event::sample; }
+
+ float gain;
- bool operator<(const Event& event) const;
+ unsigned int t;
- jack_port_t *port;
- AudioFile *sample;
- size_t duration;
- size_t time;
+ std::string file;
};
-typedef std::set< Event > Events;
+
+
+class EventQueue {
+public:
+ void post(Event *event, timepos_t time);
+ Event *take(timepos_t time);
+ bool hasEvent(timepos_t time);
+ size_t size() { return queue.size(); }
+
+private:
+ std::multimap< timepos_t, Event* > queue;
+ Mutex mutex;
+};
#endif/*__DRUMGIZMO_EVENT_H__*/