Watch the The Bass Line Pt. 4 online guitar lesson by Brad Carlton from Guitar Lab: Solving the Puzzle Vol. 1

Once you understand what the implied chord is at any given point in a piece of music, you'll then be able to both extend the chord with notes from the appropriate scale or mode. This will also help you solo effectively (melodically) because you'll know which notes are the strong notes (the chord tones).