The "time signature" at the beginning of the piece tells how many beats there will be in each measure, and what size note will receive one beat. From there on, all the different size notes in the piece are figured from that. It can even change during the piece, but if that happens, then there has to be a new time signature at the place in the music where it changes.