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

RecordNode now handles opening and closing of files for continuous data.

Whenever files are needed for recording, the RecordNode opens them. When
they are no longer necessary (either recording has stopped, or recording
of a particular channel has stopped), the RecordNode closes them.
parent 8b9ddaf9
No related branches found
No related tags found
No related merge requests found
...@@ -13,3 +13,4 @@ JuceLibraryCode/jucer/Builds/Linux/build ...@@ -13,3 +13,4 @@ JuceLibraryCode/jucer/Builds/Linux/build
Builds/Linux/build/data Builds/Linux/build/data
Builds/Linux/build/savedState.xml Builds/Linux/build/savedState.xml
Builds/Linux/build/windowState.xml Builds/Linux/build/windowState.xml
Builds/Linux/build/Data
...@@ -30,11 +30,6 @@ RecordNode::RecordNode() ...@@ -30,11 +30,6 @@ RecordNode::RecordNode()
dataFolder = "./Data"; dataFolder = "./Data";
// need to update this:
setPlayConfigDetails(2,0,44100.0,128);
} }
...@@ -85,7 +80,16 @@ void RecordNode::addInputChannel(GenericProcessor* sourceNode, int chan) ...@@ -85,7 +80,16 @@ void RecordNode::addInputChannel(GenericProcessor* sourceNode, int chan)
newChannel.chan = chan; newChannel.chan = chan;
newChannel.name = sourceNode->getOutputChannelName(chan); newChannel.name = sourceNode->getOutputChannelName(chan);
newChannel.isRecording = sourceNode->recordStatus(chan); newChannel.isRecording = sourceNode->recordStatus(chan);
newChannel.file = 0;
String filename = dataFolder;
filename += "/";
filename += newChannel.nodeId;
filename += "_";
filename += newChannel.name;
filename += ".continuous";
newChannel.filename = filename;
newChannel.file = 0;
if (newChannel.isRecording) if (newChannel.isRecording)
std::cout << " This channel will be recorded." << std::endl; std::cout << " This channel will be recorded." << std::endl;
...@@ -136,11 +140,37 @@ void RecordNode::addInputChannel(GenericProcessor* sourceNode, int chan) ...@@ -136,11 +140,37 @@ void RecordNode::addInputChannel(GenericProcessor* sourceNode, int chan)
void RecordNode::setParameter (int parameterIndex, float newValue) void RecordNode::setParameter (int parameterIndex, float newValue)
{ {
if (parameterIndex == 1) { if (parameterIndex == 1) {
isRecording = true; isRecording = true;
// create necessary files std::cout << "START RECORDING." << std::endl;
// create / open necessary files
for (int i = 0; i < continuousChannels.size(); i++)
{
if (continuousChannels[i].isRecording)
{
std::cout << "OPENING FILE: " << continuousChannels[i].filename << std::endl;
continuousChannels[i].file = fopen(continuousChannels[i].filename.toUTF8(), "a");
}
}
} else if (parameterIndex == 0) { } else if (parameterIndex == 0) {
isRecording = false; isRecording = false;
std::cout << "STOP RECORDING." << std::endl;
// 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);
}
}
// close necessary files // close necessary files
} else if (parameterIndex == 2) { } else if (parameterIndex == 2) {
...@@ -148,26 +178,30 @@ void RecordNode::setParameter (int parameterIndex, float newValue) ...@@ -148,26 +178,30 @@ void RecordNode::setParameter (int parameterIndex, float newValue)
std::cout << "Toggling channel " << currentChannel << std::endl; std::cout << "Toggling channel " << currentChannel << std::endl;
if (newValue == 0.0f) if (newValue == 0.0f) {
continuousChannels[currentChannel].isRecording = false; continuousChannels[currentChannel].isRecording = false;
else
if (isRecording) {
std::cout << "CLOSING FILE: " << continuousChannels[currentChannel].filename << std::endl;
fclose(continuousChannels[currentChannel].file);
}
}
else {
continuousChannels[currentChannel].isRecording = true; continuousChannels[currentChannel].isRecording = true;
if (isRecording) {
std::cout << "OPENING FILE: " << continuousChannels[currentChannel].filename << std::endl;
continuousChannels[currentChannel].file =
fopen(continuousChannels[currentChannel].filename.toUTF8(), "a");
}
}
} }
} }
} }
bool RecordNode::enable() bool RecordNode::enable()
{ {
// figure out the folder structure
isProcessing = true;
// File dir = File(dataFolder);
// if (!dir.exists())
// dir.createDirectory();
//FILE* pFile;
// pFile = fopen("Test.bin", "wb");
return true; return true;
} }
...@@ -177,7 +211,7 @@ bool RecordNode::disable() ...@@ -177,7 +211,7 @@ bool RecordNode::disable()
{ {
// close files if necessary // close files if necessary
isProcessing = false; setParameter(0, 10.0f);
return true; return true;
} }
...@@ -227,7 +261,7 @@ void RecordNode::process(AudioSampleBuffer &buffer, ...@@ -227,7 +261,7 @@ void RecordNode::process(AudioSampleBuffer &buffer,
nSamples, nSamples,
i); i);
// write buffer to disk! // write buffer to disk!
std::cout << "Record channel " << i << std::endl; //std::cout << "Record channel " << i << std::endl;
} }
......
...@@ -82,6 +82,7 @@ private: ...@@ -82,6 +82,7 @@ private:
int chan; int chan;
String name; String name;
bool isRecording; bool isRecording;
String filename;
FILE* file; FILE* file;
}; };
......
...@@ -400,6 +400,9 @@ void ControlPanel::buttonClicked(Button* button) ...@@ -400,6 +400,9 @@ void ControlPanel::buttonClicked(Button* button)
if (graph->enableProcessors()) if (graph->enableProcessors())
{ {
if (recordButton->getToggleState())
graph->getRecordNode()->setParameter(1,10.0f);
audio->beginCallbacks(); audio->beginCallbacks();
masterClock->start(); masterClock->start();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment