Guest User

Untitled

a guest
Aug 12th, 2016
77
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.51 KB | None
  1. the code of the button event
  2.  
  3. the code of the plugin can be found at https://drive.google.com/drive/folders/0B_B0Mi9z64F4Q3F4ZDJhbm9nRjg
  4. SpikeDetectorEditor.cpp and SpikeDetectorEditor.h concerns with gui and button behaviour,,
  5. so i believe its better to check them first
  6. SpikeDetector.cpp and SpikeDetector.h contains the functionality of these buttons
  7. i am facing problem in erratic behaviour of one button DTHR,,
  8. here is the code of button Event for the particualr button,
  9. guys, any suggestion is welcome,,
  10. will changing the button to a checkbox help ,, but i think juce does not provide functionality of a checkbox,,
  11.  
  12. a sister thread can be found at
  13. https://forum.juce.com/t/weird-gui-and-geometry-errors-while-implementing-a-circular-buffer/18656/2
  14.  
  15. else if(button == electrodeEditorButtons[3]) // DYNAMIC THRESH
  16. {
  17.  
  18. SpikeDetector* processor = (SpikeDetector*) getProcessor();
  19. Array<SimpleElectrode*> electrodes;
  20. processor->getElectrodes(electrodes);
  21.  
  22. if(button->getToggleState())
  23. {
  24. std::cout<<" setting dynamic threshold for all channels"<<std::endl;
  25. // need to think of cases when Edit or delete is clicked and so on
  26.  
  27. std::cout<<"DTHR button clicked ,, setting dynamic threshold for all elctrodes,, and all channels"<<std::endl;
  28. for (int i = 0; i < electrodes.size(); i++)
  29. {
  30. for(int chan = 0; chan < electrodes[i]->numChannels; chan++)
  31. {
  32. int theChannel = *(electrodes[i]->channels + chan);
  33. float dynamicThreshold = processor->getDynamicThreshold(theChannel);
  34. processor->setChannelThreshold(i, theChannel, dynamicThreshold);
  35. std::cout<<"In DTHR button loop Setting electrode number " << i <<" channel number "<< theChannel << "the dynamic threshold is "<< dynamicThreshold<<std::endl;
  36. }
  37. }
  38. }
  39.  
  40. else if(!button->getToggleState())
  41. {
  42. std::cout<<"setting default threshold for all channels"<<std::endl;
  43.  
  44. float defaultThreshold = processor->detectorBuffers.defthresh;
  45.  
  46. for (int i = 0; i < electrodes.size(); i++)
  47. {
  48. for(int chan = 0; chan < electrodes[i]->numChannels; chan++)
  49. {
  50. processor->setChannelThreshold(i, *(electrodes[i]->channels+chan), defaultThreshold);
  51. }
  52. }
  53.  
  54.  
  55. }
  56. }
RAW Paste Data Copied