录制音频时生成图形 [英] Generating a graph while recording audio

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

问题描述

我正在创建一个在录制音频时生成图形的应用程序.当搜索代码时,我在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

推荐答案

想法是,您可以创建一个缓冲流(轨道的长度)并将该大小用于图形.然后在该流上进行语音记录,并在您的实际记录长度达到其缓冲长度时增加它.

提示:System Voice Recorder软件还使用了一些缓冲记录时间,可能是分配了专用的内存来保存语音记录.

问候
鲁西
Idea is, you can create a buffer stream (length of your track) and use that size for graph. Then do voice recording on that stream and increase it when your actual recording length reaches to its buffer length.

Hint: System Voice Recorder software also uses some buffer recording time, might be to allocate a dedicated memory for saving voice recording.

Regards
Rushi


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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆