The historical pronunciation of these letters underwent a few changes in the evolution from Latin to modern Spanish.
Word initial "u/v", word initial "b"
This phonetic contrast appears to have continued into Old Spanish, given that medieval scribes distinguished fairly consistently between words that began with "u/v" (= /β/) and words which began with "b" (= /b/):
/w-/
→ /β-/
→ /b-/
vacca/uacca → vaca
/ˈwak.ka/ → /ˈβa.ka/ → /ˈβa.ka/ → /ˈba.ka/
Latin
→ Vul Lat
→ Old Spa
→ 15C Spa.
/b-/
bucca(m) → boca
/ˈbuk.ka/ → /ˈbo.ka/ → /ˈbo.ka/
Vul Lat
→ Old Spa
→ Mod. Spa.
Word internal "u/v", "b"
Though the phonetic contrast between these was lost in Old Spanish, and as such the spellings in Old Spanish mostly used "v/u" to represent [-β-], the modern revised orthographies maintain the etymological spellings:
/-b-/
→ /-β-/
habēre → auer → haber
/aˈbeɾe/ → /aˈβeɾ/ → /aˈβeɾ/
Vul Lat
→ Old Spa
→ Mod. Spa.
/-w-/
→ /-β-/
sĕrvīre → seruir → servir
/seɾˈwiɾe/ → /seɾˈβiɾ/ → /seɾˈβiɾ/
Vul Lat
→ Old Spa
→ Mod. Spa.
Word internal "p"
In medieval Spanish, words that had /-p-/ in Latin are fairly consistently spelled with a b, implying that they were actually pronounced with [-b-] rather than [-β-].
/-p-/
→ /-b-/
→ /-β-/
lupus → lobo
/ˈlu.pus/ → /ˈlobo/ → /ˈloβo/
Latin
→ Med Spa
→ Old Spa. (15c)
Syllable final /b/
8. Adjustments due to vowel syncope
...
Finally, syllable-final /b/ (realized as [β]) was generally semivocalized to [w], although this latter sound was later lost through assimilation if it followed a back vowel (see the codo example below):
/-p/
→ /-b/
→ /-β/
→ /-w/
capitālis → cabdal → caudal
cap(i)tālem → [kaβˈðal] → [kawˈðal]
/-b/
→ /-β/
→ /-w/
debita → debda → deuda
dēb(i)ta → [ˈdeβða] → [ˈdewða]
/-b/
→ /-β/
→ /-w/
→ ∅
cubitus → cobdo → codo
cŭb(i)tum → [ˈkoβðo] → [ˈkowðo] → [ˈkoðo]
Also:
- absentia → ausencia
- baptista → bautista
- captivar → cautivar
- rapĭdus → raudo etc
Fuentes:
• https://www.staff.ncl.ac.uk/i.e.mackenzie/cons.htm#semivowels
• Fonología y fonética históricas del español, Manuel Ariza Viguera (p.120-130)