Ejemplo n.º 1
0
/*virtual*/ string ComputationNodeBase::FormatOperationPrototype(const string& extraArgs) const
{
    string prototype;
    prototype += msra::strfun::strprintf("%ls = %ls", NodeName().c_str(), OperationName().c_str());

    // arguments of operation
    if (IsLeaf())
        prototype += "()";
    else
    {
        prototype += " (";
        for (size_t i = 0; i < GetNumInputs(); i++)
        {
            const auto& child = m_inputs[i];
            if (i > 0)
                prototype += ", ";

            if (child)
                prototype += msra::strfun::strprintf("%ls", child->NodeName().c_str());
            else
                prototype += "NULL";
        }
        prototype += extraArgs;
        prototype += ")";
    }

    // type (tensor dimensions) of operation
    prototype += " : ";

    if (!IsLeaf())
    {
        //prototype += "(";
        for (size_t i = 0; i < GetNumInputs(); i++)
        {
            const auto& child = m_inputs[i];
            if (i > 0)
                prototype += ", ";

            if (child == nullptr)
            {
                prototype += "NULL";
                continue;
            }
            prototype += child->ShapeDescription().c_str();
        }
        prototype += extraArgs;
        //prototype += ")";
    }

    prototype += msra::strfun::strprintf(" -> %s", ShapeDescription().c_str());

    return prototype;
}
Ejemplo n.º 2
0
// determine the sample tensor dimension to use for operations based on output and all inputs
// 'Sample tensor' means we only consider single samples. If we have an MBLayout, that is the sample layout of a single matrix column.
// TODO: Turn rank into a member variable, and call this method once in validation (currently called for every single ForwardProp/BackpropTo()).
size_t ComputationNodeBase::DetermineElementwiseTensorRank() const
{
    // determine largest tensor dimension amongst the sample shapes of output and the selected inputs
    size_t maxRank = GetSampleLayout().GetRank();
    for (size_t i = 0; i < GetNumInputs(); i++)
    {
        size_t rank = Input(i)->GetSampleLayout().GetRank();
        if (maxRank < rank)
            maxRank = rank;
    }
    return maxRank;
}
Ejemplo n.º 3
0
void CPluginHelper::DumpState(FILE *fp)
{
	_ftprintf(fp, _T("  "));
	m_Engine->DumpStallInfo(fp, m_Name, m_StallInfo);
	_fputts(_T("    In: "), fp);
	int	NumInputs = GetNumInputs();
	for (int InpIdx = 0; InpIdx < NumInputs; InpIdx++) {
		PFRAME InFrame = m_InputFrame[InpIdx];
		if (InFrame != NULL)
			_ftprintf(fp, _T("[%d(%d)] "), InFrame->Idx, InFrame->RefCount);
	}
	_fputtc('\n', fp);
}
void CMackieControlBase::ConfigureParamInput(SONAR_MIXER_STRIP eMixerStrip, DWORD dwStripNum,
											 bool bAllowNone, CMixParam *pParam)
{
	DWORD dwNumInputs = GetNumInputs(eMixerStrip, dwStripNum);

	if (0 == dwNumInputs)
	{
		pParam->ClearBinding();
		return;
	}

	float fMin = bAllowNone ? -1.0f : 0.0f;

	pParam->SetParams(eMixerStrip, dwStripNum, MIX_PARAM_INPUT, 0);
	pParam->SetAttribs(DT_SELECTOR, NO_DEFAULT, 1.0f, fMin, dwNumInputs - 1.0f);
}
Ejemplo n.º 5
0
/*virtual*/ void ComputationNode<ElemType>::DumpNodeInfo(const bool /*printValues*/, const bool printMetadata, File& fstream) const
{
    if (printMetadata)
    {
        fstream << L"\n" + NodeName() + L"=" + OperationName();

        if (!IsLeaf())
        {
            fstream << wstring(L"(");
            for (size_t i = 0; i < GetNumInputs(); i++)
            {
                if (i > 0)
                    fstream << wstring(L",");
                fstream << (Input(i) ? Input(i)->NodeName() : L"NULL");
            }
            fstream << wstring(L")");
        }
    }
}
Ejemplo n.º 6
0
void IPlugProcess::EffectInit()
{
  TRACE;

  if (mPlug)
  {
    AddControl(new CPluginControl_OnOff('bypa', "Master Bypass\nMastrByp\nMByp\nByp", false, true)); // Default to off
    DefineMasterBypassControlIndex(1);

    int paramCount = mPlug->NParams();

    for (int i=0; i<paramCount; i++)
    {
      IParam *p = mPlug->GetParam(i);

      switch (p->Type())
      {
        case IParam::kTypeDouble:
          AddControl(new CPluginControl_Linear(' ld '+i, p->GetNameForHost(), p->GetMin(), p->GetMax(), p->GetStep(), p->GetDefault(), p->GetCanAutomate()));
          break;
        case IParam::kTypeInt:
          AddControl(new CPluginControl_Discrete(' ld '+i, p->GetNameForHost(), (long) p->GetMin(), (long) p->GetMax(), (long) p->GetDefault(), p->GetCanAutomate()));
          break;
        case IParam::kTypeEnum:
        case IParam::kTypeBool:
        {
          std::vector<std::string> displayTexts;
          
          for (int j=0; j<p->GetNDisplayTexts(); j++)
          {
            displayTexts.push_back(p->GetDisplayTextAtIdx(j));
          }

          assert(displayTexts.size());
          AddControl(new CPluginControl_List(' ld '+i, p->GetNameForHost(), displayTexts, (long) p->GetDefault(), p->GetCanAutomate()));
          break;
        }
        default:
          break;
      }

    }

#if PLUG_DOES_MIDI
    if (!IsAS())
    {
      ComponentResult result = noErr;

      Cmn_Int32 requestedVersion = 7;

      std::string midiNodeName(PLUG_NAME" Midi");

      while (requestedVersion)
      {
        result = DirectMidi_RegisterClient(requestedVersion, this, reinterpret_cast<Cmn_UInt32>(this), (void **)&mDirectMidiInterface);

        if (result == noErr && mDirectMidiInterface != NULL)
        {
          mDirectMidiInterface->CreateRTASBufferedMidiNode(0, const_cast<char *>(midiNodeName.c_str()), 1);

          break;
        }

        requestedVersion--;
      }
    }
#endif

    mPlug->SetIO(GetNumInputs(), GetNumOutputs());
    mPlug->SetSampleRate(GetSampleRate());
    mPlug->Reset();
  }
}
Ejemplo n.º 7
0
bool CPluginHelper::Work()
{
	DWORD	Timeout = m_Engine->GetFrameTimeout() * m_Plugin->GetHelperCount();
	int	FrameLength = m_Engine->GetFrameLength();
	while (1) {
		m_IdleEvent.Set();	// signal idleness
		if (!WaitForEvent(m_InputEvent, Timeout))	// wait for input
			return(!m_KillFlag);
		int	parms = m_Plugin->GetParmCount();
		for (int i = 0; i < parms; i++) {	// for each plugin parameter
			if (m_ParmTarget[i] != m_ParmShadow[i]) {	// if target differs from shadow
				m_FFInst.SetParam(i, m_ParmTarget[i]);	// update freeframe plugin
				m_ParmShadow[i] = m_ParmTarget[i];	// update shadow
			}
		}
		ASSERT(m_InputFrame[0] != NULL);	// sanity check
		int	NumInputs = GetNumInputs();
		if (m_Plugin->UsingProcessCopy()) {	// if using process copy
			QREAD(m_Engine->GetFreeQueue(), m_OutFrame);	// get output frame
			if (!m_Plugin->GetBypass()) {	// if not bypassed
				for (int InpIdx = 0; InpIdx < NumInputs; InpIdx++)
					m_InFrameBuf[InpIdx] = m_InputFrame[InpIdx]->Buf;
				ProcessFrameCopyStruct	pfcs;
				pfcs.InputFrames = m_InFrameBuf.GetData();
				pfcs.numInputFrames = NumInputs;
				pfcs.OutputFrame = m_OutFrame->Buf;
				AddProcessHistorySample(TRUE);
				m_FFInst.ProcessFrameCopy(pfcs);	// process frame
				AddProcessHistorySample(FALSE);
			} else	// bypassed; copy first input to output
				memcpy(m_OutFrame->Buf, m_InputFrame[0], FrameLength);
			if (!WaitForEvent(m_OutputEvent, Timeout))	// wait for output token
				return(!m_KillFlag);
			// write output frame to output queues
			int	outs = m_Plugin->GetOutputCount();
			ASSERT(outs > 0);	// if no outputs, we shouldn't be running
			m_OutFrame->RefCount = outs;	// set output refs
			for (int OutIdx = 0; OutIdx < outs; OutIdx++) {
				QOUTPUT(m_Plugin->GetOutputQueue(OutIdx), m_OutFrame);
			}
			m_OutFrame = NULL;
			// free input frames
			for (int InpIdx = 0; InpIdx < NumInputs; InpIdx++) {
				if (!InterlockedDecrement(&m_InputFrame[InpIdx]->RefCount)) {
					QWRITE(m_Engine->GetFreeQueue(), m_InputFrame[InpIdx]);
				}
				m_InputFrame[InpIdx] = NULL;	// for monitoring
			}
		} else {	// in place
			if (!m_Plugin->GetBypass()) {	// if not bypassed
				AddProcessHistorySample(TRUE);
				m_FFInst.ProcessFrame(m_InputFrame[0]->Buf);	// process frame
				AddProcessHistorySample(FALSE);
			}
			if (!WaitForEvent(m_OutputEvent, Timeout))	// wait for output token
				return(!m_KillFlag);
			// write frame to output queues
			int	outs = m_Plugin->GetOutputCount();
			ASSERT(outs > 0);	// if no outputs, we shouldn't be running
			m_InputFrame[0]->RefCount = outs;	// set output refs
			for (int OutIdx = 0; OutIdx < outs; OutIdx++) {
				QOUTPUT(m_Plugin->GetOutputQueue(OutIdx), m_InputFrame[0]);
			}
			m_InputFrame[0] = NULL;	// for monitoring
		}
		m_NextOutputEvent->Set();	// pass output token
	}
}