本文介绍了录制音频时生成图形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个在录制音频时生成图形的应用程序.当搜索代码时,我在msdn中得到了类似的帮助.问题是,当我不知道什么时候进行录音时,如何定义录制音频时的音轨大小?
录音同时进行时,有人可以帮助生成图形吗?
谢谢.

I am creating an application which generates a graph while recording audio. When searched for code, I got some help like this in msdn. The problem is that, how do I define the track size when I am recording audio as I am unaware till what time the recording will take place?
Can anybody help in generating the graph as recording is simultaneously going on??
Thanks.

// interval along x-axis

double intervalX = pathX.Width / track[0].mSamples.Length;



// looping throught the samples and plotting the curve

for (int i = 0; i < track[0].mTrackSize; i++)

{

    Line line = new Line();

    line.X1 = line.X2 = pathX.Data.Bounds.Location.X + ((i) * intervalX);

    line.Y1 = pathX.Data.Bounds.Location.X + (pathY.Data.Bounds.Location.X) + (pathY.Height / 2);

    line.Y2 = line.Y1 + 5;



    polyTrack.Points.Add(new Point(line.X1, line.Y1 - track[0].mSamplesIdea * Math.Pow(10, 2)));

}



    track[0].mSamples ---- array containing the sample points of an audio

    pathX ------------------------ my X-axis

    pathY ----------------------- my Y-axis

    polyTrack ------------------ a polyline contained in the canvas to which i''m binding the points and drawing the curve

推荐答案


这篇关于录制音频时生成图形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-22 08:57