Generalization of the Darboux transformation and generalized harmonic oscillators