-1

I am recording audio in WAV format using AudioRecord. How to plot the received data while recording in form of a realtime graph using android plot.

Prateek Ratnaker
  • 817
  • 11
  • 35

1 Answers1

2

This question is much too broad to fully answer, but I can hopefully at least point you in the right direction to get started. I'd suggest beginning by converting your data into an XYSeries. There are multiple ways to do this and which one you choose depends on how you want your dynamic data to look:

  • Will the plot scroll, or will the data scroll across the plot?
  • Are the domain / range min/max values fixed or dynamic?
  • Will timestamps or sample indexes be used to represent x?

Once you know the answer to these questions you can begin to decide how to represent each sample in terms of [x, y] values. This means converting each sample(i) into an x and y value. For y, you'll need to convert your wav amplitude into a Number. For x, if you just want to show the sample index, use i. If you want to show time then you'll probably want to use the sampling frequency and recording start time to convert i into a timestamp.

Once you've got the basics of your XYSeries implementation figured out you can move on to displaying the series data in an XYPlot. Take a look at the Plotting Dynamic Data guide, which includes a link to source samples.

Nick
  • 8,181
  • 4
  • 38
  • 63
  • I have edited the code...included plotting code,tried what u said but it didn't work out...have a look at my updated code – Prateek Ratnaker Jan 02 '17 at 05:59
  • please check again – Prateek Ratnaker Jan 03 '17 at 19:03
  • can you describe what part(s) are not currently working? are you seeing data but it's not scrolling? no data at all? etc. also you probably shouldnt call `plot.redraw()` from within the for loop adding items to your series; call it once, after all items have been added instead. – Nick Jan 03 '17 at 19:20
  • I want to create a dynamic real-time graph.....That is why I am doing it...That is why I am calling plot.redraw() – Prateek Ratnaker Jan 04 '17 at 00:00
  • you have while(isRecording) which I would assume continuously processes an input stream. As long as you call redraw() once per iteration of the while loop then your plot should be dynamic. Calling redraw once per sample in your inner for loop is overkill. – Nick Jan 08 '17 at 18:46