diff --git a/.gitignore b/.gitignore index 0b97d8ba01e95d0036e28ff1ed0967f907335321..0c5e07fdc86b72b4cdabed4cdcf7f541075ecdaf 100644 --- a/.gitignore +++ b/.gitignore @@ -58,3 +58,5 @@ cscope.out # 7. Open Ephys data files *.continuous *.events + +.DS_Store diff --git a/Builds/MacOSX/open-ephys.xcodeproj/project.pbxproj b/Builds/MacOSX/open-ephys.xcodeproj/project.pbxproj index f48013cfb3da4c9e2a35b1c2c2c05ac8d6269347..b6d6a97778f59eb41a3af35eda6605efc54c734c 100644 --- a/Builds/MacOSX/open-ephys.xcodeproj/project.pbxproj +++ b/Builds/MacOSX/open-ephys.xcodeproj/project.pbxproj @@ -3563,6 +3563,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; DEBUG_INFORMATION_FORMAT = dwarf; GCC_C_LANGUAGE_STANDARD = c99; GCC_INLINES_ARE_PRIVATE_EXTERN = YES; @@ -3582,7 +3583,7 @@ 7A6F9B742B69F66DC3E29FA8 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + ARCHS = "$(NATIVE_ARCH_ACTUAL)"; CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_LINK_OBJC_RUNTIME = NO; COMBINE_HIDPI_IMAGES = YES; @@ -3599,9 +3600,13 @@ HEADER_SEARCH_PATHS = ( ../../JuceLibraryCode, "$(inherited)", + /opt/local/include, + /usr/local/include, + /usr/local/include/freetype2, ); INFOPLIST_FILE = Info.plist; INSTALL_PATH = "$(HOME)/Applications"; + LIBRARY_SEARCH_PATHS = /opt/local/lib; MACOSX_DEPLOYMENT_TARGET_ppc = 10.4; OTHER_LDFLAGS = "-lftdi"; SDKROOT_ppc = macosx10.5; @@ -3611,7 +3616,7 @@ 95F63B27BAC6E72226C3E356 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + ARCHS = "$(NATIVE_ARCH_ACTUAL)"; CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_LINK_OBJC_RUNTIME = NO; COMBINE_HIDPI_IMAGES = YES; @@ -3628,9 +3633,13 @@ HEADER_SEARCH_PATHS = ( ../../JuceLibraryCode, "$(inherited)", + /opt/local/include, + /usr/local/include, + /usr/local/include/freetype2, ); INFOPLIST_FILE = Info.plist; INSTALL_PATH = "$(HOME)/Applications"; + LIBRARY_SEARCH_PATHS = /opt/local/lib; MACOSX_DEPLOYMENT_TARGET_ppc = 10.4; ONLY_ACTIVE_ARCH = YES; OTHER_LDFLAGS = "-lftdi"; @@ -3642,6 +3651,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; DEBUG_INFORMATION_FORMAT = dwarf; GCC_C_LANGUAGE_STANDARD = c99; GCC_INLINES_ARE_PRIVATE_EXTERN = YES; diff --git a/Builds/MacOSX/open-ephys.xcodeproj/project.xcworkspace/xcuserdata/ryan.xcuserdatad/UserInterfaceState.xcuserstate b/Builds/MacOSX/open-ephys.xcodeproj/project.xcworkspace/xcuserdata/ryan.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000000000000000000000000000000000000..0e2b6d35f67b53debf60191b7d45037186fbf5de Binary files /dev/null and b/Builds/MacOSX/open-ephys.xcodeproj/project.xcworkspace/xcuserdata/ryan.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Builds/MacOSX/open-ephys.xcodeproj/xcuserdata/ryan.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist b/Builds/MacOSX/open-ephys.xcodeproj/xcuserdata/ryan.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist new file mode 100644 index 0000000000000000000000000000000000000000..647b6ca2b47334a4a3b309f80db229d8556c7630 --- /dev/null +++ b/Builds/MacOSX/open-ephys.xcodeproj/xcuserdata/ryan.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Bucket + type = "1" + version = "1.0"> + <FileBreakpoints> + <FileBreakpoint + shouldBeEnabled = "No" + ignoreCount = "0" + continueAfterRunningActions = "No" + filePath = "../../Source/Processors/Editors/ParameterEditor.cpp" + timestampString = "389810419.934004" + startingColumnNumber = "9223372036854775807" + endingColumnNumber = "9223372036854775807" + startingLineNumber = "527" + endingLineNumber = "527" + landmarkName = "ParameterEditor::channelSelectionUI()" + landmarkType = "5"> + </FileBreakpoint> + <FileBreakpoint + shouldBeEnabled = "No" + ignoreCount = "0" + continueAfterRunningActions = "No" + filePath = "../../Source/Processors/Editors/ChannelSelector.h" + timestampString = "389831652.316183" + startingColumnNumber = "9223372036854775807" + endingColumnNumber = "9223372036854775807" + startingLineNumber = "113" + endingLineNumber = "113"> + </FileBreakpoint> + <FileBreakpoint + shouldBeEnabled = "Yes" + ignoreCount = "0" + continueAfterRunningActions = "No" + filePath = "../../Source/Processors/Editors/ChannelSelector.h" + timestampString = "389833146.171327" + startingColumnNumber = "9223372036854775807" + endingColumnNumber = "9223372036854775807" + startingLineNumber = "112" + endingLineNumber = "112"> + </FileBreakpoint> + </FileBreakpoints> +</Bucket> diff --git a/Builds/MacOSX/open-ephys.xcodeproj/xcuserdata/ryan.xcuserdatad/xcschemes/open-ephys.xcscheme b/Builds/MacOSX/open-ephys.xcodeproj/xcuserdata/ryan.xcuserdatad/xcschemes/open-ephys.xcscheme new file mode 100644 index 0000000000000000000000000000000000000000..91a5abf9d39ed7513bbecff688e942900c42a82e --- /dev/null +++ b/Builds/MacOSX/open-ephys.xcodeproj/xcuserdata/ryan.xcuserdatad/xcschemes/open-ephys.xcscheme @@ -0,0 +1,86 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Scheme + LastUpgradeVersion = "0460" + version = "1.3"> + <BuildAction + parallelizeBuildables = "YES" + buildImplicitDependencies = "YES"> + <BuildActionEntries> + <BuildActionEntry + buildForTesting = "YES" + buildForRunning = "YES" + buildForProfiling = "YES" + buildForArchiving = "YES" + buildForAnalyzing = "YES"> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "609761DEC9151D2CDD50270C" + BuildableName = "open-ephys.app" + BlueprintName = "open-ephys" + ReferencedContainer = "container:open-ephys.xcodeproj"> + </BuildableReference> + </BuildActionEntry> + </BuildActionEntries> + </BuildAction> + <TestAction + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + shouldUseLaunchSchemeArgsEnv = "YES" + buildConfiguration = "Debug"> + <Testables> + </Testables> + <MacroExpansion> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "609761DEC9151D2CDD50270C" + BuildableName = "open-ephys.app" + BlueprintName = "open-ephys" + ReferencedContainer = "container:open-ephys.xcodeproj"> + </BuildableReference> + </MacroExpansion> + </TestAction> + <LaunchAction + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + launchStyle = "0" + useCustomWorkingDirectory = "NO" + buildConfiguration = "Debug" + ignoresPersistentStateOnLaunch = "NO" + debugDocumentVersioning = "YES" + allowLocationSimulation = "YES"> + <BuildableProductRunnable> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "609761DEC9151D2CDD50270C" + BuildableName = "open-ephys.app" + BlueprintName = "open-ephys" + ReferencedContainer = "container:open-ephys.xcodeproj"> + </BuildableReference> + </BuildableProductRunnable> + <AdditionalOptions> + </AdditionalOptions> + </LaunchAction> + <ProfileAction + shouldUseLaunchSchemeArgsEnv = "YES" + savedToolIdentifier = "" + useCustomWorkingDirectory = "NO" + buildConfiguration = "Release" + debugDocumentVersioning = "YES"> + <BuildableProductRunnable> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "609761DEC9151D2CDD50270C" + BuildableName = "open-ephys.app" + BlueprintName = "open-ephys" + ReferencedContainer = "container:open-ephys.xcodeproj"> + </BuildableReference> + </BuildableProductRunnable> + </ProfileAction> + <AnalyzeAction + buildConfiguration = "Debug"> + </AnalyzeAction> + <ArchiveAction + buildConfiguration = "Release" + revealArchiveInOrganizer = "YES"> + </ArchiveAction> +</Scheme> diff --git a/Builds/MacOSX/open-ephys.xcodeproj/xcuserdata/ryan.xcuserdatad/xcschemes/xcschememanagement.plist b/Builds/MacOSX/open-ephys.xcodeproj/xcuserdata/ryan.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000000000000000000000000000000000000..3450a230d501a0d61793f4ce41d8b73462e4e1b5 --- /dev/null +++ b/Builds/MacOSX/open-ephys.xcodeproj/xcuserdata/ryan.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>SchemeUserState</key> + <dict> + <key>open-ephys.xcscheme</key> + <dict> + <key>orderHint</key> + <integer>0</integer> + </dict> + </dict> + <key>SuppressBuildableAutocreation</key> + <dict> + <key>609761DEC9151D2CDD50270C</key> + <dict> + <key>primary</key> + <true/> + </dict> + </dict> +</dict> +</plist> diff --git a/Source/Processors/ArduinoOutput.cpp b/Source/Processors/ArduinoOutput.cpp index 8422dfabb905bcc33f08c7501f32e83e707ce4fa..345336f44ca01fd27b46f8ab394ddbe93365d673 100755 --- a/Source/Processors/ArduinoOutput.cpp +++ b/Source/Processors/ArduinoOutput.cpp @@ -75,6 +75,7 @@ void ArduinoOutput::handleEvent(int eventType, MidiMessage& event, int sampleNum void ArduinoOutput::setParameter(int parameterIndex, float newValue) { + editor->updateParameterButtons(parameterIndex); } diff --git a/Source/Processors/AudioNode.cpp b/Source/Processors/AudioNode.cpp index 3d516ee6ddc1b552cae5da1e4ff4da4b42a708d2..99fa448462a431ae340ece25fcccc52f7d1813d0 100755 --- a/Source/Processors/AudioNode.cpp +++ b/Source/Processors/AudioNode.cpp @@ -128,6 +128,7 @@ void AudioNode::addInputChannel(GenericProcessor* sourceNode, int chan) void AudioNode::setParameter(int parameterIndex, float newValue) { + editor->updateParameterButtons(parameterIndex); // change left channel, right channel, or volume if (parameterIndex == 1) { diff --git a/Source/Processors/AudioResamplingNode.cpp b/Source/Processors/AudioResamplingNode.cpp index 293be0ab07f5070c57cffdb150e9d43132c8bfff..49136a8d15478a337bee6c56e3b33b0e71f4591a 100644 --- a/Source/Processors/AudioResamplingNode.cpp +++ b/Source/Processors/AudioResamplingNode.cpp @@ -68,6 +68,7 @@ AudioResamplingNode::~AudioResamplingNode() void AudioResamplingNode::setParameter(int parameterIndex, float newValue) { + editor->updateParameterButtons(parameterIndex); switch (parameterIndex) { diff --git a/Source/Processors/Editors/ChannelSelector.cpp b/Source/Processors/Editors/ChannelSelector.cpp index 5789c37e62d1fbe3f0d654078937d3e20da4694d..2cc01b7c55827310e74a5b2565d075e1b0a9747d 100755 --- a/Source/Processors/Editors/ChannelSelector.cpp +++ b/Source/Processors/Editors/ChannelSelector.cpp @@ -586,7 +586,7 @@ void ChannelSelector::buttonClicked(Button* button) } } - + refreshParameterColors(); } diff --git a/Source/Processors/Editors/ChannelSelector.h b/Source/Processors/Editors/ChannelSelector.h index 33745bd6afd7e2f6df7fb525f7bc23086e1706ee..dd8d45c55bf12cf528424ab08b30e2b76d7e1e7a 100755 --- a/Source/Processors/Editors/ChannelSelector.h +++ b/Source/Processors/Editors/ChannelSelector.h @@ -73,6 +73,9 @@ public: /** Set the total number of channels. */ void setNumChannels(int); + /** get the total number of channels. */ + int getNumChannels(){return parameterButtons.size();} + /** Return whether a particular channel should be recording. */ bool getRecordStatus(int chan); @@ -82,13 +85,13 @@ public: /** Return whether a particular channel is selected for editing parameters. */ bool getParamStatus(int chan); - /** Return whether a particular channel should be recording. */ + /** Set whether a particular channel should be recording. */ void setRecordStatus(int, bool); - /** Return whether a particular channel should be monitored. */ + /** Set whether a particular channel should be monitored. */ void setAudioStatus(int, bool); - /** Return whether a particular channel is selected for editing parameters. */ + /** Set whether a particular channel is selected for editing parameters. */ void setParamStatus(int, bool); /** Return component's desired width. */ @@ -106,6 +109,10 @@ public: /** Activates all the ChannelSelectorButtons under the "param" tab.*/ void activateButtons(); + /** Refreshes Parameter Colors on change*/ + void refreshParameterColors(){GenericEditor* p=dynamic_cast<GenericEditor*>(getParentComponent()); + p->updateParameterButtons(-1);} + /** Controls the behavior of ChannelSelectorButtons; they can either behave like radio buttons (only one selected at a time) or like toggle buttons (an arbitrary number can be selected at once).*/ diff --git a/Source/Processors/Editors/GenericEditor.cpp b/Source/Processors/Editors/GenericEditor.cpp index 33ef2f9e38a2ba0d7c1770149db0ae5fd85ebcfd..defee8da696cc16c74778d2eeefd3a9b39484ea1 100755 --- a/Source/Processors/Editors/GenericEditor.cpp +++ b/Source/Processors/Editors/GenericEditor.cpp @@ -105,7 +105,7 @@ void GenericEditor::constructorInitialize(GenericProcessor* owner, bool useDefau } -void GenericEditor::addParameterEditors(bool useDefaultParameterEditors) +void GenericEditor::addParameterEditors(bool useDefaultParameterEditors=true) { if (useDefaultParameterEditors) { @@ -769,3 +769,15 @@ void TriangleButton::paintButton(Graphics& g, bool isMouseOver, bool isButtonDow } +void GenericEditor::updateParameterButtons(int parameterIndex=-1){ + if (parameterIndex==-1){ + for (int i = 0; i < parameterEditors.size(); ++i) + { + parameterEditors[i]->channelSelectionUI(); + } + } + else{ + parameterEditors[parameterIndex]->channelSelectionUI(); + } + std::cout << "updateParameterButtons" << std::endl; +} diff --git a/Source/Processors/Editors/GenericEditor.h b/Source/Processors/Editors/GenericEditor.h index 3030b740a13916db3487292d81742c98df9f2e59..214bae945e2b40cca95609c757cc7d7ae7cde4c6 100755 --- a/Source/Processors/Editors/GenericEditor.h +++ b/Source/Processors/Editors/GenericEditor.h @@ -237,6 +237,8 @@ public: /** Writes editor state to xml */ virtual void loadEditorParameters(XmlElement* xml); + /** Syncs parametereditor colors with parameter values */ + void updateParameterButtons(int parameterIndex); protected: /** A pointer to the button that opens the drawer for the ChannelSelector. */ diff --git a/Source/Processors/Editors/ParameterEditor.cpp b/Source/Processors/Editors/ParameterEditor.cpp index 44296d8bd4b21c4aec2814ed3bf460d32b00d282..1e5b9cd28cbea223a9229ca6c9f005e463d5ebef 100755 --- a/Source/Processors/Editors/ParameterEditor.cpp +++ b/Source/Processors/Editors/ParameterEditor.cpp @@ -30,6 +30,8 @@ ParameterEditor::ParameterEditor(GenericProcessor* proc, Parameter& p, Font labe processor = proc; + parameter = &p; + shouldDeactivateDuringAcquisition = p.shouldDeactivateDuringAcquisition; if (p.isBoolean()) @@ -265,6 +267,12 @@ ParameterButton::ParameterButton(var value, int buttonType, Font labelFont) : selectedOverGrad = ColourGradient(Colour(209,162,33),0.0, 5.0f, Colour(190,150,25),0.0, 0.0f, false); + usedByNonActiveGrad = ColourGradient(Colour(200,100,0),0.0,0.0, + Colour(158,95,32),0.0, 20.0f, + false); + usedByNonActiveOverGrad = ColourGradient(Colour(158,95,32),0.0, 5.0f, + Colour(128,70,13),0.0, 0.0f, + false); neutralGrad = ColourGradient(Colour(220,220,220),0.0,0.0, Colour(170,170,170),0.0, 20.0f, false); @@ -282,13 +290,20 @@ void ParameterButton::paintButton(Graphics& g, bool isMouseOver, bool isButtonDo g.setColour(Colours::grey); g.fillPath(outlinePath); - if (getToggleState()) + if (colorState==1) { if (isMouseOver) g.setGradientFill(selectedOverGrad); else g.setGradientFill(selectedGrad); } + else if (colorState==2) + { + if (isMouseOver) + g.setGradientFill(usedByNonActiveOverGrad); + else + g.setGradientFill(usedByNonActiveGrad); + } else { if (isMouseOver) @@ -490,3 +505,51 @@ Path ParameterSlider::makeRotaryPath(double min, double max, double val) return p; } + +void ParameterEditor::channelSelectionUI() +{ + + int numChannels=channelSelector->getNumChannels(); + Array<var> possibleValues=parameter->getPossibleValues(); + if (parameter->isBoolean()) + { + + } + else if (parameter->isContinuous()) + { + + } + else if (parameter->isDiscrete()) + { + std::cout << "Calculating colors for discrete buttons" << std::endl; + + for (int i = 0; i < buttonArray.size(); i++) + { + buttonArray[i]->colorState=0; + + for (int j = 0; j < numChannels; j++) + { + + if (possibleValues[i]==parameter->getValue(j)) + { + + if (channelSelector->getParamStatus(j)) + { + /* Set button as usedbyactive */ + buttonArray[i]->colorState=1; + + } + else if (buttonArray[i]->colorState==0) + { + // Set button as used by non-selected + buttonArray[i]->colorState=2; + } + + } + } + buttonArray[i]->repaint(); + + + } + } +} diff --git a/Source/Processors/Editors/ParameterEditor.h b/Source/Processors/Editors/ParameterEditor.h index 808945b9a438e6a12ebb94355ff74f8689befb5f..bb2fd13589caa3259c9ed30547267babd299cf8c 100755 --- a/Source/Processors/Editors/ParameterEditor.h +++ b/Source/Processors/Editors/ParameterEditor.h @@ -70,7 +70,7 @@ public: void setEnabled(bool t); bool shouldDeactivateDuringAcquisition; bool activationState; - + void channelSelectionUI(); private: Array<ParameterSlider*> sliderArray; @@ -80,6 +80,7 @@ private: Array<int> sliderIdArray; Array<int> checkboxIdArray; + Parameter* parameter; GenericProcessor* processor; ChannelSelector* channelSelector; @@ -106,7 +107,8 @@ public: ~ParameterButton() {} bool isEnabled; - + //Used to mark if unused, usedByActive, or usedby inactive + int colorState; private: void paintButton(Graphics& g, bool isMouseOver, bool isButtonDown); @@ -122,6 +124,8 @@ private: ColourGradient selectedGrad; ColourGradient selectedOverGrad; + ColourGradient usedByNonActiveGrad; + ColourGradient usedByNonActiveOverGrad; ColourGradient neutralGrad; ColourGradient neutralOverGrad; ColourGradient deactivatedGrad; diff --git a/Source/Processors/EventDetector.cpp b/Source/Processors/EventDetector.cpp index 7d25ba8324696583cd147705c1021aa695b09218..5ba62af73c982fbc36a255f9fdd7c1939847f2b4 100755 --- a/Source/Processors/EventDetector.cpp +++ b/Source/Processors/EventDetector.cpp @@ -45,6 +45,7 @@ EventDetector::~EventDetector() void EventDetector::setParameter(int parameterIndex, float newValue) { + editor->updateParameterButtons(parameterIndex); Parameter& p = parameters.getReference(parameterIndex); p.setValue(newValue, 0); diff --git a/Source/Processors/ExampleProcessor.cpp b/Source/Processors/ExampleProcessor.cpp index f2f2115d4dfa4555cbfb2318e60f358895fcd37c..455952dca8c6ea6f4b79ab3581f5601cffa03c82 100644 --- a/Source/Processors/ExampleProcessor.cpp +++ b/Source/Processors/ExampleProcessor.cpp @@ -44,6 +44,7 @@ ExampleProcessor::~ExampleProcessor() void ExampleProcessor::setParameter(int parameterIndex, float newValue) { + editor->updateParameterButtons(parameterIndex); //Parameter& p = parameters.getReference(parameterIndex); //p.setValue(newValue, 0); @@ -51,7 +52,7 @@ void ExampleProcessor::setParameter(int parameterIndex, float newValue) //threshold = newValue; //std::cout << float(p[0]) << std::endl; - + editor->updateParameterButtons(parameterIndex); } void ExampleProcessor::process(AudioSampleBuffer& buffer, diff --git a/Source/Processors/FPGAOutput.cpp b/Source/Processors/FPGAOutput.cpp index b246fbc74dced3d5248c8fb5d676f817905289c1..8f09a95cfe0d593181284bbd68e1e2e0b909391c 100755 --- a/Source/Processors/FPGAOutput.cpp +++ b/Source/Processors/FPGAOutput.cpp @@ -134,9 +134,10 @@ void FPGAOutput::updateSettings() void FPGAOutput::setParameter(int parameterIndex, float newValue) { + editor->updateParameterButtons(parameterIndex); //std::cout << "FPGAOutput received parameter change notification." << std::endl; - + editor->updateParameterButtons(parameterIndex); if (parameterIndex == 0) { TTLchannel = int(newValue); diff --git a/Source/Processors/FilterNode.cpp b/Source/Processors/FilterNode.cpp index 0480f3a37de5c28ffaffe27874c6214eb3306ee9..7b7500f3597404978519241a036fb93ec3c890f2 100755 --- a/Source/Processors/FilterNode.cpp +++ b/Source/Processors/FilterNode.cpp @@ -186,7 +186,6 @@ void FilterNode::setFilterParameters(double lowCut, double highCut, int chan) void FilterNode::setParameter(int parameterIndex, float newValue) { - if (newValue <= 0.01 || newValue >= 10000.0f) return; @@ -230,6 +229,7 @@ void FilterNode::setParameter(int parameterIndex, float newValue) // parameters[1].setValue(newValue, currentChannel); // setFilterParameters(lowCuts[currentChannel], newValue, currentChannel); // } + editor->updateParameterButtons(parameterIndex); } @@ -285,4 +285,4 @@ void FilterNode::loadCustomChannelParametersFromXml(XmlElement* channelInfo, boo } -} \ No newline at end of file +} diff --git a/Source/Processors/GenericProcessor.cpp b/Source/Processors/GenericProcessor.cpp index aac1b089e75bea549f71c3aec3b25d47a29a4bd2..0a7ca4e2d800c7f5841d10a01b28a919028d478c 100755 --- a/Source/Processors/GenericProcessor.cpp +++ b/Source/Processors/GenericProcessor.cpp @@ -69,6 +69,7 @@ Parameter& GenericProcessor::getParameterReference(int parameterIndex) void GenericProcessor::setParameter(int parameterIndex, float newValue) { + editor->updateParameterButtons(parameterIndex); std::cout << "Setting parameter" << std::endl; if (currentChannel >= 0) diff --git a/Source/Processors/GenericProcessor.h b/Source/Processors/GenericProcessor.h index e13ccadb9e29d7ce257394a3e448c07ce5b36d00..e841fb47bf8973f2ad1621d1f5cedc53f767ce56 100755 --- a/Source/Processors/GenericProcessor.h +++ b/Source/Processors/GenericProcessor.h @@ -495,6 +495,9 @@ public: /** Array of Channel objects for all event channels. */ OwnedArray<Channel> eventChannels; + /** Returns total number of channels */ + int totalNumberOfChannels(){return channels.size()+eventChannels.size();} + /** Settings used by most processors. */ struct ProcessorSettings { diff --git a/Source/Processors/LfpDisplayNode.cpp b/Source/Processors/LfpDisplayNode.cpp index e56c434f27c746b32fed15081a9ea9ac7a9ffc7f..16d017aa37180d167ece6f13a2f47c69fb9b5fe4 100755 --- a/Source/Processors/LfpDisplayNode.cpp +++ b/Source/Processors/LfpDisplayNode.cpp @@ -123,6 +123,7 @@ bool LfpDisplayNode::disable() void LfpDisplayNode::setParameter(int parameterIndex, float newValue) { + editor->updateParameterButtons(parameterIndex); //Sets Parameter in parameters array for processor Parameter* parameterPointer=parameters.getRawDataPointer(); parameterPointer=parameterPointer+parameterIndex; diff --git a/Source/Processors/Parameter.cpp b/Source/Processors/Parameter.cpp index 2750d3bd9638bfa2c343e919ae4f39b9465aa610..da0dc4444967296ccc077f52d700c9e914ba7d77 100755 --- a/Source/Processors/Parameter.cpp +++ b/Source/Processors/Parameter.cpp @@ -74,8 +74,6 @@ Parameter::Parameter(const String& name_, Array<var> a, int defaultVal, void Parameter::setValue(float val, int chan) { - // std::cout << "Setting value of " << chan << " to " << val << std::endl; - if (isBoolean()) { if (val > 0.0f) diff --git a/Source/Processors/Parameter.h b/Source/Processors/Parameter.h index 883b6f58bd63960e4933dfc5d7833bb4423fb467..92ee5e7a588b2bfe900b06f5b90ee3ffb075d4ec 100755 --- a/Source/Processors/Parameter.h +++ b/Source/Processors/Parameter.h @@ -105,6 +105,12 @@ public: return values[chan]; } + /** Returns the value of a parameter for a given channel.*/ + var getValue(int chan) + { + return values[chan]; + } + /** Copies a parameter.*/ Parameter& operator=(const Parameter& other); diff --git a/Source/Processors/PhaseDetector.cpp b/Source/Processors/PhaseDetector.cpp index 8fdfff5f5cb0db36281199d72124db33517ca9e9..0cf973e0be04ffc703c9584892c5a8c6327550c7 100644 --- a/Source/Processors/PhaseDetector.cpp +++ b/Source/Processors/PhaseDetector.cpp @@ -58,7 +58,8 @@ AudioProcessorEditor* PhaseDetector::createEditor() void PhaseDetector::setParameter(int parameterIndex, float newValue) { - + editor->updateParameterButtons(parameterIndex); + editor->updateParameterButtons(parameterIndex); if (parameterIndex == 1) { selectedChannel = (int) newValue; diff --git a/Source/Processors/PulsePalOutput.cpp b/Source/Processors/PulsePalOutput.cpp index 22cc978840a615cac5443a47b79ce4ba66060f85..9f51da752b53a8bcdc67bfc7a3ff98d689c5ab79 100644 --- a/Source/Processors/PulsePalOutput.cpp +++ b/Source/Processors/PulsePalOutput.cpp @@ -90,6 +90,7 @@ void PulsePalOutput::handleEvent(int eventType, MidiMessage& event, int sampleNu void PulsePalOutput::setParameter(int parameterIndex, float newValue) { + editor->updateParameterButtons(parameterIndex); //std::cout << "Changing channel " << parameterIndex << " to " << newValue << std::endl; switch (parameterIndex) diff --git a/Source/Processors/RecordNode.cpp b/Source/Processors/RecordNode.cpp index 216466184061108c16c8203ba4396cbcd707a0e3..0d3bfdf1bfa3c1f2b963681b5c5168e1659995dd 100755 --- a/Source/Processors/RecordNode.cpp +++ b/Source/Processors/RecordNode.cpp @@ -286,6 +286,7 @@ String RecordNode::generateDateString() void RecordNode::setParameter(int parameterIndex, float newValue) { + editor->updateParameterButtons(parameterIndex); // 0 = stop recording // 1 = start recording diff --git a/Source/Processors/ReferenceNode.cpp b/Source/Processors/ReferenceNode.cpp index af26f001a67a202b5ed4fe48b9728f27643db489..94bf9bdfde9d44288c677e9289bfc76b42a0e18b 100644 --- a/Source/Processors/ReferenceNode.cpp +++ b/Source/Processors/ReferenceNode.cpp @@ -58,6 +58,7 @@ void ReferenceNode::updateSettings() void ReferenceNode::setParameter(int parameterIndex, float newValue) { + editor->updateParameterButtons(parameterIndex); referenceChannel = (int) newValue; diff --git a/Source/Processors/ResamplingNode.cpp b/Source/Processors/ResamplingNode.cpp index ffc5a7ac01a7e8a5abcb07b7c25c827510ab41f2..7109e6c0a6caecd05120a74a1cfbd87c9c91e052 100755 --- a/Source/Processors/ResamplingNode.cpp +++ b/Source/Processors/ResamplingNode.cpp @@ -56,6 +56,7 @@ AudioProcessorEditor* ResamplingNode::createEditor() void ResamplingNode::setParameter(int parameterIndex, float newValue) { + editor->updateParameterButtons(parameterIndex); if (parameterIndex == 0) { diff --git a/Source/Processors/SignalGenerator.cpp b/Source/Processors/SignalGenerator.cpp index 7c736f09a6e9b899a5b0ff36800de1f63113d694..322860afb5ba94ee575c054ed68db455e905c6b3 100755 --- a/Source/Processors/SignalGenerator.cpp +++ b/Source/Processors/SignalGenerator.cpp @@ -85,9 +85,11 @@ void SignalGenerator::updateSettings() void SignalGenerator::setParameter(int parameterIndex, float newValue) { + editor->updateParameterButtons(parameterIndex); std::cout << "Message received." << std::endl; Parameter* parameterPointer=parameters.getRawDataPointer(); parameterPointer=parameterPointer+parameterIndex; + editor->updateParameterButtons(parameterIndex); if (currentChannel > -1) { diff --git a/Source/Processors/SourceNode.cpp b/Source/Processors/SourceNode.cpp index 9eb6a9a27dcc4330cccb848f242a31115d693f46..c7f0145b3cc0bd4538c1a825dcc3f4cf023236b8 100755 --- a/Source/Processors/SourceNode.cpp +++ b/Source/Processors/SourceNode.cpp @@ -199,6 +199,8 @@ void SourceNode::enabledState(bool t) void SourceNode::setParameter(int parameterIndex, float newValue) { + editor->updateParameterButtons(parameterIndex); + editor->updateParameterButtons(parameterIndex); //std::cout << "Got parameter change notification"; } diff --git a/Source/Processors/SpikeDetector.cpp b/Source/Processors/SpikeDetector.cpp index 16adb1631c67dadb19644b3fdd2b98fbd1a4ce66..1632a4764f659423662c0683c7e20579ad7d413e 100755 --- a/Source/Processors/SpikeDetector.cpp +++ b/Source/Processors/SpikeDetector.cpp @@ -243,6 +243,7 @@ double SpikeDetector::getChannelThreshold(int electrodeNum, int channelNum) void SpikeDetector::setParameter(int parameterIndex, float newValue) { + editor->updateParameterButtons(parameterIndex); if (parameterIndex == 99 && currentElectrode > -1) { *(electrodes[currentElectrode]->thresholds+currentChannelIndex) = newValue; @@ -637,4 +638,4 @@ void SpikeDetector::loadCustomParametersFromXml() } } -} \ No newline at end of file +} diff --git a/Source/Processors/WiFiOutput.cpp b/Source/Processors/WiFiOutput.cpp index 8a75331765acbf8c962ff502cc02f47c545d74f2..a3c5c9e0d32d4f6803b53e5456e39175933bb223 100755 --- a/Source/Processors/WiFiOutput.cpp +++ b/Source/Processors/WiFiOutput.cpp @@ -51,6 +51,7 @@ void WiFiOutput::handleEvent(int eventType, MidiMessage& event, int sampleNum) void WiFiOutput::setParameter(int parameterIndex, float newValue) { + editor->updateParameterButtons(parameterIndex); } diff --git a/Source/UI/EditorViewport.cpp b/Source/UI/EditorViewport.cpp index 89a58974281b4e7ec58e1e158c4cfd96fad08058..04e55b01f274bdc61af46dd63f6b0035410facfc 100755 --- a/Source/UI/EditorViewport.cpp +++ b/Source/UI/EditorViewport.cpp @@ -1318,7 +1318,8 @@ const String EditorViewport::loadState(File fileToLoad) GenericProcessor* p = (GenericProcessor*) lastEditor->getProcessor(); p->loadOrder = loadOrder; p->parametersAsXml = processor; - + //Sets parameters based on XML files + setParametersByXML(p, processor); loadOrder++; if (p->isSplitter() || p->isMerger()) @@ -1382,4 +1383,47 @@ const String EditorViewport::loadState(File fileToLoad) delete xml; return error; } +/* Set parameters based on XML.*/ +void EditorViewport::setParametersByXML(GenericProcessor* targetProcessor, XmlElement* processorXML){ + // Should probably do some error checking to make sure XML is valid, depending on how it treats errors (will likely just not update parameters, but error message could be nice.) + int numberParameters=targetProcessor->getNumParameters(); + // Ditto channels. Not sure how to handle different channel sizes when variable sources (file reader etc. change). Maybe I should check number of channels vs source, but that requires hardcoding when source matters. + //int numChannels=(targetProcessor->channels).size(); + //int numEventChannels=(targetProcessor->eventChannels).size(); + + // Sets channel in for loop + int currentChannel; + + // What the parameter name to change is. + String parameterNameForXML; + String parameterValue; + float parameterFloat; + //float testGrab; + + + forEachXmlChildElementWithTagName(*processorXML, channelXML, "CHANNEL"){ + currentChannel=channelXML->getIntAttribute("name"); + + std::cout <<"currentChannel:"<< currentChannel << std::endl; + // Sets channel to change parameter on + targetProcessor->setCurrentChannel(currentChannel-1); + + forEachXmlChildElement(*channelXML, parameterXML){ + + for (int j = 0; j < numberParameters; ++j){ + parameterNameForXML=targetProcessor->getParameterName(j); + + if (parameterXML->getStringAttribute("name")==parameterNameForXML){ + parameterValue=parameterXML->getAllSubText(); + parameterFloat=parameterValue.getFloatValue(); + targetProcessor->setParameter(j, parameterFloat); + // testGrab=targetProcessor->getParameterVar(j, currentChannel); + std::cout <<"Channel:" <<currentChannel<<"Parameter:" << parameterNameForXML << "Intended Value:" << parameterFloat << std::endl; + } + + } + + } + } +} diff --git a/Source/UI/EditorViewport.h b/Source/UI/EditorViewport.h index dbf6debcdb55db5257f8b86d93d150985eef1e12..c47d94395d0582fed8052f31877bd53f03b53811 100755 --- a/Source/UI/EditorViewport.h +++ b/Source/UI/EditorViewport.h @@ -157,6 +157,9 @@ public: /** Converts information about a splitter or merge to XML. */ XmlElement* switchNodeXml(GenericProcessor*); + /** Sets the parameters of a given processor via XML save files*/ + void setParametersByXML(GenericProcessor*, XmlElement*); + /** Checks whether or not the signal chain scroll buttons need to be activated. */ void checkScrollButtons(int topTab);