void
DelayBuffer::ReadChannel(const double aPerFrameDelays[WEBAUDIO_BLOCK_SIZE],
                         AudioBlock* aOutputChunk, uint32_t aChannel,
                         ChannelInterpretation aChannelInterpretation)
{
  if (!mChunks.Length()) {
    float* outputChannel = aOutputChunk->ChannelFloatsForWrite(aChannel);
    PodZero(outputChannel, WEBAUDIO_BLOCK_SIZE);
    return;
  }

  ReadChannels(aPerFrameDelays, aOutputChunk,
               aChannel, 1, aChannelInterpretation);
}
Beispiel #2
0
void
DelayBuffer::Read(const double aPerFrameDelays[WEBAUDIO_BLOCK_SIZE],
                  AudioChunk* aOutputChunk,
                  ChannelInterpretation aChannelInterpretation)
{
  int chunkCount = mChunks.Length();
  if (!chunkCount) {
    aOutputChunk->SetNull(WEBAUDIO_BLOCK_SIZE);
    return;
  }

  // Find the maximum number of contributing channels to determine the output
  // channel count that retains all signal information.  Buffered blocks will
  // be upmixed if necessary.
  //
  // First find the range of "delay" offsets backwards from the current
  // position.  Note that these may be negative for frames that are after the
  // current position (including i).
  double minDelay = aPerFrameDelays[0];
  double maxDelay = minDelay;
  for (unsigned i = 1; i < WEBAUDIO_BLOCK_SIZE; ++i) {
    minDelay = std::min(minDelay, aPerFrameDelays[i] - i);
    maxDelay = std::max(maxDelay, aPerFrameDelays[i] - i);
  }

  // Now find the chunks touched by this range and check their channel counts.
  int oldestChunk = ChunkForDelay(int(maxDelay) + 1);
  int youngestChunk = ChunkForDelay(minDelay);

  uint32_t channelCount = 0;
  for (int i = oldestChunk; true; i = (i + 1) % chunkCount) {
    channelCount = GetAudioChannelsSuperset(channelCount,
                                            mChunks[i].ChannelCount());
    if (i == youngestChunk) {
      break;
    }
  }

  if (channelCount) {
    AllocateAudioBlock(channelCount, aOutputChunk);
    ReadChannels(aPerFrameDelays, aOutputChunk,
                 0, channelCount, aChannelInterpretation);
  } else {
    aOutputChunk->SetNull(WEBAUDIO_BLOCK_SIZE);
  }

  // Remember currentDelayFrames for the next ProcessBlock call
  mCurrentDelay = aPerFrameDelays[WEBAUDIO_BLOCK_SIZE - 1];
}
Beispiel #3
0
void
DelayBuffer::ReadChannel(const double aPerFrameDelays[WEBAUDIO_BLOCK_SIZE],
                         const AudioChunk* aOutputChunk, uint32_t aChannel,
                         ChannelInterpretation aChannelInterpretation)
{
  if (!mChunks.Length()) {
    float* outputChannel = static_cast<float*>
      (const_cast<void*>(aOutputChunk->mChannelData[aChannel]));
    PodZero(outputChannel, WEBAUDIO_BLOCK_SIZE);
    return;
  }

  ReadChannels(aPerFrameDelays, aOutputChunk,
               aChannel, 1, aChannelInterpretation);
}
bool CKADInfo::load(
    CGT_CDiagMsg*   pdm,
	const TCHAR*    pszKADFileAndPath,
	const TCHAR*    pszTargetType,
    unsigned long   ulTrgVer
)
{
    long                i, o;
    long                len;
    long                len2;
    long                len3;
    IXMLDOMNodeList*    pNList;
    IXMLDOMNodeList*    pNList2;
    IXMLDOMNodeList*    pNList3;
    IXMLDOMNode*        pNode;
    IXMLDOMNode*        pNode2;
    int                 nCurrErrors;
    FC_CString          jot(MAX_PATH);
    bool                bTargetTypeFound = false;


    nCurrErrors = pdm->getTotalErrors();
    
	//clear possible old content:
    clear();

    m_szKADFile.load(pszKADFileAndPath);
    CG_InitSTEdipos(&m_KADEdp, m_szKADFile, 1);


    pNode = CGT_XMLLoadFile(pdm, NULL, m_szKADFile, L"KAD4VM");
    if(!pNode)
        return false;

    
    // read targets
    pNList = NULL;
    len = 0;
    pNode->selectNodes(L"TRGTYP", &pNList);
    assert(pNList);
    FC_RELEASE_PTR(pNode);

    pNList->get_length(&len);
    for(i=0;i<len;i++)
    {
        pNList->get_item(i, &pNode);

        if ( ! isCurrentTrgType(pdm, pszTargetType, pNode))
            continue;

        bTargetTypeFound = true;


        // <IEC_FEATURES> : read IEC features : dadta types , languages
        pNList2 = NULL;
        pNode->selectNodes(L"IEC_FEATURES", &pNList2);
        assert(pNList2);

        ReadIecFeatures(pdm, 
            m_szKADFile, 
            pNList2, 
            &m_AllowedIEClanguages, 
            &m_AllowedIECtypes, 
            &m_AllowedArrayIndexIECtypes,
            &m_lMaxTasks,
            &m_bLocalRetain,
            &m_CheckAddressSpace
        );

        FC_RELEASE_PTR(pNList2);

        

        // <TASKIMAGE> : read task image features : segments, size, optimize
        pNList2 = NULL;
        pNode->selectNodes(L"TASKIMAGE", &pNList2);
        assert(pNList2);

        ReadTaskImageFeature(pdm, 
            m_szKADFile, 
            pNList2, 
            &m_useTIforSegm,
            &m_optimizeTIforSegm,
            m_lMaxRegionsWR,
            m_lMaxRegionsRD,
            ulTrgVer);

        FC_RELEASE_PTR(pNList2);



        // <IOCOMPONENTS>
        pNList2 = NULL;
        pNode->selectNodes(L"IOCOMPONENTS", &pNList2);
        assert(pNList2);

        len2 = 0;
        pNList2->get_length(&len2);
        for(o=0;o<len2;o++)
        {
            pNList2->get_item(o, &pNode2);
            // <CHANNEL>
            pNList3 = NULL;
            pNode2->selectNodes(L"CHANNEL", &pNList3);
            ReadChannels(pdm, pNList3, &m_channels);
            FC_RELEASE_PTR(pNList3);
        }
        FC_RELEASE_PTR(pNList2);


        // <VM_SETTINGS> : read target features 
        pNList2 = NULL;
        pNode->selectNodes(L"VM_SETTINGS", &pNList2);
        assert(pNList2);

        ReadVmSettings(pdm, pNList2, &m_VmSettings);
        FC_RELEASE_PTR(pNList2);


        // <CG_OPTIONS> : read target code generator features 
        pNList2 = NULL;
        pNode->selectNodes(L"CG_OPTIONS", &pNList2);
        assert(pNList2);
        pNList2->get_length(&len3);
        if (len3 != 0)
        {
            // <CG_OPTIONS> is optional
            ReadCgOptions(pdm, pNList2, &m_CgOptions);
            FC_RELEASE_PTR(pNList2);
        }

        FC_RELEASE_PTR(pNode);
    }
    FC_RELEASE_PTR(pNList);

    if ( ! bTargetTypeFound)
    {
        pdm->msg1(CG_E_XML_TARGET_NOT_FOUND_IN_KAD, &m_KADEdp, pszTargetType);
        return false;
    }

    //finally check usage of channels if no error so far:
    if(nCurrErrors==pdm->getTotalErrors())
        ValidateChannels(pdm, &m_KADEdp, &m_channels, &m_VmSettings);

    return nCurrErrors==pdm->getTotalErrors();
}