Ejemplo n.º 1
0
    PinComponent (FilterGraph& graph_,
                  const uint32 filterID_, const int index_, const bool isInput_)
        : filterID (filterID_),
          index (index_),
          isInput (isInput_),
          graph (graph_)
    {
        const AudioProcessorGraph::Node::Ptr node (graph.getNodeForId (filterID_));

        if (node != nullptr)
        {
            String tip;

            if (isInput)
                tip = node->getProcessor()->getInputChannelName (index_);
            else
                tip = node->getProcessor()->getOutputChannelName (index_);

            if (tip.isEmpty())
            {
                if (index_ == FilterGraph::midiChannelNumber)
                    tip = isInput ? "Midi Input" : "Midi Output";
                else
                    tip = (isInput ? "Input " : "Output ") + String (index_ + 1);
            }

            setTooltip (tip);
        }

        setSize (16, 16);
    }
void PMixInterpolationSpaceLayout::updateComponents()
{
//  for (int i = getNumChildComponents(); --i >= 0;)
//  {
//    if (InterpolationSpacePreset* const pc = dynamic_cast <InterpolationSpacePreset*> (getChildComponent (i)))
//      pc->update();
//  }
  
  for (int i = audioEngine.getDoc().getNumNodes(); --i >= 0;)
  {
    const AudioProcessorGraph::Node::Ptr f (audioEngine.getDoc().getNode (i));
    
    if (!InternalPluginFormat::isInternalFormat(f->getProcessor()->getName()))
    {
      Array<InterpolationSpacePreset*> comps;
      getComponentsForNode(f->nodeID, comps);
      Array<var>* presets = f->properties.getVarPointer("presets")->getArray();
      
      // if the number of presets for this node has changed then delete the components and re-create
      if (comps.size() != presets->size())
      {
        for (int componentIdx = 0; componentIdx<comps.size(); componentIdx++)
        {
          removeChildComponent(comps[componentIdx]);
          delete comps[componentIdx];
        }
        
        for (int presetIdx = 0; presetIdx < presets->size(); presetIdx++)
        {
          DynamicObject* obj = presets->getReference(presetIdx).getDynamicObject();
          
          String label = obj->getProperty("name");
          InterpolationSpacePreset* const comp = new InterpolationSpacePreset(audioEngine, label, f->nodeID, obj->getProperty("uid"), audioEngine.getDoc().getNodeColour(f->nodeID)  );
          String componentID;
          componentID << "p." << (int) f->nodeID << "." << presetIdx;
          comp->setComponentID(componentID);
          float r = MIN_RADIUS + (RADIUS_RANGE * (float) obj->getProperty("radius"));
          float x = getWidth() * (float) obj->getProperty("x");
          float y = getHeight() * (float) obj->getProperty("y");
          
          comp->setSize(r, r);
          comp->setCentrePosition(x, y);
          comp->update();
          
          addAndMakeVisible (comp);
        }
      }
    }
    
  }
}
Ejemplo n.º 3
0
void ParamView::changeListenerCallback (ChangeBroadcaster* source)
{
  bool deletedNodes = false;
  
  for (int i = 0; i < sectionNodes.size(); i++) 
  {
    const AudioProcessorGraph::Node::Ptr f (audioEngine.getDoc().getNodeForId(sectionNodes[i]));
    
    if (f == nullptr) 
    {
      deletedNodes = true;
    }
  }
  
  if (deletedNodes) 
  {
    sectionNodes.clear();
    panel.clear();
  }
  
  for (int i = audioEngine.getDoc().getNumFilters(); --i >= 0;)
  {
    const AudioProcessorGraph::Node::Ptr f (audioEngine.getDoc().getNode (i));
    
    if   (f->getProcessor()->getName() != "Audio Input"
          && f->getProcessor()->getName() != "Audio Output" 
          && f->getProcessor()->getName() != "Midi Input" 
          && f->getProcessor()->getName() != "Midi Output") 
    {
      if (!sectionNodes.contains(f->nodeId)) 
      {
        sectionNodes.add(f->nodeId);
        addEditor(f->getProcessor());
      }
    }
  }
}
Ejemplo n.º 4
0
void PMixDocument::createNodeFromXml (XmlElement& xml, const String& newSourceCode)
{
  PluginDescription pd;
  
  forEachXmlChildElement (xml, e)
  {
    if (pd.loadFromXml (*e))
      break;
  }
  
  String errorMessage;
  
  AudioPluginInstance* instance = audioEngine.createPluginInstance(pd, errorMessage);
  
  jassert(instance != nullptr);
  
  if (pd.pluginFormatName == "FAUST")
  {
    FaustAudioPluginInstance* faustProc = dynamic_cast<FaustAudioPluginInstance*>(instance);
    faustProc->initialize(getLibraryPath(), drawPath);
    
    if (newSourceCode.length())
      faustProc->setSourceCode(newSourceCode, true);
    
    // TODO: this is a bit wrong!
    faustProc->prepareToPlay(44100., 8192);
    
//    xml.setAttribute("numInputs", faustProc->getNumInputChannels());
//    xml.setAttribute("numOutputs", faustProc->getNumOutputChannels()); ???
  }
  
  AudioProcessorGraph::Node::Ptr node (audioEngine.getGraph().addNode (instance, xml.getIntAttribute ("uid")));
  
  if (!newSourceCode.length())
  {
    if (const XmlElement* const state = xml.getChildByName ("STATE"))
    {
      MemoryBlock m;
      m.fromBase64Encoding (state->getAllSubText());
      
      node->getProcessor()->setStateInformation (m.getData(), (int) m.getSize());
    }
  }
  
  node->properties.set ("x", xml.getDoubleAttribute ("x"));
  node->properties.set ("y", xml.getDoubleAttribute ("y"));
  node->properties.set ("uiLastX", xml.getIntAttribute ("uiLastX"));
  node->properties.set ("uiLastY", xml.getIntAttribute ("uiLastY"));
  node->properties.set ("uiStatus", xml.getIntAttribute ("uiStatus"));

  // presets etc for faust & plugin nodes
  if(!InternalPluginFormat::isInternalFormat(pd.name))
  {
    node->properties.set ("colour", xml.getStringAttribute ("colour"));
    node->properties.set ("iposx", xml.getDoubleAttribute ("iposx"));
    node->properties.set ("iposy", xml.getDoubleAttribute ("iposy"));
    if (const XmlElement* const params = xml.getChildByName ("PARAMS"))
    {
      var vparams = JSON::parse(params->getAllSubText());
      node->properties.set ("params", vparams);
    }
    
    Array<var> presetsArr;
    
    forEachXmlChildElement (xml, e)
    {
      if (e->hasTagName ("PRESET"))
      {
        DynamicObject* obj = new DynamicObject();
        obj->setProperty("name", e->getStringAttribute("name"));
        obj->setProperty("x", e->getDoubleAttribute("x"));
        obj->setProperty("y", e->getDoubleAttribute("y"));
        obj->setProperty("radius", e->getDoubleAttribute("radius"));
        obj->setProperty("hidden", e->getBoolAttribute("hidden"));
        //  obj->setProperty("distance", e->getDoubleAttribute("distance"));
        obj->setProperty("coeff", e->getDoubleAttribute("coeff"));
        
        var vparams = JSON::parse(e->getAllSubText());
        obj->setProperty("state", vparams);
        obj->setProperty("uid", e->getIntAttribute("uid"));
        
        var preset = var(obj);
        presetsArr.add(preset);
      }
    }
    
    node->properties.set("presets", presetsArr);
  }
Ejemplo n.º 5
0
void NodeComponent::update()
{
  const AudioProcessorGraph::Node::Ptr f (audioEngine.getDoc().getNodeForId (nodeID));
  
  if (f == nullptr)
  {
    delete this;
    return;
  }

  numIns = f->getProcessor()->getTotalNumInputChannels();
  if (f->getProcessor()->acceptsMidi())
    ++numIns;
  
  numOuts = f->getProcessor()->getTotalNumOutputChannels();
  if (f->getProcessor()->producesMidi())
    ++numOuts;
  
  FaustAudioPluginInstance* faustProc = dynamic_cast<FaustAudioPluginInstance*>(f->getProcessor());
  
  if (faustProc)
    highlight = faustProc->getHighlight();

  int w = 10;
  int h = 50;

  // Update width based on number of I/O
  w = jmax (w, PINS_LEFT_OFFSET + ((jmax (numIns, numOuts) + 1) * OFFSET_BETWEEN_PINS));
  
  String name = f->getProcessor()->getName();
  
  setName (name);

  if (numIns != numInputs || numOuts != numOutputs || editor == nullptr)
  {
    numInputs = numIns;
    numOutputs = numOuts;
    
    deleteAllChildren();
    
    addAndMakeVisible(nodeName = new Label(name, name));
    nodeName->setJustificationType(Justification::centred);
    nodeName->setInterceptsMouseClicks(false, false);
    nodeName->setFont(font);
    
    w = jmax (w, nodeName->getFont().getStringWidth(name) + 15);
  
    if(!InternalPluginFormat::isInternalFormat(name) && f->getProcessor()->getNumParameters() > 0)
    {
      int uiStatus = f->properties["uiStatus"];
      
      if(uiStatus == kUIStatusEmbed)
      {
        addAndMakeVisible(editor = new PMixGenericAudioProcessorEditor (audioEngine, f->getProcessor(), f->nodeID));
        w = jmax (w, editor->getWidth() + 20 );
        
        if (editor->getContentHeight() > 300) {
          editor->setSize(editor->getWidth(), 100);
        }
        
        h += jmin (320, editor->getContentHeight() + 20);
      }
    }
    
    setSize (w, h);

    int i;
    for (i = 0; i < f->getProcessor()->getTotalNumInputChannels(); ++i)
      addAndMakeVisible (new PinComponent (audioEngine, nodeID, i, true));
    
    if (f->getProcessor()->acceptsMidi())
      addAndMakeVisible (new PinComponent (audioEngine, nodeID, PMixDocument::midiChannelNumber, true));
    
    for (i = 0; i < f->getProcessor()->getTotalNumOutputChannels(); ++i)
      addAndMakeVisible (new PinComponent (audioEngine, nodeID, i, false));
    
    if (f->getProcessor()->producesMidi())
      addAndMakeVisible (new PinComponent (audioEngine, nodeID, PMixDocument::midiChannelNumber, false));
    
    resized();
  }
  
  {
    double x, y;
    audioEngine.getDoc().getNodePosition (nodeID, x, y);
    setCentreRelative ((float) x, (float) y);
  }
    
  if(faustProc != nullptr) {
    if(faustProc->getCompilerMessage() != String::empty)
      bubbleMessage(faustProc->getCompilerMessage());
  }
}
Ejemplo n.º 6
0
    void update()
    {
        const AudioProcessorGraph::Node::Ptr f (graph.getNodeForId (filterID));

        if (f == nullptr)
        {
            delete this;
            return;
        }

        numIns = f->getProcessor()->getNumInputChannels();
        if (f->getProcessor()->acceptsMidi())
            ++numIns;

        numOuts = f->getProcessor()->getNumOutputChannels();
        if (f->getProcessor()->producesMidi())
            ++numOuts;

        int w = 100;
        int h = 60;

        w = jmax (w, (jmax (numIns, numOuts) + 1) * 20);

        const int textWidth = font.getStringWidth (f->getProcessor()->getName());
        w = jmax (w, 16 + jmin (textWidth, 300));
        if (textWidth > 300)
            h = 100;

        setSize (w, h);

        setName (f->getProcessor()->getName());

        {
            double x, y;
            graph.getNodePosition (filterID, x, y);
            setCentreRelative ((float) x, (float) y);
        }

        if (numIns != numInputs || numOuts != numOutputs)
        {
            numInputs = numIns;
            numOutputs = numOuts;

            deleteAllChildren();

            int i;
            for (i = 0; i < f->getProcessor()->getNumInputChannels(); ++i)
                addAndMakeVisible (new PinComponent (graph, filterID, i, true));

            if (f->getProcessor()->acceptsMidi())
                addAndMakeVisible (new PinComponent (graph, filterID, FilterGraph::midiChannelNumber, true));

            for (i = 0; i < f->getProcessor()->getNumOutputChannels(); ++i)
                addAndMakeVisible (new PinComponent (graph, filterID, i, false));

            if (f->getProcessor()->producesMidi())
                addAndMakeVisible (new PinComponent (graph, filterID, FilterGraph::midiChannelNumber, false));

            resized();
        }
    }