Click here to Skip to main content
15,897,519 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
Posted

1 solution

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
 
Share this answer
 
Comments
aditya behara 10-May-11 6:42am    
ok. But how do I use a buffer? Can you post a code snippet of the same?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900