Portia has cooked up a scheme in which music plays a key role. Critic Homer Watt expalins it this way:
At his trial, aided by a hint embebbed in a song which Portia orders sung while he comments to himself on the caskets, the happy Bassnio finds in the leaden casket "fair Portia's counterfeit."
In 3.2.40-45, Portia tells Bassanio:
Away then. I am locked in one of them.*(*a coffin)
If you do love me, you will find me out.
Nerissa and the rest, stand all aloof.
Let music sound while he doth make his choice.
Then if he lose make a swanlike end
Fading in music. That the comparison
May stand more proper, my eye shall be the stream,
And watr'y deathbed for him. He may win,
And what is music then? The music is
Even as the flouish when true subjects bow
To a new crowned monarch.