A system, method and memory medium for operating on an electrocardiogram (ECG) signal. A multiscale short-time Fourier transform (STFT) is performed on a set of ECG samples {s(n)} to obtain a transform array. For each sufficiently energetic peak in the transform array, a refined window width value and a refined window displacement value is generated by: computing an inner product between the set of samples and each of a plurality of functions, where the plurality of functions are sufficiently close to a coarse approximation function given by the peak location and solving a linear system Av=c for the unknown vector v, where the vector c is determined by the inner products, where the matrix A is determined by the center times of the plurality of functions. After appropriate selection, the refined window width and refined window displacement may be used to represent ECG waveform features.