diff --git a/Source/Processors/Channel/InfoObjects.cpp b/Source/Processors/Channel/InfoObjects.cpp index 0d3beae8e0ee976d2fd6c0c4ddc31bcb7104c35f..05e77fa60b5b0a7b82d8247229b8290c73425b0c 100644 --- a/Source/Processors/Channel/InfoObjects.cpp +++ b/Source/Processors/Channel/InfoObjects.cpp @@ -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 diff --git a/Source/Processors/Channel/InfoObjects.h b/Source/Processors/Channel/InfoObjects.h index cc2ea71544f290f0065dd265f14bc0772bede7b0..b4f782f4ae807405ab8e1eb32545f5c680ae248f 100644 --- a/Source/Processors/Channel/InfoObjects.h +++ b/Source/Processors/Channel/InfoObjects.h @@ -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 }; }; diff --git a/Source/Processors/Channel/MetaData.cpp b/Source/Processors/Channel/MetaData.cpp index c5b8726963af74c41be5866670a3bc3efd20e6fa..d07a050f928b70f6d750f52e9517083cea00ee9d 100644 --- a/Source/Processors/Channel/MetaData.cpp +++ b/Source/Processors/Channel/MetaData.cpp @@ -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 diff --git a/Source/Processors/Channel/MetaData.h b/Source/Processors/Channel/MetaData.h index 379c51a0e43c80a71421aa1d2c8f11c520f6502a..7d732932ea9bf52128071c8e38d413b5074f2fb6 100644 --- a/Source/Processors/Channel/MetaData.h +++ b/Source/Processors/Channel/MetaData.h @@ -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; diff --git a/Source/Processors/Editors/GenericEditor.h b/Source/Processors/Editors/GenericEditor.h index 0a877f7ddd94ad3c21f8999a01235598c9b8d229..c023b3c7161cd7a8a844d886481783efc06aa82c 100755 --- a/Source/Processors/Editors/GenericEditor.h +++ b/Source/Processors/Editors/GenericEditor.h @@ -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; diff --git a/Source/Processors/Events/Events.cpp b/Source/Processors/Events/Events.cpp index 9736213db3736a35fc6b61a6e1a2c84d968f8446..b2d6f473013f3953b0a2deda426c8dd7efcd4eee 100644 --- a/Source/Processors/Events/Events.cpp +++ b/Source/Processors/Events/Events.cpp @@ -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 diff --git a/Source/Processors/Events/Events.h b/Source/Processors/Events/Events.h index ec289e1d6c394b03609a3b9d73c1363014fe2a30..3472d2c97ebe95a62002e910e4538448ab42a988 100644 --- a/Source/Processors/Events/Events.h +++ b/Source/Processors/Events/Events.h @@ -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); }; diff --git a/Source/Processors/GenericProcessor/GenericProcessor.h b/Source/Processors/GenericProcessor/GenericProcessor.h index 3f5d96ce088aa1fe0940d2c2e6cca66a09a062d8..3086eee3c1f5cabc719739259a9e11200f9df0a9 100755 --- a/Source/Processors/GenericProcessor/GenericProcessor.h +++ b/Source/Processors/GenericProcessor/GenericProcessor.h @@ -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);