Harmonic issues have always been paid attention to in electrical systems, and accurate calculation of the amplitude and phase of each harmonic has become one of the research focuses of scholars. This article develops a generalized harmonic closed-form analytical solution for a single-phase voltage source inverter (VSI) under digital sinusoidal pulse width modulation (DSPWM) and dead-time effects. This article is the first to point out the double-pulse phenomenon that can occur when using a double Fourier series to solve the harmonic spectrum due to the discontinuity of the dead-time effects and half-cycle integrals. Analysis and data comparison shows that this phenomenon can affect the accuracy of harmonic calculations. An discretized double Fourier series method is proposed to solve this phenomenon. Moreover, the problems of missing pulse caused by the modulation under a specific current phase and current zero-crossing are also solved, improving the harmonic calculation's accuracy and generality. Simulation analysis and the results of inverse fast Fourier transform (IFFT) proved the correctness of the optimization method. And the experimental results are obtained on the DSP and SIC platforms, which are in good agreement with the expression calculation results