Serial.print latency problem

Im getting a two second delay when reading the serial port on the Arduino from Processing…

My arduino code looks like:

void loop() {
  // wait if any serial is going on
  while (FreqCounter::f_ready == 0) 

My Processing code looks like:

 while(true) {
      inString = myPort.readStringUntil('\n');

     if (inString != null) {
           // trim off any whitespace:
         inString = trim(inString);
         // convert to an int
         frequency = int(inString); 
         if(frequency >= 0 && frequency < 3000) {
      // sine.setFreq(5000);

Basically the Arduino calculates a frequency based on the position of my finger acting as a potentiometer and sends the frequency to Processing. Processing takes that frequency and turns it into sound.

But I get a 2 second delay between touching and hearing sound…

Any ideas why this is happening?


while (FreqCounter::f_ready == 0)

Is that deliberate, or is there a semicolon missing?

How do we know what happens in "FreqCounter"?