ctl->cmsg(CMSG_WARNING, VERB_NORMAL, "BAD period %d\n", period);
ctl->cmsg(CMSG_WARNING, VERB_NOISY, "BAD period %d\n", period);
period2note (int period, int *finetune){  static int period_table[121] =  {  /*  C     C#    D     D#    E     F     F#    G     G#    A     A#    B  */     13696,12928,12192,11520,10848,10240, 9664, 9120, 8608, 8096, 7680, 7248,      6848, 6464, 6096, 5760, 5424, 5120, 4832, 4560, 4304, 4048, 3840, 3624,      3424, 3232, 3048, 2880, 2712, 2560, 2416, 2280, 2152, 2024, 1920, 1812,      1712, 1616, 1524, 1440, 1356, 1280, 1208, 1140, 1076, 1016,  960,  906,       856,  808,  762,  720,  678,  640,  604,  570,  538,  508,  480,  453,       428,  404,  381,  360,  339,  320,  302,  285,  269,  254,  240,  226,       214,  202,  190,  180,  170,  160,  151,  143,  135,  127,  120,  113,       107,  101,   95,   90,   85,   80,   75,   71,   67,   63,   60,   56,	53,   50,   47,   45,   42,   40,   37,   35,   33,   31,   30,   28,	27,   25,   24,   22,   21,   20,   19,   18,   17,   16,   15,   14,	  	-100 /* just a guard */  };  int note;  int l, r, m;  if (period < 14 || period > 13696)  {    ctl->cmsg(CMSG_WARNING, VERB_NORMAL, "BAD period %d\n", period);    return -1;  }  /* bin search */  l = 0;  r = 120;  while (l < r)    {      m = (l + r) / 2;      if (period_table[m] >= period)	l = m + 1;      else	r = m;    }  note = l - 1;  /*   * 112 >= note >= 0   * period_table[note] >= period > period_table[note + 1]   */  if (period_table[note] == period)    *finetune = 0;  else {    /* Pick the closest note even if it is higher than this one.     * (e.g. 721 - 720 < 762 - 721 ----> pick 720)    */    if (period - period_table[note + 1] < period_table[note] - period)      note++;        /* fine tune completion */    *finetune = ((period_table[note] - period) << 8) /		   (period_table[note] - period_table[note + 1]);    *finetune <<= 5;  }  return note;}