Esempio n. 1
0
    MetaLinkTest()
            : m_master(m_factory.getOrCreateHandle("[Master]"), "[Master]"),
              m_headphone(m_factory.getOrCreateHandle("[Headphone]"), "[Headphone]") {
        mixxx::Time::setTestMode(true);
        mixxx::Time::setTestElapsedTime(mixxx::Duration::fromNanos(0));
        m_pEffectsManager->registerInputChannel(m_master);
        m_pEffectsManager->registerInputChannel(m_headphone);
        registerTestBackend();

        EffectChainPointer pChain(new EffectChain(m_pEffectsManager.data(),
                                                  "org.mixxx.test.chain1"));
        int iRackNumber = 0;
        int iChainNumber = 0;
        int iEffectNumber = 0;

        StandardEffectRackPointer pRack = m_pEffectsManager->addStandardEffectRack();
        m_pChainSlot = pRack->getEffectChainSlot(iChainNumber);
        m_pChainSlot->loadEffectChainToSlot(pChain);
        m_pEffectSlot = m_pChainSlot->getEffectSlot(iEffectNumber);

        QString group = StandardEffectRack::formatEffectSlotGroupString(
            iRackNumber, iChainNumber, iEffectNumber);

        EffectManifest manifest;
        manifest.setId("org.mixxx.test.effect");
        manifest.setName("Test Effect");
        manifest.setMetaknobDefault(0.0);

        EffectManifestParameter* low = manifest.addParameter();
        low->setId("low");
        low->setName(QObject::tr("Low"));
        low->setDescription(QObject::tr("Gain for Low Filter"));
        low->setControlHint(EffectManifestParameter::ControlHint::KNOB_LINEAR);
        low->setSemanticHint(EffectManifestParameter::SemanticHint::UNKNOWN);
        low->setUnitsHint(EffectManifestParameter::UnitsHint::UNKNOWN);
        low->setNeutralPointOnScale(0.25);
        low->setDefault(1.0);
        low->setMinimum(0);
        low->setMaximum(1.0);

        registerTestEffect(manifest, false);

        // Check the controls reflect the state of their loaded effect.
        EffectPointer pEffect = m_pEffectsManager->instantiateEffect(manifest.id());

        m_pEffectSlot->loadEffect(pEffect, false);

        QString itemPrefix = EffectParameterSlot::formatItemPrefix(0);

        m_pControlValue.reset(new ControlProxy(group, itemPrefix));

        m_pControlLinkType.reset(new ControlProxy(group,
                itemPrefix + QString("_link_type")));

        m_pControlLinkInverse.reset(new ControlProxy(group,
                itemPrefix + QString("_link_inverse")));
    }
Esempio n. 2
0
// static
EffectChainPointer EffectChain::createFromXml(EffectsManager* pEffectsManager,
                                        const QDomElement& element) {
    if (!element.hasChildNodes()) {
        // An empty element <EffectChain/> is treated as an ejected Chain (null)
        return EffectChainPointer();
    }

    QString id = XmlParse::selectNodeQString(element,
                                             EffectXml::ChainId);
    QString name = XmlParse::selectNodeQString(element,
                                               EffectXml::ChainName);
    QString description = XmlParse::selectNodeQString(element,
                                                      EffectXml::ChainDescription);
    QString insertionTypeStr = XmlParse::selectNodeQString(element,
                                                           EffectXml::ChainInsertionType);

    EffectChainPointer pChain(new EffectChain(pEffectsManager, id));
    pChain->setName(name);
    pChain->setDescription(description);
    InsertionType insertionType = insertionTypeFromString(insertionTypeStr);
    if (insertionType != NUM_INSERTION_TYPES) {
        pChain->setInsertionType(insertionType);
    }

    QDomElement effects = XmlParse::selectElement(element, EffectXml::EffectsRoot);
    QDomNodeList effectChildren = effects.childNodes();

    for (int i = 0; i < effectChildren.count(); ++i) {
        QDomNode effect = effectChildren.at(i);
        if (effect.isElement()) {
            EffectPointer pEffect = Effect::createFromXml(
                pEffectsManager, effect.toElement());
            pChain->addEffect(pEffect);
        }
    }

    return pChain;
}
Esempio n. 3
0
int ElPoly::ProjectionF(int NBin,int Coord){
  if(Coord > 4 || Coord <0) return 1;
  int NType = 5;
  double *Plot = (double *)calloc(NBin*NBin*NType,sizeof(double));
  double InvNBin = 1./(double)NBin;
  double RefPos[3] = {0.,0.,0.};
  for(int d=0;d<3;d++){
    RefPos[d] = Nano->Pos[d]-.5*pEdge(d);
  }
  if(Coord == 3){
    RefPos[0]=pCm(0);RefPos[1]=pCm(1);RefPos[2]=pCm(2);
  }
  SetEdge(.5*MIN(pEdge(CLat1),pEdge(CLat2)),3);
  for(int f=NFile[0];f<NFile[1];f++){
    Processing(f);
    OpenRisk(cFile[f],BF_PART);
    ShiftSys(SHIFT_CM);
    int NPlot = 0;
    //---Projects-against-one-coordinate--
    if(Coord < 3){
      int coord1 = (Coord+1)%3;
      int coord2 = (Coord+2)%3;
      for(int p=0;p<pNPart();p++){
	double x = pPos(p,coord1) - RefPos[coord1];
	x -= floor(x*pInvEdge(coord1))*pEdge(coord1);
	double y = pPos(p,coord2) - RefPos[coord2];
	y -= floor(y*pInvEdge(coord2))*pEdge(coord2);
	int v = (int)(NBin*x*pInvEdge(coord1));
	if( v < 0 || v >= NBin) continue;
	int vv = (int)(NBin*y*pInvEdge(coord2));
	if( vv < 0 || vv >= NBin) continue;
	int t = pType(p);
	if( t < 0 || t > 3) continue;
	if( CHAIN_IF_TYPE(Ch[pChain(p)].Type,CHAIN_ADDED) )
	  Plot[(v*NBin+vv)*NType+3] += 1.;
	Plot[(v*NBin+vv)*NType+t] += 1.;
	if(p<pNPart()-1)
	  if(pType(p+1) == 1 && pType(p) == 0)
	    Plot[(v*NBin+vv)*NType+4] += 1.;	  
      }
    }
    //---Projects-against-the-radial-coordinate--
    else if(Coord == 3){
      SetEdge(.5*MAX((pEdge(CLat1)),(pEdge(CLat2))),3);
      for(int p=0;p<pNPart();p++){
	double x = pPos(p,CLat1) - RefPos[CLat1];
	x -= floor(x*pInvEdge(CLat1))*pEdge(CLat1);
	double y = pPos(p,CLat2) - RefPos[CLat2];
	y -= floor(y*pInvEdge(CLat2))*pEdge(CLat2);
	double z = pPos(p,CNorm) - RefPos[CNorm];
	z -= floor(z*pInvEdge(CNorm))*pEdge(CNorm);
	double r = sqrt(SQR(x)+SQR(y));
	int v = (int)(NBin*r*pInvEdge(3));
	if( v < 0 || v >= NBin) continue;
	int vv = (int)(NBin*pPos(p,CNorm)/pEdge(CNorm));
	if( vv < 0 || vv >= NBin) continue;
	int t = pType(p);
	if( t < 0 || t > 3) continue;
	if( CHAIN_IF_TYPE(Ch[pChain(p)].Type,CHAIN_ADDED) )
	  Plot[(v*NBin+vv)*NType+3] += 1.;
	Plot[(v*NBin+vv)*NType+t] += 1.;
	if(p<pNPart()-1)
	  if(pType(p+1) == 1 && pType(p) == 0)
	    Plot[(v*NBin+vv)*NType+4] += 1.;	  
      }
    }
  }
  printf("\n");
  //-----writes-the-output-file-------------------
  FILE *FileToWrite = NULL;
  FileToWrite = fopen("Projection.xyd","w");
  fprintf(FileToWrite,"#l(%lf %lf %lf) v[%d] d[%s]\n",pEdge(CLat1),pEdge(CLat2),pEdge(CNorm),NBin,ChooseDraw(EL_QUAD1));
  int coord1 = (Coord+1)%3;
  int coord2 = (Coord+2)%3;
  if(Coord == 3){
    coord1 = 3;
    coord2 = CNorm;
  }
  double Max[NType];
  for(int t=0;t<NType;t++){
    Max[t] = Plot[t];
    for(int v=0;v<NBin;v++)
      for(int vv=0;vv<NBin;vv++)
	if(Max[t] < Plot[(v*NBin+vv)*NType+t]) Max[t] = Plot[(v*NBin+vv)*NType+t];
    Max[t] = Max[t] <= 0. ? 1. : Max[t];
  }
  //for(int t=0;t<NType-1;t++){
  for(int t=0;t<1;t++){
    for(int v=0;v<NBin;v++){
      for(int vv=0;vv<NBin;vv++){
	int p = (v*NBin+vv)*NType+t;
	int c = 0;
	if(Plot[p] < .1) continue;
	double x = (v)*InvNBin*pEdge(CLat1);
	double y = (vv)*InvNBin*pEdge(CLat2);
	double dens = Plot[p]/Max[t]*5.+.5*pEdge(CNorm);
	double NanoAdded = 0.;//Plot[p]/Max[t]+Plot[((v*NBin+vv)*NType+3]/Max[3];
	double Phob = t == 0 ? Plot[(v*NBin+vv)*NType+0]/Max[0] : 0.;
	double Phil = t == 1 ? Plot[(v*NBin+vv)*NType+1]/Max[1] : 0.;
	fprintf(FileToWrite,"{t[%d %d %d] x(%lf %lf %lf) v(%lf %lf %lf)}\n",p,c,t,x,y,dens,NanoAdded,Phob,Phil);
      }
    } 
  }
  free(Plot);
  fclose(FileToWrite);
  return 0;
}