Soil type B 1500 m/sec > Vs > 750 m/sec Includes volcanics, most Mesozoic bedrock, and some Franciscan bedrock. (Mesozoic rocks are between 245 and 64 million years old. The Franciscan Complex is a Mesozoic unit that is common in the Bay Area.)
Soil Type C 750 m/sec > Vs > 350 m/sec Includes some Quaternary (less than 1.8 million years old) sands, sandstones and mudstones, some Upper Tertiary (1.8 to 24 million years old) sandstones, mudstones and limestone, some Lower Tertiary (24 to 64 million years old) mudstones and sandstones, and Franciscan melange and serpentinite.
Soil Type D 350 m/sec > Vs > 200 m/sec Includes some Quaternary muds, sands, gravels, silts and mud. Significant amplification of shaking by these soils is generally expected.
Soil Type E 200 m/sec > Vs Includes water-saturated mud and artificial fill. The strongest amplification of shaking due is expected for this soil type.
The slower the shear wave velocity, the greater the shaking.
Source: https://earthquake.usgs.gov/hazards/urban/sfbay/soiltype/
Additionally, the composition of the rock that the seismic waves are travelling through is a major factor in determining the speed of the waves. Two rock properties that determine the speed of the waves are reflection and refraction:
Reflection
When a wave encounters a change in material properties (seismic velocities and or density) its energy is split into reflected and refracted waves.
Refraction
Source: http://eqseis.geosc.psu.edu/~cammon/HTML/Classes/IntroQuakes/Notes/waves_and_interior.html
There are many factors involved in determining the magnitude of an earthquake with underlying sediments and rock being one of the major factors. This is not an exhaustive list of all those factors but hopefully it points you in the right direction for an answer to your question.