예제 #1
0
        void audioBeamFrameReader_FrameArrived(
            AudioBeamFrameReader sender, AudioBeamFrameArrivedEventArgs args)
        {
            using (var audioFrame =
                       args.FrameReference.AcquireBeamFrames() as AudioBeamFrameList) {
                if (audioFrame == null)
                {
                    return;
                }

                for (int i = 0; i < audioFrame.Count; i++)
                {
                    using (var frame = audioFrame[i]) {
                        for (int j = 0; j < frame.SubFrames.Count; j++)
                        {
                            using (var subFrame = frame.SubFrames[j]) {
                                subFrame.CopyFrameDataToArray(audioBuffer);

                                waveFile.Write(audioBuffer);

                                // 参考:実際のデータは32bit IEEE floatデータ
                                //float data1 = BitConverter.ToSingle( audioBuffer, 0 );
                                //float data2 = BitConverter.ToSingle( audioBuffer, 4 );
                                //float data3 = BitConverter.ToSingle( audioBuffer, 8 );
                            }
                        }
                    }
                }
            }
        }
        void audioBeamFrameReader_FrameArrived(object sender, AudioBeamFrameArrivedEventArgs e)
        {
            using (var audioFrame = e.FrameReference.AcquireBeamFrames()) {
                if (audioFrame == null)
                {
                    return;
                }

                var subFrame = audioFrame[0].SubFrames[0];
                subFrame.CopyFrameDataToArray(audioBuffer);

                waveFile.Write(audioBuffer);

                // (例)実際のデータは32bit IEEE floatデータなので変換する
                float audioData1 = BitConverter.ToSingle(audioBuffer, 0);
                float audioData2 = BitConverter.ToSingle(audioBuffer, 4);
                float audioData3 = BitConverter.ToSingle(audioBuffer, 8);
            }
        }