Answer:
In the first sentence:
"alberto oyo la musica de la fiesta y salio de casa."
The tense used is the perfect preterite, this means that the action is already finished when the sentence is said "Oyo" means heard.
In the second sentence:
"Alberto oia la musica de la fiesta cuando salio de casa"
We have an imperfect preterite, this means that the action started in the past, but it is not necesarly finished yet, so "oia" can be translated to "he was hearing".
So this is the difference between both sentences, the first one can be translated to:
"
Alberto heard the music of the party and left home."
and the second one to;
"Alberto was hearing the musico of the party as he left home"