Skip to content
Snippets Groups Projects
Commit be444e42 authored by jsiegle's avatar jsiegle
Browse files

Added additional protection to RecordNode when closing files

parent 4cbcc5f0
Branches
Tags
No related merge requests found
......@@ -100,11 +100,9 @@ AudioProcessorEditor* FilterNode::createEditor()
void FilterNode::updateSettings()
{
filters.clear();
// lowCuts.clear();
//highCuts.clear();
if (getNumInputs() < 100 && getNumInputs() != filters.size()) {
if (getNumInputs() < 100) {
filters.clear();
for (int n = 0; n < getNumInputs(); n++)
{
......
......@@ -31,6 +31,7 @@ RecordNode::RecordNode()
// newDataFolder = true; // defaults to creating a new data folder on startup
continuousDataBuffer = new int16[10000];
signalFilesShouldClose = false;
}
......@@ -238,14 +239,10 @@ void RecordNode::setParameter (int parameterIndex, float newValue)
if (isRecording) {
// close necessary files
for (int i = 0; i < continuousChannels.size(); i++)
{
if (continuousChannels[i].isRecording)
{
std::cout << "CLOSING FILE: " << continuousChannels[i].filename << std::endl;
fclose(continuousChannels[i].file);
}
}
signalFilesShouldClose = true;
}
isRecording = false;
......@@ -279,6 +276,19 @@ void RecordNode::setParameter (int parameterIndex, float newValue)
}
}
void RecordNode::closeAllFiles()
{
for (int i = 0; i < continuousChannels.size(); i++)
{
if (continuousChannels[i].isRecording)
{
std::cout << "CLOSING FILE: " << continuousChannels[i].filename << std::endl;
fclose(continuousChannels[i].file);
}
}
}
bool RecordNode::enable()
{
isProcessing = true;
......@@ -349,7 +359,7 @@ void RecordNode::process(AudioSampleBuffer &buffer,
//buffer.applyGain(0, nSamples, 0.5);
// cycle through events -- extract the samples per channel
// NOT YET IMPLEMENTED
// cycle through buffer channels
for (int i = 0; i < buffer.getNumChannels(); i++)
......@@ -368,6 +378,16 @@ void RecordNode::process(AudioSampleBuffer &buffer,
}
return;
}
if (signalFilesShouldClose)
{
// prevent parameter changes from closing files
// before recording stops
closeAllFiles();
signalFilesShouldClose = false;
}
}
......@@ -32,8 +32,6 @@
#include "GenericProcessor.h"
/**
--UNDER CONSTRUCTION--
Receives inputs from all processors that want to save their data.
Writes data to disk using fwrite.
......@@ -83,7 +81,7 @@ private:
/** Keep the RecordNode informed of acquisition and record states.
*/
bool isRecording, isProcessing;
bool isRecording, isProcessing, signalFilesShouldClose;
/** User-selectable directory for saving data files. Currently
defaults to the user's home directory.
......@@ -125,6 +123,8 @@ private:
FILE* file;
};
void closeAllFiles();
/** Map of continuous channels.
*/
std::map<int, Channel> continuousChannels;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment