Framework (A-Z)

Reference for Wiring version 1.0 Build 0100+ If you have a previous version, use the reference included with your software. If see any errors or have any comments, let us know.

Name

getTonePolyphony()

Examples
void setup() {
  // sets digital pin 7 as input to connect a switch
  pinMode(7, INPUT);  
  // sets the max number of tones to play to 2
  setTonePolyphony(2);
  // generates a 400Hz tone in output pin 8 with infinite duration
  tone(8, 400); 
}

void loop() {
  // if the switch is pressed 
  if (digitalRead(7) == HIGH) {  
    // and if 2 tones can be played simultaneously
    if (getTonePolyphony() >=2) {  
      // generate a 1000Hz tone in output pin 9 with infinite duration
      tone(9, 1000);
	}
  }
}
Description The getTonePolyphony() returns the max number of tones to play, max is limited by the number of timers on the board. If a previous tone command is playing, and a new pin is specified, and tonePolyphony has been set to > 1, and there are available timers, a simultaneous tone will be played on the new pin.
Syntax
getTonePolyphony()
Returns int: the max number of tones that can be played simultaneously.
Usage Application
Related tone()
noTone()
setTonePolyphony()
getTonePolyphony()
Updated on July 07, 2011 11:08:19pm PDT

Creative Commons License