I am using a Arduino and a buzzer to test the accuracy of the data transfer quality.
It seems, if the phone can handle the amount of computation, smaller buffer size would be a better choice.
A smaller buffer size means more buffers generated per second and less samples per buffer. These would result in a lower frequency resolution. Take 0.001 buffer duration, for example, the frequency resolution becomes 1/0.001=1KHz. That means the smallest difference that can be told from a buffer would be 1KHz(if using this 0-crossing counting algorithm).
This is good. the parts where the tone is changing frequency is more clear-cut. And the latency is lower(as we would need to wait for shorter time before a buffer is filled). Of course, the price we pay is the resolution becomes not so good. we can't really tell the difference between 5KHz and 5.5kHZ, if we use a buffer duration of 0.001sec.
Testing Procedure:
I am using the Arduino and the following code to generate the frequency that is fed into a buffer and a low pass filter.
void setup() {// initialize the digital pin as an output.// Pin 13 has an LED connected on most Arduino boards:pinMode(9, OUTPUT);}void loop() {for(int i=1000;i<9000;i+=500){tone(9,i); // set the LED offdelay(20);tone(9,10000); // set the LED offdelay(50);}}
We would expect a increasing tone alternated by a fixed pitch at 10KHz.
And this is the graph I obtained by getting the computed frequency for each buffer from NSLog, than plot it using EXCEL:
Buffer Duration of 0.005 sec:
Buffer Duration of 0.002 sec:
Buffer Duration of 0.001 sec:



No comments:
Post a Comment