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

Minor updates to RecordNode

parent 0a2e9a47
No related branches found
No related tags found
No related merge requests found
......@@ -30,7 +30,8 @@ RecordNode::RecordNode()
// newDataFolder = true; // defaults to creating a new data folder on startup
continuousDataBuffer = new int16[10000];
continuousDataIntegerBuffer = new int16[10000];
continuousDataFloatBuffer = new float[10000];
signalFilesShouldClose = false;
}
......@@ -142,10 +143,8 @@ void RecordNode::addInputChannel(GenericProcessor* sourceNode, int chan)
continuousChannels.insert(newPair);
} else {
std::map<int, Channel> eventChans;
int ID = sourceNode->getNodeId();
......@@ -317,9 +316,15 @@ float RecordNode::getFreeSpace()
void RecordNode::writeContinuousBuffer(float* data, int nSamples, int channel)
{
// scale the data appropriately
for (int n = 0; n < nSamples; n++)
{
*(continuousDataFloatBuffer+n) = *(data+n) / 10000.0f;
}
// find file and write samples to disk
AudioDataConverters::convertFloatToInt16BE(data, continuousDataBuffer, nSamples);
AudioDataConverters::convertFloatToInt16BE(continuousDataFloatBuffer, continuousDataIntegerBuffer, nSamples);
//int16 samps = nSamples;
......@@ -333,7 +338,7 @@ void RecordNode::writeContinuousBuffer(float* data, int nSamples, int channel)
1, // count
continuousChannels[channel].file); // ptr to FILE object
int n = fwrite(continuousDataBuffer, // ptr
int n = fwrite(continuousDataIntegerBuffer, // ptr
2, // size of each element
nSamples, // count
continuousChannels[channel].file); // ptr to FILE object
......@@ -354,10 +359,11 @@ void RecordNode::process(AudioSampleBuffer &buffer,
//std::cout << "Record node processing block." << std::endl;
//std::cout << "Num channels: " << buffer.getNumChannels() << std::endl;
timestamp = timer.getHighResolutionTicks();
if (isRecording) {
timestamp = timer.getHighResolutionTicks();
// WHY IS THIS AFFECTING THE LFP DISPLAY?
//buffer.applyGain(0, nSamples, 5.2438f);
......@@ -385,10 +391,10 @@ void RecordNode::process(AudioSampleBuffer &buffer,
}
// this is intended to prevent parameter changes from closing files
// before recording stops
if (signalFilesShouldClose)
{
// prevent parameter changes from closing files
// before recording stops
closeAllFiles();
signalFilesShouldClose = false;
}
......
......@@ -52,9 +52,20 @@ public:
RecordNode();
~RecordNode();
/** Handle incoming data and decide which files and events to write to disk.
*/
void process(AudioSampleBuffer &buffer, MidiBuffer &eventBuffer, int& nSamples);
/** Overrides implementation in GenericProcessor; used to change recording parameters
on the fly.
parameterIndex = 0: stop recording
parameterIndex = 1: start recording
parameterIndex = 2:
newValue = 0: turn off recording for current channel
newValue = 1: turn on recording for current channel
*/
void setParameter (int parameterIndex, float newValue);
void addInputChannel(GenericProcessor* sourceNode, int chan);
......@@ -67,16 +78,30 @@ public:
*/
float getFreeSpace();
/** Selects a channel relative to a particular processor with ID = id
*/
void setChannel(int id, int chan);
/** Turns recording on and off for a particular channel.
Channel numbers are absolute (based on RecordNode channel mapping).
*/
void setChannelStatus(int chan, bool status);
/** Used to clear all connections prior to the start of acquisition.
*/
void resetConnections();
/** Overrides implementation by GenericProcessor.
*/
bool isAudioOrRecordNode() {return true;}
/** Callback to indicate when user has chosen a new data directory.
*/
void filenameComponentChanged(FilenameComponent*);
/** Creates a new data directory in the location specified by the fileNameComponent.
*/
void createNewDirectory();
private:
......@@ -102,7 +127,12 @@ private:
/** Holds data that has been converted from float to int16 before
saving.
*/
int16* continuousDataBuffer;
int16* continuousDataIntegerBuffer;
/** Holds data that has been converted from float to int16 before
saving.
*/
float* continuousDataFloatBuffer;
/** Integer timestamp saved for each buffer.
*/
......@@ -125,6 +155,8 @@ private:
FILE* file;
};
/** Closes all open files after recording has finished.
*/
void closeAllFiles();
/** Map of continuous channels.
......
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