Tone.cpp

I cant understand this code in Tone.cpp source. Could anyone explain what this for loop is checking for

#define AVAILABLE_TONE_PINS 1

const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 3, 4, 5, 1, 0 */ };
static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255, 255, 255, 255, 255 */ }
 for (int i = 0; i < AVAILABLE_TONE_PINS; i++) {
    if (tone_pins[i] == _pin) {
      _timer = pgm_read_byte(tone_pin_to_timer_PGM + i);
      tone_pins[i] = 255;
    }
  }

Could anyone explain what this for loop is checking for

There is a #define statement that defines how many pins can support tones at one time (based on how many timers are available).

The arrays define the pins and the timers to use for those pins.

The for loop iterates over all the pins that can support tones, and determines which timer a specific pin uses. Then, it sets that pin as not supporting tones.