void SpikeDisplayNode::writeSpike(const SpikeObject& s, int i) { packSpike(&s, spikeBuffer, MAX_SPIKE_BUFFER_LEN); int totalBytes = s.nSamples * s.nChannels * 2 + // account for samples s.nChannels * 4 + // acount for threshold and gain 15; // 15 bytes in every SpikeObject // format: // 1 byte of event type (always = 4 for spikes) // 8 bytes for 64-bit timestamp // 2 bytes for 16-bit electrode ID // 2 bytes for 16-bit number of channels (n) // 2 bytes for 16-bit number of samples (m) // 2*n*m bytes for 16-bit samples // 2*n bytes for 16-bit gains // 2*n bytes for 16-bit thresholds // const MessageManagerLock mmLock; diskWriteLock->enter(); fwrite(spikeBuffer, 1, totalBytes, electrodes[i].file); fwrite(&recordingNumber, // ptr 2, // size of each element 1, // count electrodes[i].file); // ptr to FILE object diskWriteLock->exit(); }
void OriginalRecording::writeSpike(const SpikeObject& spike, int electrodeIndex) { uint8_t spikeBuffer[MAX_SPIKE_BUFFER_LEN]; if (spikeFileArray[electrodeIndex] == nullptr) return; packSpike(&spike, spikeBuffer, MAX_SPIKE_BUFFER_LEN); int totalBytes = spike.nSamples * spike.nChannels * 2 + // account for samples spike.nChannels * 4 + // acount for gain spike.nChannels * 2 + // account for thresholds SPIKE_METADATA_SIZE; // 42, from SpikeObject.h // format: // 1 byte of event type (always = 4 for spikes) // 8 bytes for 64-bit timestamp // 2 bytes for 16-bit electrode ID // 2 bytes for 16-bit number of channels (n) // 2 bytes for 16-bit number of samples (m) // 2*n*m bytes for 16-bit samples // 2*n bytes for 16-bit gains // 2*n bytes for 16-bit thresholds // const MessageManagerLock mmLock; diskWriteLock.enter(); fwrite(spikeBuffer, 1, totalBytes, spikeFileArray[electrodeIndex]); fwrite(&recordingNumber, // ptr 2, // size of each element 1, // count spikeFileArray[electrodeIndex]); // ptr to FILE object diskWriteLock.exit(); }