My program runs through but won't show me my graph. I'm using android-graphview api to graph some audio file, but when my program ends reading the audio file and then proceeds to graphing it, the whole graph won't show. And it only give me this in LogCat
12-31 16:55:16.314: D/TextLayoutCache(12579): Enable myanmar Zawgyi converter
12-31 16:55:16.314: D/TextLayoutCache(12579): Enable myanmar Zawgyi converter
12-31 16:55:16.354: D/GC(12579): <tid=12579> OES20 ===> GC Version : GC Ver rls_pxa988_KK44_GC13.20
12-31 16:55:16.404: D/OpenGLRenderer(12579): Enabling debug mode 0
12-31 16:55:16.454: D/TextLayoutCache(12579): Enable myanmar Zawgyi converter
12-31 16:55:16.454: D/TextLayoutCache(12579): Enable myanmar Zawgyi converter
12-31 16:55:16.454: D/TextLayoutCache(12579): Enable myanmar Zawgyi converter
12-31 16:55:16.464: D/TextLayoutCache(12579): Enable myanmar Zawgyi converter
I don't think I have no error on me reading the file but it won't show me the graph. this is my code
public void graphing() throws IOException
{
System.out.println("in process...");
File f = new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/sample.wav");
LineGraphSeries<DataPoint> series = new LineGraphSeries<DataPoint>();
graph = (GraphView) findViewById (R.id.graph);
graph.getViewport().setScrollable(true);
graph.getViewport().setScalable(true);
graph.getViewport().setMinX(0);
graph.getViewport().setMaxX(f.length()/2);
FileInputStream fis;
fis = new FileInputStream(f);
BufferedInputStream bis = new BufferedInputStream(fis);
int channelCount = 1;
int[][] samples = new int[channelCount][(int) (f.length()/2)];
int sampleIndex = 0;
long cursor = 0;
byte[] data = new byte[(int) ((f.length()/2)*2)];
int result = fis.read(data);
for(int i = 0; i < data.length;)
{
for(int ch = 0; ch < channelCount; ch++)
{
int low = (int) data[i];
i++;
int high = (int) data[i];
i++;
int sample = get(high, low);
samples[ch][sampleIndex] = sample;
System.out.println(cursor+" "+samples[ch][sampleIndex]);
series.appendData(new DataPoint(cursor, samples[ch][sampleIndex]), true, 10);
cursor++;
}
sampleIndex++;
}
System.out.println("...end");
}
public static int get(int high, int low)
{
return (high << 8) + (low & 0x00ff);
}
BTW, HAPPY NEW YEAR GUYS!
Aucun commentaire:
Enregistrer un commentaire