Abstract : We define a generic model for finite audio or symbolic musical patterns that structurally encodes a rich and abstract synchronization mechanism. This is achieved by distinguishing for each pattern a realization window, describing what the pattern is, from a synchronization window, describing how the pattern can be used. The sequential composition of patterns is defined and studied. An algebra of musical patterns is introduced in a mathematically well-founded approach. We propose several high level operators that can be used either in audio processing or in musical analysis and composition. Practical uses and experiments conducted in both fields are described.