How many times must one hear the shofar sounded on Rosh Hashanah? One must hear it nine times, for the Torah uses the word teruah [a shofar sound] three times in reference to Rosh Hashanah and each teruah sound is preceded and followed by a tekiah sound.
Now, concerning the teruah to which the Torah refers, doubt has arisen, over the ages, as to which sound is intended: whether it is a wailing tone, such as women cry among themselves when they lament; or a kind of sigh, such as one might repeatedly emit in a state of acute sorrow; or if it is a combination of both a sighing and a wailing tone. For such is the way of one who feels great sorrow and anxiety: he first sighs, and then laments.
Therefore we sound all three of these shofar tones, and to differentiate between them we call the wailing sound teruah and the sighing sound shevarim, and the combination of the two shevarim-teruah. In order to resolve all doubt as to the original teruah sound, we sound all three possibilities, each preceded and followed by the straight tekiah.
The order of the shofar sounding is therefore as follows:
After reciting the appropriate blessings, a tekiah is sounded, followed by shevarim, a teruah, and then another tekiah.
This order is followed three times, for a total of twelve sounds [six tekiot, three shevarim and three teruot]. Then another tekiah is sounded, followed by a shevarim, and then another tekiah. This order is also followed three times, for a total of nine sounds. Then, another tekiah is sounded followed by a teruah, and then another tekiah.
Again, this order is followed three times, for a total of nine sounds. Altogether, thirty sounds are made. This order of shofar sounds is referred to as the tekiot d'meyushav - the tekiot sounded when the people may either stand or remain seated. While the person sounding the shofar is required to stand, the congregation may remain seated since they have not yet begun Musaf. Nonetheless, it is customary to stand when the shofar is sounded.
During Musaf, there is an additional requirement to sound the shofar when reciting the blessings of malchuyot - our recognition of G-d's sovereignty, zichronot - when we remind ourselves of G-d's providence, and shofarot - when we refer to the sounding of the shofar. These are referred to as the tekiot d'me'umad - the sounding of the shofar while standing, because the shofar is sounded during the Amidah prayer, which is said while the congregation is standing.
The custom in some congregations is to sound the shofar during the silent Amidah, while others do so only during the cantors repetition.