Skip to content
Snippets Groups Projects
Commit d8e5bebe authored by Josh Siegle's avatar Josh Siegle
Browse files

Merge branch 'master' of https://github.com/open-ephys/GUI

parents 4ef389c1 3d4f97e6
Branches
Tags
No related merge requests found
......@@ -30,6 +30,7 @@ Channel::Channel(GenericProcessor* p, int n) :
sampleRate(44100.0f), bitVolts(1.0f), eventType(0)
{
nodeId = p->getNodeId();
createDefaultName();
}
......@@ -45,9 +46,16 @@ Channel::Channel(const Channel& ch)
bitVolts = ch.bitVolts;
name = ch.name;
eventType = ch.eventType;
nodeId = ch.nodeId;
}
void Channel::setProcessor(GenericProcessor* p)
{
processor = p;
nodeId = p->getNodeId();
}
String Channel::getName()
{
return name;
......@@ -66,5 +74,5 @@ void Channel::reset()
void Channel::createDefaultName()
{
name = String("CH");
name += num;
name += (num + 1);
}
\ No newline at end of file
......@@ -60,9 +60,14 @@ public:
void reset();
void setProcessor(GenericProcessor*);
// channel number:
int num;
// node id
int nodeId;
// event info:
int eventType;
......
......@@ -137,12 +137,12 @@ void FilterNode::updateSettings()
(1));
Parameter& p1 = parameters.getReference(0);
p1.setValue(600.0f, n);
p1.setValue(4.0f, n);
Parameter& p2 = parameters.getReference(1);
p2.setValue(6000.0f, n);
p2.setValue(12.0f, n);
setFilterParameters(600.0f, 3000.0f, n);
setFilterParameters(4.0f, 12.0f, n);
}
}
......
......@@ -306,6 +306,7 @@ void GenericProcessor::update()
{
Channel* sourceChan = sourceNode->channels[i];
Channel* ch = new Channel(*sourceChan);
ch->setProcessor(this);
channels.add(ch);
}
......
......@@ -88,10 +88,10 @@ void PhaseDetector::handleEvent(int eventType, MidiMessage& event, int sampleNum
// std::cout << "Received event from " << eventNodeId << ", channel "
// << eventChannel << ", with ID " << eventId << std::endl;
if (eventId == 1)
if (eventId == 1 && eventChannel == 5)
{
canBeTriggered = true;
} else {
} else if (eventId == 0 && eventChannel == 5) {
canBeTriggered = false;
}
......
......@@ -42,6 +42,13 @@ RecordNode::RecordNode()
eventChannel = new Channel(this, 0);
eventChannel->isEventChannel = true;
recordMarker = new char[10];
for (int i = 0; i < 9; i++)
{
recordMarker[i] = 0;
}
recordMarker[9] = 255;
// 128 inputs, 0 outputs
setPlayConfigDetails(getNumInputs(),getNumOutputs(),44100.0,128);
......@@ -136,6 +143,8 @@ void RecordNode::addInputChannel(GenericProcessor* sourceNode, int chan)
channelPointers.add(sourceNode->channels[chan]);
// std::cout << channelIndex << std::endl;
updateFileName(channelPointers[channelIndex]);
......@@ -174,7 +183,7 @@ void RecordNode::updateFileName(Channel* ch)
if (!ch->isEventChannel)
{
filename += ch->processor->getNodeId();
filename += ch->nodeId;
filename += "_";
filename += ch->name;
filename += ".continuous";
......@@ -185,6 +194,8 @@ void RecordNode::updateFileName(Channel* ch)
ch->filename = filename;
ch->file = 0;
//std::cout << "Updating " << filename << std::endl;
}
void RecordNode::createNewDirectory()
......@@ -445,27 +456,41 @@ void RecordNode::writeContinuousBuffer(float* data, int nSamples, int channel)
// find file and write samples to disk
AudioDataConverters::convertFloatToInt16BE(continuousDataFloatBuffer, continuousDataIntegerBuffer, nSamples);
//if (nSamples < 1000) // this is temporary, but there seems to be an error reading in the data if too many samples are written
// in the first few blocks
//{
int16 samps = (int16) nSamples;
AudioDataConverters::convertFloatToInt16BE(continuousDataFloatBuffer, continuousDataIntegerBuffer, nSamples);
//std::cout << samps << std::endl;
int16 samps = (int16) nSamples;
//std::cout << samps << std::endl;
fwrite(&timestamp, // ptr
8, // size of each element
1, // count
channelPointers[channel]->file); // ptr to FILE object
fwrite(&samps, // ptr
2, // size of each element
1, // count
channelPointers[channel]->file); // ptr to FILE object
int n = fwrite(continuousDataIntegerBuffer, // ptr
2, // size of each element
nSamples, // count
channelPointers[channel]->file); // ptr to FILE object
// n must equal "count", otherwise there was an error
// write a 10-byte marker indicating the end of a record
fwrite(recordMarker, // ptr
1, // size of each element
10, // count
channelPointers[channel]->file); // ptr to FILE object
fwrite(&timestamp, // ptr
8, // size of each element
1, // count
channelPointers[channel]->file); // ptr to FILE object
fwrite(&samps, // ptr
2, // size of each element
1, // count
channelPointers[channel]->file); // ptr to FILE object
int n = fwrite(continuousDataIntegerBuffer, // ptr
2, // size of each element
nSamples, // count
channelPointers[channel]->file); // ptr to FILE object
// n must equal "count", otherwise there was an error
//}
}
void RecordNode::writeEventBuffer(MidiMessage& event, int samplePosition) //, int node, int channel)
......
......@@ -179,6 +179,9 @@ private:
*/
void writeEventBuffer(MidiMessage& event, int samplePos);
/** Used to indicate the end of each record */
char* recordMarker;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (RecordNode);
};
......
......@@ -307,8 +307,8 @@ void SourceNode::process(AudioSampleBuffer &buffer,
);
} else {
std::cout << "ON" << std::endl;
std::cout << c << std::endl;
// std::cout << "ON" << std::endl;
// std::cout << c << std::endl;
// signal channel state is ON
addEvent(events, // MidiBuffer
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment