Key signatures define which accidentals (sharps or flats) a piece's notes will tend to follow, by expressing them all at the beginning of a line (or piece.) Notes following the key signature are then automaticly augmented or diminished according to this signature. A piece may alter this standard by inserting sharps or flats next to the intended note; these accidentals last until the end of the bar. They are closely linked to scales, from which they can be derived.