java - Smoothing signal from microphone - Hearthbeat -
i'm working on project using oximeter.i want smooth out can use calculating hearthbeat. i'm gathering raw data microphone , put them in new array, lets say, sdata[]
.
signal crazy , jumps on plot expected, tried smoothing using moving average. main code looks this.
writeaudiodatatofile(); (int = 0; < sdata.length; a++) { tempavg += math.abs(sdata[a]); if (a % numberofsamplesaveraged == 0) { //average x samples if (myindex > sample_size - 1) { myindex = 0; } tempavg = tempavg / numberofsamplesaveraged; if (tempavg > 500) { newdataarray[myindex] = 500; }else{ newdataarray[myindex] = tempavg; } //this suppose clear high peaks. log.d("isrecording - average " + numberofsamplesaveraged + " numbers.", "newdataarray[" + myindex + "] = " + newdataarray[myindex]); tempavg = 0; myindex++; } } notifier.notifyobservers(); log.d("notifier", "notifier fired!"); thread.sleep(20); //still experimenting value
it looks messy, plot (i'm using androidplot btw) looks inaccurate can't calculate hearthrate it. has "bounce" in "high" state. found on internet kind of filter (maybe iir filter) job. wanna ask guys how can achieve nice smooth chart? iir filter way go? there free applet/lib smoothen out? first question here i'm sorry if badly written. if need more information me, ask. here picture how chart looks now.
http://oi62.tinypic.com/2uf7yoy.jpg // cant post images im new here.
this lucky 1 though. need smoother output.
noises, occur @ measurement, have high frequency. should filter signal, should retain low frequency part of signal , suppress high frquency part of signal. can it, making low-pass filter. be, example, first-order inertial model. suggest make pass-band till ~~10 khz, since people hear sound 2 khz 20 khz. appriopriate sample time 0,0001 sec (0,1 ms). discrete model has following equation:
y[k] = 0.9048*y[k-1] + 0.09516*u[k-1]
,
where u measured vector (directly microphone, input in our filter), , y vector want analyze (so output our filter).
as can see,, can calculate sample number 1, , can assign 0 sample number 0. after all, can try plot y vector.
Comments
Post a Comment