Skip to content

Commit 98c58d4

Browse files
authored
Merge pull request #333 from wagenadl/master
Trivial bugfix to PluginGenerator: incorrect pathname for include fixed
2 parents a35fef5 + 66b96fe commit 98c58d4

7 files changed

Lines changed: 241 additions & 294 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ PluginGenerator/Builds/VisualStudio2013/*.user
3333
PluginGenerator/Builds/VisualStudio2013/*.sdf
3434
PluginGenerator/Builds/VisualStudio2013/*.opensdf
3535
PluginGenerator/Builds/VisualStudio2013/*.suo
36+
PluginGenerator/Builds/LinuxMakefile/build
3637
Projucer/**/build
3738

3839
# 3. extra files

PluginGenerator/Builds/LinuxMakefile/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ ifeq ($(CONFIG),Debug)
1818
TARGET_ARCH := -march=native
1919
endif
2020

21-
CPPFLAGS := $(DEPFLAGS) -D "LINUX=1" -D "DEBUG=1" -D "_DEBUG=1" -D "JUCER_LINUX_MAKE_6D53C8B4=1" -D "JUCE_APP_VERSION=4.2.1" -D "JUCE_APP_VERSION_HEX=0x40201" -I /usr/include -I /usr/include/freetype2 -I ../../JuceLibraryCode -I ../../../JuceLibraryCode/modules -I JuceLibraryCode/
21+
CPPFLAGS := $(DEPFLAGS) -D "LINUX=1" -D "DEBUG=1" -D"JUCE_DISABLE_NATIVE_FILECHOOSERS=1" -D "_DEBUG=1" -D "JUCER_LINUX_MAKE_6D53C8B4=1" -D "JUCE_APP_VERSION=4.2.1" -D "JUCE_APP_VERSION_HEX=0x40201" -I /usr/include -I /usr/include/freetype2 -I ../../JuceLibraryCode -I ../../../JuceLibraryCode/modules -I JuceLibraryCode/
2222
CFLAGS += $(CPPFLAGS) $(TARGET_ARCH) -g -ggdb -O0 -std=c++11
2323
CXXFLAGS += $(CFLAGS) -std=c++11
2424
LDFLAGS += $(TARGET_ARCH) -L$(BINDIR) -L$(LIBDIR) -L/usr/X11R6/lib/ -lX11 -lXext -lXinerama -ldl -lfreetype -lpthread -lrt -lcurl

PluginGenerator/Source/Wizards/openEphys_PluginTemplatesPageComponent.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include "openEphys_EditorTemplatesFactory.h"
2626
#include "openEphys_EditorTemplateComponent.h"
2727

28-
#include "../../../Source/Plugins/Headers/AllLookAndFeels.h"
28+
#include "../../../Plugins/Headers/AllLookAndFeels.h"
2929
#include "../../../Source/UI/Utils/LinearButtonGroupManager.h"
3030
#include "../../../Source/UI/Utils/TiledButtonGroupManager.h"
3131

Plugins/LfpDisplayNodeBeta/LfpDisplayCanvas.cpp

Lines changed: 126 additions & 126 deletions
Large diffs are not rendered by default.

Plugins/LfpDisplayNodeBeta/LfpDisplayNode.cpp

Lines changed: 100 additions & 162 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,13 @@ using namespace LfpDisplayNodeBeta;
3131
LfpDisplayNode::LfpDisplayNode()
3232
: GenericProcessor ("LFP Viewer Beta")
3333
, displayGain (1)
34-
, bufferLength (20.0f)
34+
, bufferLength (20.0f) // seconds
3535
, abstractFifo (100)
3636
{
3737
setProcessorType (PROCESSOR_TYPE_SINK);
3838

39-
displayBuffer = new AudioSampleBuffer (8, 100);
39+
displayBuffer = new AudioSampleBuffer (8, 100); // channels, samples
40+
// (Size is later changed by resizeBuffer() to [bufferLength = 20] seconds.)
4041

4142
const int heapSize = 5000;
4243
arrayOfOnes = new float[heapSize];
@@ -68,15 +69,15 @@ void LfpDisplayNode::updateSettings()
6869
eventSourceNodes.clear();
6970
ttlState.clear();
7071

71-
for (int i = 0; i < eventChannelArray.size(); ++i)
72-
{
73-
uint32 sourceID = getChannelSourceID(eventChannelArray[i]);
74-
if (!eventSourceNodes.contains(sourceID))
75-
{
76-
eventSourceNodes.add(sourceID);
72+
for (int i = 0; i < eventChannelArray.size(); ++i)
73+
{
74+
uint32 sourceID = getChannelSourceID(eventChannelArray[i]);
75+
if (!eventSourceNodes.contains(sourceID))
76+
{
77+
eventSourceNodes.add(sourceID);
7778

78-
}
79-
}
79+
}
80+
}
8081

8182
numEventChannels = eventSourceNodes.size();
8283

@@ -96,7 +97,7 @@ void LfpDisplayNode::updateSettings()
9697

9798
uint32 LfpDisplayNode::getChannelSourceID(const EventChannel* event) const
9899
{
99-
return getProcessorFullId(event->getTimestampOriginProcessor(), event->getTimestampOriginSubProcessor());
100+
return getProcessorFullId(event->getTimestampOriginProcessor(), event->getTimestampOriginSubProcessor());
100101
}
101102

102103
bool LfpDisplayNode::resizeBuffer()
@@ -110,6 +111,9 @@ bool LfpDisplayNode::resizeBuffer()
110111
{
111112
abstractFifo.setTotalSize (nSamples);
112113
displayBuffer->setSize (nInputs + numEventChannels, nSamples); // add extra channels for TTLs
114+
displayBuffer->clear();
115+
//displayBufferIndex.clear();
116+
//displayBufferIndex.insertMultiple(0, 0, nInputs + numEventChannels);
113117

114118
return true;
115119
}
@@ -139,6 +143,7 @@ bool LfpDisplayNode::disable()
139143
{
140144
LfpDisplayEditor* editor = (LfpDisplayEditor*) getEditor();
141145
editor->disable();
146+
eventValueChanges.clear();
142147
return true;
143148
}
144149

@@ -157,170 +162,103 @@ void LfpDisplayNode::setParameter (int parameterIndex, float newValue)
157162
ed->canvas->setParameter (parameterIndex, newValue);
158163
}
159164

160-
161-
void LfpDisplayNode::handleEvent(const EventChannel* eventInfo, const MidiMessage& event, int samplePosition)
162-
{
163-
if (Event::getEventType(event) == EventChannel::TTL)
164-
{
165-
TTLEventPtr ttl = TTLEvent::deserializeFromMessage(event, eventInfo);
166-
167-
//int eventNodeId = *(dataptr+1);
168-
const int eventId = ttl->getState() ? 1 : 0;
169-
const int eventChannel = ttl->getChannel();
170-
const int eventTime = samplePosition;
171-
const uint32 eventSourceNodeId = getChannelSourceID(eventInfo);
172-
const int nSamples = getNumSourceSamples(eventSourceNodeId);
173-
int samplesToFill = nSamples - eventTime;
174-
if (samplesToFill < 0) samplesToFill = 0;
175-
176-
// std::cout << "Received event from " << eventSourceNode << ", channel "
177-
// << eventChannel << ", with ID " << eventId << ", copying to "
178-
// << channelForEventSource[eventSourceNode] << std::endl;
179-
////
180-
int bufferIndex = (displayBufferIndex[channelForEventSource[eventSourceNodeId]] + eventTime - nSamples)
181-
% displayBuffer->getNumSamples();
182-
183-
bufferIndex = bufferIndex >= 0
184-
? bufferIndex
185-
: displayBuffer->getNumSamples() + bufferIndex;
186-
187-
if (eventId == 1)
188-
{
189-
ttlState[eventSourceNodeId] |= (1L << eventChannel);
190-
}
191-
else
192-
{
193-
ttlState[eventSourceNodeId] &= ~(1L << eventChannel);
194-
}
195-
196-
if (samplesToFill + bufferIndex < displayBuffer->getNumSamples())
197-
{
198-
//std::cout << bufferIndex << " " << samplesToFill << " " << ttlState[eventSourceNode] << std::endl;
199-
200-
displayBuffer->copyFrom (channelForEventSource[eventSourceNodeId], // destChannel
201-
bufferIndex, // destStartSample
202-
arrayOfOnes, // source
203-
samplesToFill, // numSamples
204-
float (ttlState[eventSourceNodeId])); // gain
205-
}
206-
else
207-
{
208-
const int block2Size = (samplesToFill + bufferIndex) % displayBuffer->getNumSamples();
209-
const int block1Size = samplesToFill - block2Size;
210-
211-
displayBuffer->copyFrom (channelForEventSource[eventSourceNodeId], // destChannel
212-
bufferIndex, // destStartSample
213-
arrayOfOnes, // source
214-
block1Size, // numSamples
215-
float (ttlState[eventSourceNodeId])); // gain
216-
217-
displayBuffer->copyFrom (channelForEventSource[eventSourceNodeId], // destChannel
218-
0, // destStartSample
219-
arrayOfOnes, // source
220-
block2Size, // numSamples
221-
float (ttlState[eventSourceNodeId])); // gain
222-
}
223-
224-
// std::cout << "Received event from " << eventNodeId
225-
// << " on channel " << eventChannel
226-
// << " with value " << eventId
227-
// << " at timestamp " << event.getTimeStamp() << std::endl;
228-
}
165+
std::list<int> LfpDisplayNode::eventStateChannels() const {
166+
std::list<int> cc;
167+
for (uint32 id: eventSourceNodes)
168+
cc.push_back(channelForEventSource.find(id)->second);
169+
return cc;
170+
}
171+
172+
void LfpDisplayNode::handleEvent(const EventChannel* eventInfo,
173+
const MidiMessage& event, int samplePosition) {
174+
if (Event::getEventType(event) == EventChannel::TTL) {
175+
TTLEventPtr ttl = TTLEvent::deserializeFromMessage(event, eventInfo);
176+
const int eventChannel = ttl->getChannel();
177+
const int eventTime = samplePosition;
178+
const uint32 eventSourceNodeId = getChannelSourceID(eventInfo);
179+
int val = 1<<eventChannel;
180+
if (!ttl->getState())
181+
val = -val;
182+
eventValueChanges[eventSourceNodeId].push_back(EventValueChange(eventTime, val));
183+
}
229184
}
230185

186+
void LfpDisplayNode::initializeEventChannels() {
187+
for (int i=0; i<eventSourceNodes.size(); i++) {
188+
uint32 src = eventSourceNodes[i];
189+
eventValueChanges[src] = std::list<EventValueChange>();
190+
}
191+
}
231192

232-
void LfpDisplayNode::initializeEventChannels()
233-
{
234-
for (int i = 0; i < eventSourceNodes.size(); ++i)
235-
{
236-
const int chan = channelForEventSource[eventSourceNodes[i]];
237-
const int index = displayBufferIndex[chan];
238-
const int samplesLeft = displayBuffer->getNumSamples() - index;
239-
const int nSamples = getNumSourceSamples(eventSourceNodes[i]);
240-
241-
//std::cout << "Event source node " << i << ", channel " << chan << std::endl;
242-
243-
if (nSamples < samplesLeft)
244-
{
245-
// std::cout << getNumInputs()+1 << " " << displayBufferIndex << " " << totalSamples << " " << ttlState << std::endl;
246-
247-
displayBuffer->copyFrom (chan, // destChannel
248-
index, // destStartSample
249-
arrayOfOnes, // source
250-
nSamples, // numSamples
251-
float (ttlState[eventSourceNodes[i]])); // gain
252-
253-
displayBufferIndex.set (chan, index + nSamples);
254-
}
255-
else
256-
{
257-
int extraSamples = nSamples - samplesLeft;
258-
259-
displayBuffer->copyFrom (chan, // destChannel
260-
index, // destStartSample
261-
arrayOfOnes, // source
262-
samplesLeft, // numSamples
263-
float (ttlState[eventSourceNodes[i]])); // gain
264-
265-
displayBuffer->copyFrom (chan, // destChannel
266-
0, // destStartSample
267-
arrayOfOnes, // source
268-
extraSamples, // numSamples
269-
float (ttlState[eventSourceNodes[i]])); // gain
193+
void LfpDisplayNode::copyToEventChannel(uint32 src,
194+
int t0,
195+
int t1,
196+
float value) {
197+
int dispBufSamps = displayBuffer->getNumSamples();
198+
int chan = channelForEventSource[src];
199+
int destStart = t0 + displayBufferIndex[chan];
200+
int n = t1 - t0;
201+
while (destStart + n >= dispBufSamps) {
202+
int m = dispBufSamps - destStart;
203+
displayBuffer->copyFrom(chan, destStart, arrayOfOnes, m, value);
204+
n -= m;
205+
destStart = 0;
206+
}
207+
if (n>0)
208+
displayBuffer->copyFrom(chan, destStart, arrayOfOnes, n, value);
209+
}
270210

271-
displayBufferIndex.set (chan, extraSamples);
272-
}
211+
void LfpDisplayNode::finalizeEventChannels() {
212+
for (int i=0; i<eventSourceNodes.size(); ++i) {
213+
uint32 src = eventSourceNodes[i];
214+
int chan = channelForEventSource[src];
215+
int index = displayBufferIndex[chan];
216+
int nSamples = getNumSourceSamples(src);
217+
int t0 = 0;
218+
for (EventValueChange const &evc: eventValueChanges[src]) {
219+
int t1 = evc.eventTime;
220+
copyToEventChannel(src, t0, t1, ttlState[src]);
221+
if (evc.eventVal>0)
222+
ttlState[src] |= evc.eventVal;
223+
else
224+
ttlState[src] &= ~evc.eventVal;
225+
t0 = t1;
273226
}
227+
copyToEventChannel(src, t0, nSamples, ttlState[src]);
228+
displayBufferIndex.set(chan, (index + nSamples)
229+
% displayBuffer->getNumSamples());
230+
}
274231
}
275232

233+
void LfpDisplayNode::copyDataToDisplay(int chan, AudioSampleBuffer &srcbuf) {
234+
int n = getNumSamples(chan);
235+
int idx = displayBufferIndex[chan];
236+
int buflen = displayBuffer->getNumSamples();
237+
int t0 = 0;
238+
while (idx + n >= buflen) {
239+
int m = buflen - idx;
240+
displayBuffer->copyFrom(chan, idx, srcbuf, chan, t0, m);
241+
t0 += m;
242+
n -= m;
243+
idx = 0;
244+
}
245+
if (n>0) {
246+
displayBuffer->copyFrom(chan, idx, srcbuf, chan, t0, n);
247+
idx += n;
248+
}
249+
displayBufferIndex.set(chan, idx);
250+
}
276251

277252
void LfpDisplayNode::process (AudioSampleBuffer& buffer)
278253
{
279254
// 1. place any new samples into the displayBuffer
280255
//std::cout << "Display node sample count: " << nSamples << std::endl; ///buffer.getNumSamples() << std::endl;
281256

282257
initializeEventChannels();
283-
284-
checkForEvents (); // see if we got any TTL events
285-
286-
ScopedLock displayLock (displayMutex);
287-
288-
for (int chan = 0; chan < buffer.getNumChannels(); ++chan)
289-
{
290-
const int samplesLeft = displayBuffer->getNumSamples() - displayBufferIndex[chan];
291-
const int nSamples = getNumSamples (chan);
292-
293-
if (nSamples < samplesLeft)
294-
{
295-
displayBuffer->copyFrom (chan, // destChannel
296-
displayBufferIndex[chan], // destStartSample
297-
buffer, // source
298-
chan, // source channel
299-
0, // source start sample
300-
nSamples); // numSamples
301-
302-
displayBufferIndex.set (chan, displayBufferIndex[chan] + nSamples);
303-
}
304-
else
305-
{
306-
const int extraSamples = nSamples - samplesLeft;
307-
308-
displayBuffer->copyFrom (chan, // destChannel
309-
displayBufferIndex[chan], // destStartSample
310-
buffer, // source
311-
chan, // source channel
312-
0, // source start sample
313-
samplesLeft); // numSamples
314-
315-
displayBuffer->copyFrom (chan, // destChannel
316-
0, // destStartSample
317-
buffer, // source
318-
chan, // source channel
319-
samplesLeft, // source start sample
320-
extraSamples); // numSamples
321-
322-
displayBufferIndex.set (chan, extraSamples);
323-
}
324-
}
258+
checkForEvents(); // see if we got any TTL events
259+
ScopedLock displayLock(displayMutex);
260+
finalizeEventChannels();
261+
for (int chan = 0; chan < buffer.getNumChannels(); ++chan)
262+
copyDataToDisplay(chan, buffer);
325263
}
326264

Plugins/LfpDisplayNodeBeta/LfpDisplayNode.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
#include <ProcessorHeaders.h>
2828
#include "LfpDisplayEditor.h"
29-
29+
#include <list>
3030

3131
class DataViewport;
3232

@@ -66,16 +66,24 @@ class LfpDisplayNode : public GenericProcessor
6666
int getDisplayBufferIndex (int chan) const { return displayBufferIndex[chan]; }
6767

6868
CriticalSection* getMutex() { return &displayMutex; }
69-
69+
std::list<int> eventStateChannels() const;
7070

7171
private:
7272
void initializeEventChannels();
73-
73+
void finalizeEventChannels();
74+
void copyToEventChannel(uint32 src, int t0, int t1, float value);
75+
void copyDataToDisplay(int chan, AudioSampleBuffer &srcbuf);
7476
ScopedPointer<AudioSampleBuffer> displayBuffer;
7577

7678
Array<int> displayBufferIndex;
7779
Array<uint32> eventSourceNodes;
7880
std::map<uint32, int> channelForEventSource;
81+
struct EventValueChange {
82+
int eventTime;
83+
int eventVal; // positive to set, negative to clear
84+
EventValueChange(int t=0, int v=0): eventTime(t), eventVal(v) { }
85+
};
86+
std::map<uint32, std::list<EventValueChange>> eventValueChanges;
7987

8088
int numEventChannels;
8189

Source/Doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ WARN_LOGFILE =
655655
# directories like "/usr/src/myproject". Separate the files or directories
656656
# with spaces.
657657

658-
INPUT =
658+
INPUT = ../Source
659659

660660
# This tag can be used to specify the character encoding of the source files
661661
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is

0 commit comments

Comments
 (0)