Skip to content
Snippets Groups Projects
Commit 8da69f94 authored by Aaron Cuevas Lopez's avatar Aaron Cuevas Lopez
Browse files

Working commit

parent ddb9846d
No related branches found
No related tags found
No related merge requests found
......@@ -261,7 +261,7 @@ void EventChannel::setLength(unsigned int length)
m_length = length;
m_dataSize = length * getTypeByteSize(m_type);
//for messages, add 1 byte to account for the null terminator
if (m_type == MESSAGE) m_dataSize += 1;
if (m_type == TEXT) m_dataSize += 1;
}
unsigned int EventChannel::getLength() const
......
......@@ -154,7 +154,6 @@ private:
const uint16 m_sourceIndex;
/** Index of this particular subtype in the source processor */
const uint16 m_sourceTypeIndex;
float m_sampleRate{ 44100.0f };
};
......
......@@ -231,7 +231,7 @@ template <typename T>
void MetaDataValue::getValue(Array<T>& data) const
{
jassert(checkMetaDataType<T>(m_type));
data.addArray(m_data.getData(), m_length);
data.addArray(reinterpret_cast<const T*>(m_data.getData()), m_length);
}
//Actual template instantiations at the end of the file
......
......@@ -24,7 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef METADATA_H_INCLUDED
#define METADATA_H_INCLUDED
#include <JuceHeader.h>
#include "../../../JuceLibraryCode/JuceHeader.h"
#include "../PluginManager/OpenEphysPlugin.h"
class GenericProcessor;
......
......@@ -245,10 +245,10 @@ public:
Array<ParameterEditor*> parameterEditors;
/** Returns the Channel object for a given continuous channel number. */
Channel* getChannel (int chan);
DataChannel* getChannel (int chan);
/** Returns the Channel object for a given event channel number. */
Channel* getEventChannel (int chan);
EventChannel* getEventChannel (int chan);
/** Stores the font used to display the editor's name. */
Font titleFont;
......
......@@ -124,6 +124,28 @@ uint16 Event::getChannel() const
return m_channel;
}
bool Event::serializeHeader(EventChannel::EventChannelTypes type, char* buffer, size_t dstSize) const
{
size_t dataSize = m_channelInfo->getDataSize();
size_t eventSize = dataSize + EVENT_BASE_SIZE;
size_t totalSize = eventSize + m_channelInfo->getTotalEventMetaDataSize();
if (totalSize < dstSize)
{
jassertfalse;
return false;
}
*(buffer + 0) = PROCESSOR_EVENT;
*(buffer + 1) = static_cast<char>(type);
*(reinterpret_cast<uint16*>(buffer + 2)) = m_channelInfo->getSourceNodeID();
*(reinterpret_cast<uint16*>(buffer + 4)) = m_channelInfo->getSubProcessorIdx();
*(reinterpret_cast<uint16*>(buffer + 6)) = m_channelInfo->getSourceIndex();
*(reinterpret_cast<uint64*>(buffer + 8)) = m_timestamp;
*(reinterpret_cast<uint64*>(buffer + 16)) = m_channel;
return true;
}
//TTLEvent
TTLEvent::TTLEvent(const EventChannel* channelInfo, uint64 timestamp, uint16 channel, const void* eventData)
......@@ -150,24 +172,12 @@ const void* TTLEvent::getTTLWordPointer() const
void TTLEvent::serialize(void* dstBuffer, size_t dstSize) const
{
size_t dataSize = m_channelInfo->getDataSize();
size_t eventSize = dataSize + EVENT_BASE_SIZE;
size_t totalSize = eventSize + m_channelInfo->getTotalEventMetaDataSize();
if (totalSize < dstSize)
{
jassertfalse;
return;
}
char* buffer = static_cast<char*>(dstBuffer);
*(buffer + 0) = PROCESSOR_EVENT;
*(buffer + 1) = EventChannel::TTL;
*(reinterpret_cast<uint16*>(buffer + 2)) = m_channelInfo->getSourceNodeID();
*(reinterpret_cast<uint16*>(buffer + 4)) = m_channelInfo->getSubProcessorIdx();
*(reinterpret_cast<uint16*>(buffer + 6)) = m_channelInfo->getSourceIndex();
*(reinterpret_cast<uint64*>(buffer + 8)) = m_timestamp;
*(reinterpret_cast<uint64*>(buffer + 16)) = m_channel;
if (!serializeHeader(EventChannel::TTL, buffer, dstSize))
return;
size_t dataSize = m_channelInfo->getDataSize();
size_t eventSize = dataSize + EVENT_BASE_SIZE;
memcpy((buffer + 18), m_data.getData(), dataSize);
serializeMetaData(buffer + eventSize);
}
......@@ -226,9 +236,26 @@ TTLEvent* TTLEvent::deserializeFromMessage(const MidiMessage& msg, const EventCh
}
//TextEvent
TextEvent::TextEvent(const EventChannel* channelInfo, uint64 timestamp, uint16 channel, const String& text)
: Event(channelInfo, timestamp, channel),
m_text(text)
{
}
TextEvent(const EventChannel* channelInfo, uint64 timestamp, uint16 channel, const String& msg)
: Event(channelInfo, timestamp, channel)
String TextEvent::getText() const
{
return m_text;
}
void TextEvent::serialize(void* dstBuffer, size_t dstSize) const
{
char* buffer = static_cast<char*>(dstBuffer);
if (!serializeHeader(EventChannel::TTL, buffer, dstSize))
return;
size_t dataSize = m_channelInfo->getDataSize();
size_t eventSize = dataSize + EVENT_BASE_SIZE;
memcpy((buffer + 18), m_data.getData(), dataSize);
serializeMetaData(buffer + eventSize);
}
\ No newline at end of file
......@@ -24,8 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef EVENTS_H_INCLUDED
#define EVENTS_H_INCLUDED
#include "../../../JuceLibraryCode/JuceHeader.h"
#include "../PluginManager/OpenEphysPlugin.h"
#include <JuceHeader.h>
#include "../Channel/InfoObjects.h"
class GenericProcessor;
......@@ -92,6 +91,7 @@ public:
protected:
Event(const EventChannel* channelInfo, uint64 timestamp, uint16 channel);
Event() = delete;
bool serializeHeader(EventChannel::EventChannelTypes type, char* buffer, size_t dstSize) const;
const uint16 m_channel;
const EventChannel* m_channelInfo;
......@@ -133,9 +133,9 @@ public:
static TextEvent* deserializeFromMessage(const MidiMessage& msg, const EventChannel* channelInfo);
private:
TextEvent() = delete;
TextEvent(const EventChannel* channelInfo, uint64 timestamp, uint16 channel, const String& msg);
TextEvent(const EventChannel* channelInfo, uint64 timestamp, uint16 channel, const String& text);
const String m_msg;
const String m_text;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(TextEvent);
};
......
......@@ -37,7 +37,7 @@ enum ChannelType
//defines which events are writable to files
#define isWritableEvent(ev) (((int)(ev) == GenericProcessor::TTL) || ((int)(ev) == GenericProcessor::MESSAGE) || ((int)(ev) == GenericProcessor::BINARY_MSG))
#include "../../../JuceLibraryCode/JuceHeader.h"
#include <JuceHeader.h>
#include "../Editors/GenericEditor.h"
#include "../Parameter/Parameter.h"
#include "../../CoreServices.h"
......@@ -255,7 +255,7 @@ public:
virtual float getDefaultBitVolts() const;
/** Returns the bit volts for a given channel **/
virtual float getBitVolts (Channel* chan) const;
virtual float getBitVolts (DataChannel* chan) const;
/** Returns the next available channel (and increments the channel if the input is set to 'true'. */
virtual int getNextChannel (bool t);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment