0

私の主な目標は、2 つのオーディオ ストリームをキャプチャして保存しvector<BYTE>、同等性をチェックする合同アルゴリズムを考え出すことです。現在、ストリームを 1 つだけキャプチャしていますが、ストリームの値は 0 '/0' です。BYTE ベクトル内のすべての要素に対して null で終了する値を取得するのはなぜですか?

    void AudioDeviceOperator::TakeInput(AudioStreamModel* m)
{
  HRESULT hr;
  IAudioClient *iac = NULL;
  IAudioCaptureClient *pCaptureClient = NULL;
  WAVEFORMATEX *mixFormat;
  UINT32 bufferFrameCount;

  HRESULT de;
  de = AudioDeviceEnumerator -> GetDefaultAudioEndpoint(eCapture, eConsole, &SelectedAudioDeviceModel->AudioDevice);
  hr = SelectedAudioDeviceModel->AudioDevice -> Activate(IID_IAudioClient, CLSCTX_ALL, NULL, (void**)&iac);


  REFERENCE_TIME bufferDuration = 0;  //default to min
  REFERENCE_TIME periodicity = 0;

  GUID trashGuid;
  HRESULT tg = CoCreateGuid(&trashGuid);
  LPCGUID AudioSessionGuid = &trashGuid;
  GUID guid2 = *AudioSessionGuid;
  HRESULT guidError = UuidCreate(&guid2); //project -> properties -> Linker -> Command Line -> Rpctr4.lib

  iac->GetMixFormat(&mixFormat);
  m->StreamFormat = *mixFormat;
  if (SUCCEEDED(guidError)) {
    cout << "/n" << "Initializing audio stream..";
    hr = iac->Initialize(AUDCLNT_SHAREMODE_SHARED, AUDCLNT_STREAMFLAGS_CROSSPROCESS, bufferDuration, periodicity, mixFormat, AudioSessionGuid);
    cout << hr;
    hr = iac->GetBufferSize(&bufferFrameCount);
    cout << hr;
    iac->GetService(IID_IAudioCaptureClient, (void**)&pCaptureClient);
    // Calculate the actual duration of the allocated buffer.
    double hnsActualDuration = (double)REFTIMES_PER_SEC * bufferFrameCount / mixFormat-> nSamplesPerSec;

    bool recordAudio = TRUE;
    BYTE *sData;
    UINT32 numFramesAvailable = 0;
    DWORD flags;
    UINT32 packetLength = 0;
    int numOfPackets = 0;
    iac->Start();
    while (recordAudio == TRUE)
    {
      hr = pCaptureClient->GetNextPacketSize(&packetLength);
      while (packetLength != 0) {
        hr = pCaptureClient->GetBuffer(&sData, &numFramesAvailable, &flags, NULL, NULL);
        if (sData != NULL) {
          m->Stream.push_back((*sData)); //here is where I write to the vector
          numOfPackets++;
        }
        if (numOfPackets == 100) {  // just getting 100 packets for testing
          recordAudio = FALSE;
          break;
        }
      }
      hr = pCaptureClient->ReleaseBuffer(numFramesAvailable);
    }
  }
  else
    cout << "AudioSessionGuidError";

  CoTaskMemFree(iac);
  AudioDeviceEnumerator->Release();
  //pCaptureClient->Release();  // releaseBuffer seeming to release capture client interface as weell.
};

オーディオセッションが始まると、必ず音を立てます。ベクトル値をそのまま使用すると、比較するものは何もありません。また、そのバイト ベクターを使用して IAudioRenderClient でレンダリングしても何も起こらないと想定していますが、それが次のアクション プランです。何か案は??

4

0 に答える 0