Skip to content
Snippets Groups Projects
Select Git revision
  • bb2f8aa87af6bab56616f323786018678d486fa4
  • master default protected
2 results

7-echo.rs

Blame
  • PluginEditor.h 4.01 KiB
    /*
      ==============================================================================
    
        This file contains the basic framework code for a JUCE plugin editor.
    
      ==============================================================================
    */
    
    #pragma once
    
    #include <JuceHeader.h>
    #include "PluginProcessor.h"
    
    //==============================================================================
    /**
    */
    class Test2AudioProcessorEditor : public juce::AudioProcessorEditor, public juce::Slider::Listener, private juce::Timer
    {
    public:
      Test2AudioProcessorEditor(Test2AudioProcessor &);
      ~Test2AudioProcessorEditor();
    
      //==============================================================================
      void paint(juce::Graphics &) override;
      void resized() override;
    
    private:
      // This reference is provided as a quick way for your editor to
      // access the processor object that created it.
      Test2AudioProcessor &processor;
      juce::Slider posSlider;
    
      void sliderValueChanged(juce::Slider *slider) override
      {
        DBG("slider changed");
        // if (slider == &posSlider)
        //   durationSlider.setValue(1.0 / frequencySlider.getValue(), dontSendNotification);
        // else if (slider == &durationSlider)
        //   frequencySlider.setValue(1.0 / durationSlider.getValue(), dontSendNotification);
      }
    
      // is this the way
      juce::Label positionLabel, timecodeDisplayLabel; // = juce::Label("Position", "Position : 0");
      // or something like
      //juce::Label positionLabel = {"Position"};
    
      // should it be here or in the cpp file
      // do we even need a cpp file, seems easier to do everything in the
      // class declaration as we do not need to repeat the type name for each
      // member function.
      void timerCallback() override
      {
        positionLabel.setText("Pos : " + std::to_string(processor.position), juce::dontSendNotification);
        updateTimecodeDisplay(processor.lastPosInfo);
        repaint();
      }
      // Updates the text in our position label.
      void updateTimecodeDisplay(juce::AudioPlayHead::CurrentPositionInfo pos)
      {
        juce::MemoryOutputStream displayText;
    
        displayText << "[" << juce::SystemStats::getJUCEVersion() << "]   "
                    << juce::String(pos.bpm, 2) << " bpm, "
                    << pos.timeSigNumerator << '/' << pos.timeSigDenominator
                    << "  -  " << timeToTimecodeString(pos.timeInSeconds)
                    << "  -  " << quarterNotePositionToBarsBeatsString(pos.ppqPosition, pos.timeSigNumerator, pos.timeSigDenominator);
    
        if (pos.isRecording)
          displayText << "  (recording)";
        else if (pos.isPlaying)