Permalink
Browse files

Add 'allFilesOpened' check to make sure recording doesn't start until…

… all files have been opened
  • Loading branch information...
1 parent eb916d5 commit 4ea79bfac5524d2601cb9877f380d017452723fd jsiegle committed Feb 4, 2014
Showing with 10 additions and 1 deletion.
  1. +9 −1 Source/Processors/RecordNode.cpp
  2. +1 −0 Source/Processors/RecordNode.h
@@ -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
@@ -122,6 +122,7 @@ class RecordNode : public GenericProcessor,
bool newDirectoryNeeded;
bool isRecording;
+ bool allFilesOpened;
/** Generate a Matlab-compatible datestring */
String generateDateString();

0 comments on commit 4ea79bf

Please sign in to comment.