We introduce an automatic algorithm for transcribing cardiac rhythm sequences into music rhythm notation. The method is efficient and runs in linear time according to the number of beats and the sampling frequency, and can work in real time. This quantisation method uses approximate common divisors (ACDs) to find an optimal rhythm transcription. The technique maps ACDs to nodes on a graph, node transitions represent heart rate variations, and a balance must be struck between rhythmic changes and heart rate variation. Each possible transcription corresponds to a path in the graph. Given a set of weights on the edges, a shortest path algorithm then finds an optimal transcription. Because the graph is directed and acyclic, the shortest path algorithm is linear. Such music representation of the cardiac rhythm allows for efficient pattern recognition and extraction. We test the transcription algorithm on the MIT-BIH Normal Sinus Rhythm Database for validation, and on the Physionet Long Term Atrial Fibrillation Database and the Spontaneous Ventricular Tachyarrhythmia Database for detecting frequent rhythmic subsequences which may potentially serve as biomarkers for disease stratification.