From bab8fced17cd9797706aa1f8da277a0f5cde823c Mon Sep 17 00:00:00 2001 From: Aaron Cuevas Lopez <aacuelo@teleco.upv.es> Date: Wed, 4 Mar 2015 05:22:59 +0100 Subject: [PATCH] Fixes to the board audio output --- .../Processors/DataThreads/RHD2000Editor.cpp | 10 +++---- .../Processors/DataThreads/RHD2000Thread.cpp | 29 ++++++++++++++----- Source/Processors/DataThreads/RHD2000Thread.h | 3 +- Source/Processors/SpikeSorter/SpikeSorter.cpp | 2 +- 4 files changed, 28 insertions(+), 16 deletions(-) diff --git a/Source/Processors/DataThreads/RHD2000Editor.cpp b/Source/Processors/DataThreads/RHD2000Editor.cpp index e5048cce4..dc5a9d727 100644 --- a/Source/Processors/DataThreads/RHD2000Editor.cpp +++ b/Source/Processors/DataThreads/RHD2000Editor.cpp @@ -826,7 +826,7 @@ void RHD2000Editor::channelChanged(int chan) { electrodeButtons[i]->setChannelNum(chan); electrodeButtons[i]->repaint(); - board->assignAudioOut(i, chan); + board->setDACchannel(i, chan); } } @@ -891,10 +891,10 @@ void RHD2000Editor::loadCustomParameters(XmlElement* xml) bandwidthInterface->setLowerBandwidth(xml->getDoubleAttribute("LowCut")); bandwidthInterface->setUpperBandwidth(xml->getDoubleAttribute("HighCut")); adcButton->setToggleState(xml->getBoolAttribute("ADCsOn"), sendNotification); - electrodeButtons[0]->setChannelNum(xml->getIntAttribute("AudioOutputL")); - board->assignAudioOut(0, xml->getIntAttribute("AudioOutputL")); - electrodeButtons[1]->setChannelNum(xml->getIntAttribute("AudioOutputR")); - board->assignAudioOut(1, xml->getIntAttribute("AudioOutputR")); + //electrodeButtons[0]->setChannelNum(xml->getIntAttribute("AudioOutputL")); + //board->assignAudioOut(0, xml->getIntAttribute("AudioOutputL")); + //electrodeButtons[1]->setChannelNum(xml->getIntAttribute("AudioOutputR")); + //board->assignAudioOut(1, xml->getIntAttribute("AudioOutputR")); audioInterface->setNoiseSlicerLevel(xml->getIntAttribute("NoiseSlicer")); ttlSettleCombo->setSelectedId(xml->getIntAttribute("TTLFastSettle")); dacTTLButton->setToggleState(xml->getBoolAttribute("DAC_TTL"), sendNotification); diff --git a/Source/Processors/DataThreads/RHD2000Thread.cpp b/Source/Processors/DataThreads/RHD2000Thread.cpp index 581efe267..7e682e533 100644 --- a/Source/Processors/DataThreads/RHD2000Thread.cpp +++ b/Source/Processors/DataThreads/RHD2000Thread.cpp @@ -195,13 +195,26 @@ void RHD2000Thread::setDACthreshold(int dacOutput, float threshold) // evalBoard->setDacThresholdVoltage(dacOutput,threshold); } -void RHD2000Thread::setDACchannel(int dacOutput, int stream, int channel) +void RHD2000Thread::setDACchannel(int dacOutput, int channel) { - dacChannels[dacOutput] = channel; - dacStream[dacOutput] = stream; - dacChannelsToUpdate[dacOutput] = true; - dacOutputShouldChange = true; - // evalBoard->updateDacAssignment(dacOutput, channel); // doesn't really change anything, but keep things in sync... + if (channel < getNumHeadstageOutputs()) + { + int channelCount = 0; + for (int i = 0; i < enabledStreams.size(); i++) + { + if (channel < channelCount + numChannelsPerDataStream[i]) + { + dacChannels[dacOutput] = channel - channelCount; + dacStream[dacOutput] = i; + } + else + { + channelCount += numChannelsPerDataStream[i]; + } + } + dacChannelsToUpdate[dacOutput] = true; + dacOutputShouldChange = true; + } } Array<int> RHD2000Thread::getDACchannels() @@ -1083,7 +1096,7 @@ int RHD2000Thread::getChannelsInHeadstage(int hsNum) return headstagesArray[hsNum]->getNumChannels(); } -void RHD2000Thread::assignAudioOut(int dacChannel, int dataChannel) +/*void RHD2000Thread::assignAudioOut(int dacChannel, int dataChannel) { if (deviceFound) { @@ -1103,7 +1116,7 @@ void RHD2000Thread::assignAudioOut(int dacChannel, int dataChannel) // to avoid problems } -} +}*/ void RHD2000Thread::enableAdcs(bool t) { diff --git a/Source/Processors/DataThreads/RHD2000Thread.h b/Source/Processors/DataThreads/RHD2000Thread.h index cd05cc707..01801e116 100644 --- a/Source/Processors/DataThreads/RHD2000Thread.h +++ b/Source/Processors/DataThreads/RHD2000Thread.h @@ -101,7 +101,6 @@ public: int endIndex, double sampleRate, double frequency); int getNumEventChannels(); - void assignAudioOut(int dacChannel, int dataChannel); void enableAdcs(bool); bool isAcquisitionActive(); @@ -110,7 +109,7 @@ public: int modifyChannelName(int channel, String newName); void getEventChannelNames(StringArray &Names); Array<int> getDACchannels(); - void setDACchannel(int dacOutput, int stream, int channel); + void setDACchannel(int dacOutput, int channel); void setDACthreshold(int dacOutput, float threshold); void setDefaultNamingScheme(int scheme); diff --git a/Source/Processors/SpikeSorter/SpikeSorter.cpp b/Source/Processors/SpikeSorter/SpikeSorter.cpp index 3fab6eb2a..e29b2db7c 100644 --- a/Source/Processors/SpikeSorter/SpikeSorter.cpp +++ b/Source/Processors/SpikeSorter/SpikeSorter.cpp @@ -410,7 +410,7 @@ void SpikeSorter::assignDACtoChannel(int dacOutput, int channel) RHD2000Thread* th = getRhythmAccess(); if (th != nullptr) { - th->setDACchannel(dacOutput, channels[channel]->sourceNodeId, channels[channel]->index); // this is probably wrong (JHS) + th->setDACchannel(dacOutput, channel); // this is probably wrong (JHS) } } -- GitLab