[SCM] calf/master: + LV2: changed lv2_event structure so that it cannot be constructed (to prevent accidental stack overwrites) + Small modules: added MIDI transpose plugin
js at users.alioth.debian.org
js at users.alioth.debian.org
Tue May 7 15:37:44 UTC 2013
The following commit has been merged in the master branch:
commit d584eeeee8e4566108e0392c3f975059452899c1
Author: kfoltman <kfoltman at 78b06b96-2940-0410-b7fc-879d825d01d8>
Date: Fri Oct 10 21:49:10 2008 +0000
+ LV2: changed lv2_event structure so that it cannot be constructed (to prevent accidental stack overwrites)
+ Small modules: added MIDI transpose plugin
git-svn-id: https://calf.svn.sourceforge.net/svnroot/calf/trunk@329 78b06b96-2940-0410-b7fc-879d825d01d8
diff --git a/src/calf/lv2helpers.h b/src/calf/lv2helpers.h
index deae345..fe911eb 100644
--- a/src/calf/lv2helpers.h
+++ b/src/calf/lv2helpers.h
@@ -67,7 +67,7 @@ public:
/// LV2 event structure + payload as 0-length array for easy access
struct lv2_event: public LV2_Event
{
- uint8_t data[0];
+ uint8_t data[];
inline lv2_event &operator=(const lv2_event &src) {
*(LV2_Event *)this = (const LV2_Event &)src;
memcpy(data, src.data, src.size);
@@ -77,6 +77,11 @@ struct lv2_event: public LV2_Event
inline uint64_t timestamp() const {
return ((uint64_t)frames << 32) | subframes;
}
+private:
+ /// forbid default constructor - this object cannot be constructed, only obtained via cast from LV2_Event* (or &) to lv2_event* (or &)
+ lv2_event() {}
+ /// forbid copy constructor - see default constructor
+ lv2_event(const lv2_event &) {}
};
/// A read-only iterator-like object for reading from event buffers
diff --git a/src/calf/modulelist.h b/src/calf/modulelist.h
index 128b917..2eb48be 100644
--- a/src/calf/modulelist.h
+++ b/src/calf/modulelist.h
@@ -47,6 +47,7 @@
PER_SMALL_MODULE_ITEM(pitchbendfilter_m, "pitchbendfilter_m")
PER_SMALL_MODULE_ITEM(systemfilter_m, "systemfilter_m")
PER_SMALL_MODULE_ITEM(channelfilter_m, "channelfilter_m")
+ PER_SMALL_MODULE_ITEM(transpose_m, "transpose_m")
PER_SMALL_MODULE_ITEM(eventmerge_e, "eventmerge_e")
PER_SMALL_MODULE_ITEM(quadpower_a, "quadpower_a")
PER_SMALL_MODULE_ITEM(quadpower_c, "quadpower_c")
diff --git a/src/modules_small.cpp b/src/modules_small.cpp
index ce48011..b093f2d 100644
--- a/src/modules_small.cpp
+++ b/src/modules_small.cpp
@@ -1398,6 +1398,42 @@ public:
static inline const char **strings() { static const char *s[] = { "channelfilter_m", "Channel Filter", "range", "Range" }; return s;}
};
+class transpose_m_audio_module: public midi_mixin<small_audio_module_base<2, 1> >
+{
+public:
+ static void plugin_info(plugin_info_iface *pii)
+ {
+ pii->names("transpose_em", "Transpose", "kf:MIDIPlugin");
+ pii->event_port("in", "In").input();
+ pii->control_port("transpose", "Transpose", 12).input().integer();
+ pii->event_port("out", "Out").output();
+ }
+ void process(uint32_t)
+ {
+ event_port_read_iterator ri((LV2_Event_Buffer *)ins[0]);
+ event_port_write_iterator wi((LV2_Event_Buffer *)outs[0]);
+ while(ri)
+ {
+ const lv2_event &event = *ri++;
+ if (event.type == this->midi_event_type && event.size == 3 && (event.data[0] >= 0x80 && event.data[0] <= 0x9F))
+ {
+ int new_note = event.data[1] + (int)*ins[1];
+ // ignore out-of-range notes
+ if (new_note >= 0 && new_note <= 127)
+ {
+ // it is not possible to create copies here because they are variable length and would "nicely" overwrite the stack
+ // so write the original event instead, and then modify the pitch
+ *wi = event;
+ wi->data[1] = new_note;
+ wi++;
+ }
+ }
+ else
+ *wi++ = event;
+ }
+ }
+};
+
class eventmerge_e_audio_module: public event_mixin<small_audio_module_base<2, 1> >
{
public:
--
calf audio plugins packaging
More information about the pkg-multimedia-commits
mailing list