// 音声入力を開始する void KinectAudio::start() { memset( &outputBufferStruct_, 0, sizeof(outputBufferStruct_) ); outputBufferStruct_.pBuffer = &mediaBuffer_; // Set DMO output format DMO_MEDIA_TYPE mt = {0}; CHECKHR( ::MoInitMediaType( &mt, sizeof(WAVEFORMATEX) ) ); mt.majortype = MEDIATYPE_Audio; mt.subtype = MEDIASUBTYPE_PCM; mt.lSampleSize = 0; mt.bFixedSizeSamples = TRUE; mt.bTemporalCompression = FALSE; mt.formattype = FORMAT_WaveFormatEx; memcpy( mt.pbFormat, &getWaveFormat(), sizeof(WAVEFORMATEX) ); CHECKHR( mediaObject_->SetOutputType( 0, &mt, 0 ) ); ::MoFreeMediaType( &mt ); // Allocate streaming resources. This step is optional. If it is not called here, it // will be called when first time ProcessInput() is called. However, if you want to // get the actual frame size being used, it should be called explicitly here. CHECKHR( mediaObject_->AllocateStreamingResources() ); // allocate output buffer mediaBuffer_.SetBufferLength( getWaveFormat().nSamplesPerSec * getWaveFormat().nBlockAlign ); }
VDAudioSourceWAV::VDAudioSourceWAV(VDInputFileWAV *parent) : mpParent(parent) , mBytesPerSample(parent->GetBytesPerSample()) { mSampleFirst = 0; mSampleLast = parent->GetDataLength() / mBytesPerSample; const vdstructex<VDWaveFormat>& format = parent->GetFormat(); memcpy(allocFormat(format.size()), format.data(), format.size()); streamInfo.fccType = streamtypeAUDIO; streamInfo.fccHandler = 0; streamInfo.dwFlags = 0; streamInfo.wPriority = 0; streamInfo.wLanguage = 0; streamInfo.dwInitialFrames = 0; streamInfo.dwScale = mBytesPerSample; streamInfo.dwRate = getWaveFormat()->mDataRate; streamInfo.dwStart = 0; streamInfo.dwLength = VDClampToUint32(mSampleLast); streamInfo.dwSuggestedBufferSize = 0; streamInfo.dwQuality = 0xffffffff; streamInfo.dwSampleSize = mBytesPerSample; }