I understand there’s a specific sound musicians needs. How was that note determined and set?
People have decided to define the A above middle C as a frequency of 440hz (hertz). This means the tone played by a piece of metal (like a xylophone for instance) vibrating 440 times per second is an A.
People could have just as easily defined A as 450hz, or anything else for that matter. In fact in the past (baroque, but I might be mistaken) people tuned instruments to A = 420hz. In many orchestras A can also be tuned to 442hz or similar.
In conclusion we just arbitrarily defined A to be 440hz.
The standard tuning note is defined as 440Hz sine wave which is a pure A. However individual orchestras can use their own pitch, it is common to chose a higher pitch to make it easier to play, and choirs often chose a lower pitch for similar reasons. In practice there are often instruments that is hard to tune which everyone tunes to.
The 440Hz standard does actually have an interesting story behind it. The standard pitch used to be much lower. For example Handel’s tuning fork from 1740 was 422.5Hz. We have later forks as low as 409Hz. Then in the 1800s we got the pitch inflation war. By tuning instruments higher the same piece of music sounds better. But especially for the choir it can be hard to sing at very high pitch. As operas, cathedrals and music groups competed for attention the pitch standard increased over time. In the middle of the century the standard was already above 450Hz. The first official pitch standard came in 1859 and was set at 435Hz which was signed into French law. This standard spread to many other countries through a series of treaties. It was even one of the bargaining topics at the end of WWI which resulted in 435Hz being defined as a standard for the central powers who lost.
The British however settled on a higher standard of 452Hz. The Scottish did not even stop there and bagpipes are usually pitched over 470Hz. So eventually in 1939 there was a big international conference where they compromised on 440Hz for the entire world, obsoleting all older standards, even the 435Hz standard. Part of the reason that 440Hz was selected is because this have many factors so you can more easily compare it to a standard 1s pendulum.
The pitch an instrument plays is effected by several factors, most notably the temperature and humidity of the air (which actually changes the speed of sound, how that changes pitch is best described by asking astronomers about blue / red shifting if you want to go down that rabbit hole).
In order to correct for changes, the instruments are tuned just prior to any performance. For an orchestra, a note that is played on all the stringed instruments without pressing on the fingerboards (A) is used to give a single pitch to everyone and they correct their instrument to play the same pitch when trying to play that note.
For pop/rock/country etc. each player will normally tune to an electric tuner before the performance.
Different types of instruments make adjustments in different ways:
stringed instruments: there are tuning pegs that change the tension on the string to set the pitch
Harps have individual strings for each note and it is a pain to get them all in tune (common joke is that a harpist spends half their time tuning, and another half playing out of tune)
Wind instruments, both woodwind and brass have a slide somewhere that changes the length of the pipe. On a brass instrument it can be anywhere in the tubing, on woodwinds it is between where the sound is generated at the mouthpiece and the keys, typically it is just how far in you push the mouthpiece.
Keyboard instruments, like piano are typically not tuned for every performance. The atmospheric changes that effect pitch will mostly allow the instrument to be in tune to itself. It is common in orchestras for the oboe who traditionally gives the reference pitch to correct their pitch against the piano and give the same A it would be playing.
Regular maintenance is done on pianos to keep them in tune. depending on the concert hall and the performer, this may be day of performance, but frequently is between weekly and monthly for ones that get common use to yearly for home instruments.
tuned percussion is set at the factory and not changed by the user. There are some acoustic parts that may make adjustments to amplify the sound better based on current air conditions, but this does not change the pitch played by the struck part of the instrument.
The musical notes are all based on ratios. If you take say middle C and then go to C one octave up you should have doubled the frequency for example. A given instrument is tuned to a specific set of notes, in order to be able to play pieces of music designed for those notes. The various scales are sets of ratios that sound good to the human ear, and the notes of a given instrument are chosen to allow the instrument to play one or more scales.
In general it is not necessary to tune to specific frequencies, rather you can pick one of the notes your instrument can make, for example a single string of your guitar. Then you adjust the frequencies of the other notes (strings) to be the correct ratio with respect to that first note.
In an orchestra you have multiple instruments and they do need to match. You can’t really tune a piano in real time, so the other instruments are adjusted to match a particular note on the piano.