如何在Windows UWP中将AudioFrame [AudioGraph] PCM缓冲区转换为AAC?

时间:2017-06-23 13:27:23

标签: c# windows audio uwp aac

如何在UWP中将AudioFrame PCM缓冲区转换为AAC?我正在使用AudioFrameOutputNodeAudioGraph在AudioFrames中捕获麦克风数据。

    AudioFrameOutputNode frameOutputNode;

    private void CreateFrameOutputNode()
    {
        frameOutputNode = audioGraph.CreateFrameOutputNode();
        audioGraph.QuantumStarted += AudioGraph_QuantumStarted;
    }

    private void AudioGraph_QuantumStarted(AudioGraph sender, object args)
    {
        AudioFrame frame = frameOutputNode.GetFrame();
        ProcessFrameOutput(frame);

    }

    /* AudioFrame buffer will be in PCM format */
    unsafe private void ProcessFrameOutput(AudioFrame frame)
    {
        using (AudioBuffer buffer = frame.LockBuffer(AudioBufferAccessMode.Write))
        using (IMemoryBufferReference reference = buffer.CreateReference())
        {
            byte* dataInBytes;
            uint capacityInBytes;
            float* dataInFloat;

            // Get the buffer from the AudioFrame
            ((IMemoryBufferByteAccess)reference).GetBuffer(out dataInBytes, out capacityInBytes);

            dataInFloat = (float*)dataInBytes;

            //TO DO
            //Convert PCM data to AAC data
        }
    }

0 个答案:

没有答案