Phonology (Greek phonē = voice/sound and logos = word/speech), is a subfield of linguistics which studies the sound system of a specific language (or languages). Whereas phonetics is about the physical production and perception of the sounds of speech, phonology describes the way sounds function within a given language or across languages.
An important part of phonology is studying which sounds are distinctive units within a language. In English, for example, /p/ and /b/ are distinctive units of sound, (i.e., they are phonemes / the difference is phonemic, or phonematic). This can be seen from minimal pairs such as "pin" and "bin", which mean different things, but differ only in one sound. On the other hand, /p/ is often pronounced differently depending on its position relative to other sounds, yet these different pronunciations are still considered by native speakers to be the same "sound". For example, the /p/ in "pin" is aspirated while the same phoneme in "spin" is not. In some other languages, for example Thai and Quechua, this same difference of aspiration or non-aspiration does differentiate phonemes.
In addition to the minimal meaningful sounds (the phonemes), phonology studies how sounds alternate, such as the /p/ in English described above, and topics such as syllable structure, stress, accent, and intonation.
The principles of phonological theory have also been applied to the analysis of sign languages, in which it is argued that the same or a similar phonological system underlies both signed and spoken languages. (Signs are distinguished from gestures in that the latter are non-linguistic or supply extra meaning alongside the linguistic message.)