diff --git a/Source/Processors/RecordNode.cpp b/Source/Processors/RecordNode.cpp index a8ee52c836c81eead48cba275fdba4ab1b02cce3..ed48582ba14975e11416941a5a90a59786020737 100755 --- a/Source/Processors/RecordNode.cpp +++ b/Source/Processors/RecordNode.cpp @@ -36,6 +36,7 @@ RecordNode::RecordNode() isProcessing = false; isRecording = false; + allFilesOpened = false; blockIndex = 0; signalFilesShouldClose = false; @@ -383,6 +384,8 @@ void RecordNode::setParameter(int parameterIndex, float newValue) } } + allFilesOpened = true; + } else if (parameterIndex == 0) { @@ -470,10 +473,13 @@ void RecordNode::openFile(Channel* ch) //std::cout << header << std::endl; std::cout << "File ID: " << chFile << ", number of bytes: " << header.getNumBytesAsUTF8() << std::endl; + fwrite(header.toUTF8(), 1, header.getNumBytesAsUTF8(), chFile); std::cout << "Wrote header." << std::endl; + std::cout << "Block index: " << blockIndex << std::endl; + } else { @@ -583,6 +589,8 @@ void RecordNode::closeAllFiles() closeFile(eventChannel); blockIndex = 0; // back to the beginning of the block + + allFilesOpened = false; } bool RecordNode::enable() @@ -769,7 +777,7 @@ void RecordNode::process(AudioSampleBuffer& buffer, // CONSTRAINTS: // samplesWritten must equal nSamples by the end of the process() method - if (isRecording) + if (isRecording && allFilesOpened) { // FIRST: cycle through events -- extract the TTLs and the timestamps diff --git a/Source/Processors/RecordNode.h b/Source/Processors/RecordNode.h index b0c4eafacc9c2ebc9cb213dc89489533eba330b8..8c8f58a67d76a32b77c2a4f286275058f66ea86a 100755 --- a/Source/Processors/RecordNode.h +++ b/Source/Processors/RecordNode.h @@ -122,6 +122,7 @@ public: bool newDirectoryNeeded; bool isRecording; + bool allFilesOpened; /** Generate a Matlab-compatible datestring */ String generateDateString();