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

Add option to prepend or append strings to the name of data folders

parent dd501b86
No related branches found
No related tags found
No related merge requests found
......@@ -77,10 +77,12 @@ void ProcessorGraph::createDefaultNodes()
// add record node -- sends output to disk
RecordNode* recn = new RecordNode();
recn->setNodeId(RECORD_NODE_ID);
// add audio node -- takes all inputs and selects those to be used for audio monitoring
AudioNode* an = new AudioNode();
an->setNodeId(AUDIO_NODE_ID);
// add audio resampling node -- resamples continuous signals to 44.1kHz
AudioResamplingNode* arn = new AudioResamplingNode();
......@@ -110,6 +112,12 @@ void ProcessorGraph::createDefaultNodes()
}
void ProcessorGraph::updatePointers()
{
getAudioNode()->setUIComponent(getUIComponent());
getRecordNode()->setUIComponent(getUIComponent());
}
void* ProcessorGraph::createNewProcessor(String& description)//,
// GenericProcessor* source,
// GenericProcessor* dest)
......
......@@ -79,6 +79,8 @@ public:
/** Loops through processors and restores parameters, if they're available. */
void restoreParameters();
void updatePointers();
private:
int currentNodeId;
......@@ -92,6 +94,7 @@ private:
};
void createDefaultNodes();
void clearConnections();
};
......
......@@ -23,13 +23,14 @@
#include "RecordNode.h"
#include "ProcessorGraph.h"
#include "../UI/ControlPanel.h"
#include "Channel.h"
RecordNode::RecordNode()
: GenericProcessor("Record Node"),
isRecording(false), isProcessing(false), signalFilesShouldClose(false),
timestamp(0)
timestamp(0), newDirectoryNeeded(true)
{
......@@ -126,7 +127,7 @@ void RecordNode::filenameComponentChanged(FilenameComponent* fnc)
else
std::cout << " is NOT a directory." << std::endl;
createNewDirectory();
//createNewDirectory();
......@@ -217,6 +218,8 @@ void RecordNode::createNewDirectory()
updateFileName(channelPointers[i]);
}
newDirectoryNeeded = false;
}
String RecordNode::generateDirectoryName()
......@@ -231,21 +234,28 @@ String RecordNode::generateDirectoryName()
t.add(calendar.getMinutes());
t.add(calendar.getSeconds());
String filename = "";
String filename = getControlPanel()->getTextToPrepend();
String datestring = "";
for (int n = 0; n < t.size(); n++)
{
if (t[n] < 10)
filename += "0";
datestring += "0";
filename += t[n];
datestring += t[n];
if (n == 2)
filename += "_";
datestring += "_";
else if (n < 5)
filename += "-";
datestring += "-";
}
getControlPanel()->setDateText(datestring);
filename += datestring;
filename += getControlPanel()->getTextToAppend();
return filename;
}
......@@ -286,6 +296,9 @@ void RecordNode::setParameter(int parameterIndex, float newValue)
isRecording = true;
std::cout << "START RECORDING." << std::endl;
if (newDirectoryNeeded)
createNewDirectory();
if (!rootFolder.exists())
rootFolder.createDirectory();
......
......@@ -101,6 +101,9 @@ public:
*/
void createNewDirectory();
/** Signals when to create a new data directory when recording starts.*/
bool newDirectoryNeeded;
private:
/** Keep the RecordNode informed of acquisition and record states.
......
......@@ -379,7 +379,7 @@ ControlPanel::ControlPanel(ProcessorGraph* graph_, AudioComponent* audio_)
cpb = new ControlPanelButton(this);
addAndMakeVisible(cpb);
newDirectoryButton = new UtilityButton("+", font);
newDirectoryButton = new UtilityButton("+", Font("Small Text", 15, Font::plain));
newDirectoryButton->setEnabledState(false);
newDirectoryButton->addListener(this);
addChildComponent(newDirectoryButton);
......@@ -396,6 +396,23 @@ ControlPanel::ControlPanel(ProcessorGraph* graph_, AudioComponent* audio_)
"");
addChildComponent(filenameComponent);
prependText = new Label("Prepend","");
prependText->setEditable(true);
prependText->addListener(this);
prependText->setColour(Label::backgroundColourId, Colours::lightgrey);
addChildComponent(prependText);
dateText = new Label("Date","YY-MM-DD_HH-MM-SS");
dateText->setColour(Label::backgroundColourId, Colours::lightgrey);
addChildComponent(dateText);
appendText = new Label("Append","");
appendText->setEditable(true);
appendText->addListener(this);
appendText->setColour(Label::backgroundColourId, Colours::lightgrey);
addChildComponent(appendText);
//diskMeter->updateDiskSpace(graph->getRecordNode()->getFreeSpace());
//diskMeter->repaint();
//refreshMeters();
......@@ -495,17 +512,29 @@ void ControlPanel::resized()
if (open)
{
filenameComponent->setBounds(200, h+5, w-250, h-10);
filenameComponent->setBounds(165, h+5, w-500, h-10);
filenameComponent->setVisible(true);
newDirectoryButton->setBounds(165, h+5, h-10, h-10);
newDirectoryButton->setBounds(w-h+4, h+5, h-10, h-10);
newDirectoryButton->setVisible(true);
prependText->setBounds(165+w-490, h+5, 50, h-10);
prependText->setVisible(true);
dateText->setBounds(165+w-435, h+5, 175, h-10);
dateText->setVisible(true);
appendText->setBounds(165+w-255, h+5, 50, h-10);
appendText->setVisible(true);
}
else
{
filenameComponent->setVisible(false);
newDirectoryButton->setVisible(false);
prependText->setVisible(false);
dateText->setVisible(false);
appendText->setVisible(false);
}
repaint();
......@@ -518,6 +547,11 @@ void ControlPanel::openState(bool os)
getUIComponent()->childComponentChanged();
}
void ControlPanel::labelTextChanged(Label* label)
{
}
void ControlPanel::buttonClicked(Button* button)
{
......@@ -557,7 +591,7 @@ void ControlPanel::buttonClicked(Button* button)
}
else if (button == newDirectoryButton && newDirectoryButton->getEnabledState())
{
getProcessorGraph()->getRecordNode()->createNewDirectory();
getProcessorGraph()->getRecordNode()->newDirectoryNeeded = true;
newDirectoryButton->setEnabledState(false);
masterClock->resetRecordTime();
return;
......@@ -699,3 +733,32 @@ void ControlPanel::toggleState()
cpb->toggleState();
getUIComponent()->childComponentChanged();
}
String ControlPanel::getTextToAppend()
{
String t = appendText->getText();
if (t.length() > 0)
{
return "_" + t;
} else {
return t;
}
}
String ControlPanel::getTextToPrepend()
{
String t = prependText->getText();
if (t.length() > 0)
{
return t + "_";
} else {
return t;
}
}
void ControlPanel::setDateText(String t)
{
dateText->setText(t, dontSendNotification);
}
\ No newline at end of file
......@@ -34,8 +34,6 @@
#include "../Processors/Editors/GenericEditor.h" // for UtilityButton
#include "../Processors/Visualization/OpenGLCanvas.h"
//#include "../OpenGL.h"
/**
......@@ -273,7 +271,8 @@ class UtilityButton;
class ControlPanel : public Component,
public Button::Listener,
public Timer,
public AccessClass
public AccessClass,
public Label::Listener
{
public:
......@@ -306,6 +305,18 @@ public:
return open;
}
/** Notifies the control panel when the filename is updated */
void labelTextChanged(Label*);
/** Used by RecordNode to set the filename. */
String getTextToPrepend();
/** Used by RecordNode to set the filename. */
String getTextToAppend();
/** Set date text. */
void setDateText(String);
private:
ScopedPointer<PlayButton> playButton;
ScopedPointer<RecordButton> recordButton;
......@@ -316,6 +327,10 @@ private:
ScopedPointer<UtilityButton> newDirectoryButton;
ScopedPointer<ControlPanelButton> cpb;
ScopedPointer<Label> prependText;
ScopedPointer<Label> dateText;
ScopedPointer<Label> appendText;
ProcessorGraph* graph;
AudioComponent* audio;
AudioEditor* audioEditor;
......
......@@ -74,6 +74,7 @@ UIComponent::UIComponent(MainWindow* mainWindow_, ProcessorGraph* pgraph, AudioC
std::cout << "Finished UI stuff." << std::endl << std::endl << std::endl;
processorGraph->setUIComponent(this);
processorGraph->updatePointers(); // needs to happen after processorGraph gets the right pointers
processorList->setUIComponent(this);
editorViewport->setUIComponent(this);
dataViewport->setUIComponent(this);
......
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