Skip to content

Commit 8c1b871

Browse files
authored
Merge pull request #184 from kmichaelfox/testing
Fix bug with DataChannels and audio monitoring
2 parents c52c7f2 + 33f325b commit 8c1b871

6 files changed

Lines changed: 61 additions & 23 deletions

File tree

.gitignore

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,36 @@ Builds/MacOSX/open-ephys.xcodeproj/*.pbxuser
120120
Builds/MacOSX/open-ephys.xcodeproj/xcuserdata
121121
Builds/MacOSX/open-ephys.xcodeproj/project.xcworkspace
122122
Builds/MacOSX/build
123-
Projucer/Builds/MacOSX/The Projucer.xcodeproj/*.mode1v3
124-
Projucer/Builds/MacOSX/The Projucer.xcodeproj/*.pbxuser
125-
Projucer/Builds/MacOSX/The Projucer.xcodeproj/xcuserdata
126-
Projucer/Builds/MacOSX/The Projucer.xcodeproj/project.xcworkspace
123+
Projucer/Builds/MacOSX/Projucer.xcodeproj/*.mode1v3
124+
Projucer/Builds/MacOSX/Projucer.xcodeproj/*.pbxuser
125+
Projucer/Builds/MacOSX/Projucer.xcodeproj/xcuserdata
126+
Projucer/Builds/MacOSX/Projucer.xcodeproj/project.xcworkspace
127127
Projucer/Builds/MacOSX/build
128128
Projucer/Builds/MacOSX/Projucer.xcodeproj/xcuserdata
129129
Projucer/Builds/MacOSX/Projucer.xcodeproj/project.xcworkspace
130130

131+
*.pbxuser
132+
!default.pbxuser
133+
*.mode1v3
134+
!default.mode1v3
135+
*.mode2v3
136+
!default.mode2v3
137+
*.perspectivev3
138+
*default.perspectivev3
139+
xcuserdata/
140+
141+
*.moved-aside
142+
*.xccheckout
143+
*.xcscmblueprint
144+
145+
*.xcodeproj/*
146+
!*.xcodeproj/project.pbxproj
147+
!*.xcodeproj/xcshareddata/
148+
!*.xcworkspace/contents.xcworkspacedata
149+
/*.gcno
150+
151+
PluginGenerator/Builds/MacOSX/OpenEphys_PluginGenerator.xcodeproj/project.xcworkspace/contents.xcworkspacedata
152+
131153
# 9. Plugin build dirs
132154
build/
133155

Source/Processors/AudioNode/AudioNode.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,11 @@ void AudioNode::addInputChannel(GenericProcessor* sourceNode, int chan)
113113

114114
setPlayConfigDetails(channelIndex+1,0,44100.0,128);
115115

116-
dataChannelArray.add(new DataChannel(*sourceNode->getDataChannel(chan)));
116+
auto dataChannel = sourceNode->getDataChannel(chan);
117+
auto dataChannelCopy = new DataChannel(*dataChannel);
118+
dataChannelCopy->setMonitored(dataChannel->isMonitored());
119+
120+
dataChannelArray.add(dataChannelCopy);
117121

118122
}
119123

@@ -534,4 +538,4 @@ void Expander::process(float* sampleData, int numSamples)
534538

535539
sampleData[i] = sampleData[i] * gain;
536540
}
537-
}
541+
}

Source/Processors/Channel/InfoObjects.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,4 +683,4 @@ void ConfigurationObject::setDefaultNameAndDescription()
683683
{
684684
setName("Configuration Object");
685685
setDescription("Generic configuration object");
686-
}
686+
}

Source/Processors/Editors/ChannelSelector.cpp

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -655,19 +655,19 @@ void ChannelSelector::buttonClicked(Button* button)
655655
bool status = b->getToggleState();
656656

657657
// std::cout << "Requesting audio monitor for channel " << ch->nodeIndex + 1 << std::endl;
658-
659-
if (acquisitionIsActive) // use setParameter to change parameter safely
658+
659+
// change parameter directly on editor
660+
// This is another of those ugly things that will go away once the
661+
// probe audio system is implemented, but is needed to maintain compatibility
662+
// between the older recording system and the newer channel objects.
663+
const_cast<DataChannel*>(ch)->setMonitored(status);
664+
665+
666+
if (acquisitionIsActive) // use setParameter to change audio node's copy of parameter safely, if running
660667
{
661668
AccessClass::getProcessorGraph()->
662669
getAudioNode()->setChannelStatus(ch, status);
663670
}
664-
else // change parameter directly
665-
{
666-
//This is another of those ugly things that will go away once the
667-
//probe audio system is implemented, but is needed to maintain compatibility
668-
//between the older recording system and the newer channel objects.
669-
const_cast<DataChannel*>(ch)->setMonitored(status);
670-
}
671671
}
672672
else if (b->getType() == RECORD)
673673
{
@@ -680,9 +680,16 @@ void ChannelSelector::buttonClicked(Button* button)
680680

681681
if (acquisitionIsActive) // use setParameter to change parameter safely
682682
{
683-
AccessClass::getProcessorGraph()->
683+
if ( AccessClass::getProcessorGraph()->
684684
getRecordNode()->
685-
setChannelStatus(ch, status);
685+
setChannelStatus(ch, status) )
686+
{
687+
const_cast<DataChannel*>(ch)->setRecordState(status);
688+
}
689+
690+
// make sure that the button matches the system's actual state, in case
691+
// user's interaction was disallowed
692+
b->setToggleState(const_cast<DataChannel*>(ch)->getRecordState(), dontSendNotification);
686693
}
687694
else // change parameter directly
688695
{

Source/Processors/RecordNode/RecordNode.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,16 @@ RecordNode::~RecordNode()
6969

7070
void RecordNode::setChannel(const DataChannel* ch)
7171
{
72-
int channelNum = dataChannelArray.indexOf(ch);
72+
// int channelNum = dataChannelArray.indexOf(ch);
73+
int channelNum = getDataChannelIndex(ch->getSourceIndex(), ch->getSourceNodeID(), ch->getSubProcessorIdx());
7374

7475
std::cout << "Record node setting channel to " << channelNum << std::endl;
7576

7677
setCurrentChannel(channelNum);
7778

7879
}
7980

80-
void RecordNode::setChannelStatus(const DataChannel* ch, bool status)
81+
bool RecordNode::setChannelStatus(const DataChannel* ch, bool status)
8182
{
8283

8384
//std::cout << "Setting channel status!" << std::endl;
@@ -87,7 +88,8 @@ void RecordNode::setChannelStatus(const DataChannel* ch, bool status)
8788
setParameter(2, 1.0f);
8889
else
8990
setParameter(2, 0.0f);
90-
91+
92+
return status == dataChannelArray[currentChannel]->getRecordState();
9193
}
9294

9395

@@ -555,4 +557,4 @@ void RecordNode::updateRecordChannelIndexes()
555557
void RecordNode::addSpecialProcessorChannels(Array<EventChannel*>& channels)
556558
{
557559
eventChannelArray.addArray(channels);
558-
}
560+
}

Source/Processors/RecordNode/RecordNode.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,11 @@ class RecordNode : public GenericProcessor,
106106
/** Turns recording on and off for a particular channel.
107107
108108
Channel numbers are absolute (based on RecordNode channel mapping).
109+
110+
Returns a bool indicating whether the status update was successful (true)
111+
or blocked (false) because recording is currently in progress.
109112
*/
110-
void setChannelStatus(const DataChannel* ch, bool status);
113+
bool setChannelStatus(const DataChannel* ch, bool status);
111114

112115
/** Used to clear all connections prior to the start of acquisition.
113116
*/

0 commit comments

Comments
 (0)