diff --git a/Source/Processors/RecordEngine.h b/Source/Processors/RecordEngine.h index 3ee7c1476..4aa8a2412 100644 --- a/Source/Processors/RecordEngine.h +++ b/Source/Processors/RecordEngine.h @@ -45,24 +45,92 @@ class RecordEngine : public AccessClass public: RecordEngine(); ~RecordEngine(); - + /** All the public methods are called by RecordNode: + When acquisition starts (in the specified order): + 1-resetChannels + 2-registerProcessor, addChannel, registerSpikeSource, addspikeelectrode + 3-startAcquisition + When recording starts (in the specified order): + 1-directoryChanged (if needed) + 2-openFiles + During recording: + writeData, writeEvent, writeSpike, updateTimeStamp + When recording stops: + closeFiles + */ + + /** Called when recording starts to open all needed files + */ virtual void openFiles(File rootFolder, int experimentNumber, int recordingNumber) =0; + + /** Called when recording stops to close all files + and do all the necessary cleanups + */ virtual void closeFiles() =0; + + /** Write continuous data. + This method gets the full data buffer, it must query getRecordState for + each registered channel to determine which channels to actually write to disk + */ virtual void writeData(AudioSampleBuffer& buffer, int nSamples) =0; + + /** Write a single event to disk. + */ virtual void writeEvent(int eventType, MidiMessage& event, int samplePosition) =0; - virtual void addChannel(int index, Channel* chan) =0; + + /** Called when acquisition starts once for each processor that might record continuous data + */ + virtual void registerProcessor(GenericProcessor* processor); + + /** Called after registerProcessor, once for each output + channel of the processor + */ + virtual void addChannel(int index, Channel* chan) =0; + + /** Called when acquisition starts once for each processor that might record spikes + */ + virtual void registerSpikeSource(GenericProcessor* processor); + + /** Called after registerSpikesource, once for each channel group + */ virtual void addSpikeElectrode(int index, SpikeRecordInfo* elec) =0; + + /** Write a spike to disk + */ virtual void writeSpike(const SpikeObject& spike, int electrodeIndex) =0; - virtual void registerProcessor(GenericProcessor* processor); - virtual void registerSpikeSource(GenericProcessor* processor); + + /** Called when a new acquisition starts, to clean all channel data + before registering the processors + */ virtual void resetChannels(); + + /** Called every time a new timestamp event is received + */ virtual void updateTimeStamp(int64 timestamp); + + /** Called after all channels and spike groups have been registered, + just before acquisition starts + */ virtual void startAcquisition(); + + /** Called when the recording directory changes during an acquisition + */ virtual void directoryChanged(); protected: + /** Functions to access RecordNode arrays and utilities + */ + + /** Gets the specified channel from the channel array stored in RecordNode + */ Channel* getChannel(int index); + + /** Gets the specified channel group info structure from the array stored in RecordNode + */ SpikeRecordInfo* getSpikeElectrode(int index); + + /** Generate a Matlab-compatible datestring + */ String generateDateString(); private: diff --git a/Source/Processors/RecordNode.h b/Source/Processors/RecordNode.h index f78fedef2..b1efc776e 100755 --- a/Source/Processors/RecordNode.h +++ b/Source/Processors/RecordNode.h @@ -72,12 +72,18 @@ class RecordNode : public GenericProcessor, */ void setParameter(int parameterIndex, float newValue); + /** Called by the processor graph for each processor that could record data + */ void registerProcessor(GenericProcessor* sourceNode); + /** Called by the processor graph for each recordable channel + */ void addInputChannel(GenericProcessor* sourceNode, int chan); bool enable(); bool disable(); + /** Get channel stored in channelPointers array + */ Channel* getDataChannel(int index); /** Called by the ControlPanel to determine the amount of space @@ -113,14 +119,26 @@ class RecordNode : public GenericProcessor, return rootFolder; } + /** Adds a Record Engine to use + */ void registerRecordEngine(RecordEngine* engine); + /** Clears the list of active Record Engines + */ void clearRecordEngines(); + /** Must be called by a spike recording source on the "enable" method + */ void registerSpikeSource(GenericProcessor* processor); + /** Registers an electrode group for spike recording + Must be called by a spike recording source on the "enable" method + after the call to registerSpikeSource + */ int addSpikeElectrode(SpikeRecordInfo* elec); + /** Called by a spike recording source to write a spike to file + */ void writeSpike(SpikeObject& spike, int electrodeIndex); SpikeRecordInfo* getSpikeElectrode(int index);