Manuscript Offprint
arXiv:2610.39255A learning-based method of automatic music transcription
Phu-Anh-Tai Do*
Department of Information Technology
FPT University
Ho Chi Minh City, Vietnam
Huu-Hoang Nguyen*
Department of Information Technology
FPT University
Ho Chi Minh City, Vietnam
Duc-Hoang Nguyen*
Department of Information Technology
FPT University
Ho Chi Minh City, Vietnam
Thanh-Hai Le†
Faculty of Information Technology
Ho Chi Minh City Open University
Ho Chi Minh City, Vietnam
October 30, 2026
ABSTRACT
Automatic Music Transcription (AMT) seeks to convert acoustic music recordings into symbolic musical notation, a process that remains remarkably difficult for polyphonic piano due to concurrent polyphony, harmonic partial interference, expressive timing, and severe pitch activation sparsity. In this paper, we formulate polyphonic piano transcription as a frame-level multi-label classification problem across the standard 88 piano pitches (MIDI notes 21 to 108). Raw audio waveforms are processed using the Constant-Q Transform (CQT) to construct a geometrically spaced log-frequency time-frequency representation that aligns with the chromatic musical scale across seven octaves (252 frequency bins per frame). We systematically investigate recurrent sequence models, contrasting unidirectional Long Short-Term Memory (LSTM) with Bidirectional LSTM (BiLSTM) backbones, and propose two architectural adaptations tailored to recurrent temporal representations: a modified additive attention module and a modified multihead attention mechanism equipped with hyperbolic tangent activation and head-wise summation. Furthermore, to mitigate the severe class imbalance between inactive and active notes (approximately 41:1), we evaluate Weighted Binary Cross-Entropy (WBCE) alongside standard Binary Cross-Entropy (BCE). Rigorous empirical evaluations on the MAPS and MAESTRO datasets demonstrate steady, compounding gains from bidirectionality and attention mechanisms. Our proposed Multihead Attention–BiLSTM architecture attains an F1-score of 88.20%, an accuracy of 78.90%, a precision of 0.89, and a recall of 0.86, substantially outperforming the baseline unidirectional LSTM (F1-score of 71.20%) while maintaining a compact parameter budget of 4.43M. Qualitative piano-roll visualizations confirm that our model generates faithful transcriptions even in complex harmonic passages.
Keywords Automatic Music Transcription · Polyphonic Piano Transcription · Constant-Q Transform · Bidirectional LSTM · Attention Mechanism · Multihead Attention · Weighted Binary Cross-Entropy
1 Introduction
The transcription of acoustic music into written symbolic notation represents a remarkable feat of human intelligence, uniting psychoacoustic perception (auditory scene analysis), cognition (auditory object identification), formal knowledge
*Equal contribution.
†Corresponding author / Project Supervisor.
representation (musical syntax and harmony), and probabilistic inference (evaluating competing musical hypotheses) [1]. Automatic Music Transcription (AMT) aims to automate this complex translation process by designing computational algorithms capable of converting acoustic signals into symbolic representations such as MIDI or digital sheet scores. AMT constitutes a cornerstone of Music Information Retrieval (MIR), offering foundational primitives for downstream applications including musicological analysis, audio search, automated accompaniment, cover-song identification, and computational music education [2, 1].
Despite decades of active research, polyphonic AMT—and polyphonic piano transcription in particular—remains an inherently ill-posed and challenging problem. This difficulty arises from four primary acoustic and structural phenomena:
-
Polyphony and Overlapping Mixtures: In polyphonic music, multiple notes are excited simultaneously. The observed acoustic signal is a linear mixture of vibrational modes produced by multiple strings, resulting in composite, intertwined spectro-temporal profiles.
-
Harmonic Interference: Musical harmony relies heavily on consonant musical intervals (e.g., octaves, perfect fifths, perfect fourths), whose fundamental frequencies adhere to small integer ratios. As a consequence, the overtone series of simultaneously sounding notes heavily overlap in the frequency domain, obscuring individual fundamental frequencies and complicating source separation [3, 4].
-
Temporal Dynamics and Acoustic Reverberation: Real-world piano performance exhibits complex temporal non-stationarity, including percussive hammer strikes, sustain pedal resonances, string coupling, and room reverberation. The decay phase of preceding notes lingers across subsequent frames, frequently violating assumptions of temporal independence [5, 6].
-
Acute Class Imbalance: A modern standard acoustic piano spans 88 keys. Even in virtuosic performances, human pianists rarely strike more than 8 to 10 keys simultaneously. Consequently, in any given analysis frame, only a very small fraction of the 88 pitches are active, resulting in an extreme sparsity ratio of active to inactive notes (empirically measured at approximately 1:41 in benchmark training corpora). Standard classification objectives heavily bias predictors toward inactive predictions unless explicitly countered.
To address these hurdles, this paper presents a learning-based framework for polyphonic piano transcription. As illustrated in Figure 1, we formulate the problem as a frame-level multi-label classification task over the 88 canonical piano pitches (MIDI notes 21 through 108). Recognizing the logarithmic frequency organization of musical pitch perception, we employ the Constant-Q Transform (CQT) [7] over 7 octaves with 36 bins per octave, yielding a 252-dimensional spectral feature vector per time frame.
To model the temporal dynamics of music, we explore recurrent neural network architectures, contrasting unidirectional Long Short-Term Memory (LSTM) [8] networks against Bidirectional LSTMs (BiLSTM). Furthermore, we propose two novel attention extensions designed to operate harmoniously with recurrent temporal representations: a Modified Attention Mechanism that incorporates explicit bias terms and hyperbolic tangent activation, and a Modified Multihead Attention mechanism utilizing parallel attention projections combined with element-wise summation and non-linear compression. To address the 1:41 class imbalance, we formulate a Weighted Binary Cross-Entropy (WBCE) loss that penalizes false negatives on active notes.
Through extensive experiments on the MAPS [9] and MAESTRO [10] benchmark datasets, we systematically evaluate 7 distinct model configurations. Our best proposed model—a Multihead Attention-Bidirectional LSTM network—achieves an F1-score of 88.20% and an overall accuracy of 78.90% with only 4.43M trainable parameters, establishing an effective, lightweight solution for polyphonic music transcription.
2.1 Classical Signal Processing and Matrix Factorization
Research in automated music analysis traces back to the pioneering works of Moorer [11, 12], who explored computer-based sound segmentation and transcription of continuous musical signals. Goto and Muraoka [13] subsequently pioneered real-time beat tracking and rhythm parsing from acoustic mixtures. Over the subsequent decades, multi-pitch estimation (MPE) focused on hand-crafted spectral representations and unsupervised decomposition. Prominent paradigms included non-negative matrix factorization (NMF) and its extensions [14, 4, 5], probabilistic spectral smoothness models [3], multiple fundamental frequency estimation via spectral peak/non-peak classification [15], and Bayesian generative spectrogram factorizations [16, 17]. While these methods offered sound mathematical interpretability, they struggled to generalize to expressive dynamics and dense polyphony without rigid acoustic priors.

Figure 1: Data representation pipeline in an Automatic Music Transcription (AMT) system. The input acoustic waveform is transformed into a time-frequency representation, parameterized into frame-level feature vectors, processed by a sequence-modeling acoustic and temporal network, and decoded into active pitch activations (MIDI/piano roll representation) [1].
2.2 Supervised Machine Learning and Deep Neural Networks
The advent of supervised discriminative learning marked a paradigm shift in AMT. Poliner and Ellis [18] deployed an ensemble of 87 binary Support Vector Machines (SVMs) followed by a Hidden Markov Model (HMM) for temporal smoothing, demonstrating that learning pitch-specific decision boundaries from data outperformed hand-crafted acoustic heuristics.
With the deep learning resurgence, neural architectures rapidly advanced AMT performance. Sigtia et al. [6, 19] introduced an end-to-end neural framework combining a convolutional neural network (CNN) acoustic front-end with an RNN language model to capture note transition semantics. Kelz et al. [20] provided an influential study on simple framewise CNN approaches, demonstrating that high-capacity convolutional models could achieve competitive framewise transcription without explicit language modeling. Ullrich and van der Wel [21] advanced sequence-to-sequence convolutional networks for polyphonic score estimation.
Subsequent studies by Morán [22] and Li et al. [23] examined feed-forward Deep Neural Networks (DNN) and LSTM networks for framewise piano transcription, identifying the challenge of training stability and noting that simple recurrent networks often suffered from under-fitting or slow convergence when trained with mean squared error (MSE) loss and sub-optimal activation functions. Our work directly builds upon and resolves these limitations by introducing specialized attention modules, multi-label probabilistic loss functions, and bidirectional processing.
Table 1: Data split distribution for the MAPS and MAESTRO benchmark datasets.
| Dataset | Train | Validation | Test |
|---|---|---|---|
| MAESTRO [10] | 962 | 174 | — |
| MAPS [9] | 23,928 | 2,991 | 2,991 |
Table 2: Sample extract of ground truth note event annotations pairing onset time, offset time, and MIDI pitch.
| Onset Time (s) | Offset Time (s) | MIDI Pitch |
|---|---|---|
| 0.988281 | 1.111979 | 34 (A#1) |
| 1.109375 | 1.135417 | 53 (F3) |
| 1.109375 | 1.161458 | 62 (D4) |
| 1.153646 | 1.196615 | 58 (A#3) |
| 1.518229 | 1.549479 | 74 (D5) |
| 1.527344 | 1.563802 | 62 (D4) |
| 1.533854 | 1.566406 | 58 (A#3) |
| 1.539062 | 1.566406 | 82 (A#5) |
| 1.518229 | 1.567708 | 86 (D6) |
| 1.540365 | 1.578125 | 53 (F3) |
2.3 Attention Mechanisms in Sequence Modeling
Attention mechanisms, first introduced in machine translation by Bahdanau et al. [24], resolved the information bottleneck of fixed-size recurrent context vectors by enabling decoders to dynamically attend to relevant encoder hidden states across arbitrary temporal distances. Vaswani et al. [25] generalized this concept into the Multi-Head Attention and Transformer architectures, proving that multi-subspace projections allow models to jointly attend to information from different representation subspaces. In audio and music processing, attention mechanisms have become indispensable for capturing long-range harmonic and temporal correlations across disparate musical measures. In this paper, we adapt these mechanisms into modified recurrent attention blocks optimized for frame-level spectral inputs.
3 Dataset and Preprocessing
3.1 Dataset Description
To evaluate our transcription models on polyphonic piano compositions across diverse acoustic conditions, we utilize two publicly accessible benchmark datasets:
-
MAPS Database (MIDI Aligned Piano Sounds) [9]: MAPS contains high-fidelity audio recordings of classical piano pieces, chords, and isolated notes produced by upright and grand pianos (both physical instruments and high-grade software synthesizers). Each audio file is paired with ground truth text annotations specifying the exact onset time, offset time, and MIDI pitch for every note.
-
MAESTRO Dataset (MIDI and Audio Edited for Synchronous Tracks and Organization) [10]: MAESTRO encompasses over 200 hours of virtuosic piano performances collected from ten years of the International Piano-e-Competition. The audio is captured from Yamaha Disklavier concert grands with sub-3 ms alignment between MIDI events and acoustic waveforms.
The datasets are partitioned into training, validation, and test splits following standard evaluation protocols. As detailed in Table 1, the MAPS dataset comprises 23,928 training files, 2,991 validation files, and 2,991 test files. The MAESTRO dataset provides 962 training compositions and 174 validation pieces.
3.2 Audio Preprocessing and Constant-Q Transform
Raw audio waveforms stored in uncompressed .wav format are standardized to a sampling rate of kHz. Multichannel signals are down-mixed to mono by computing the channel-wise arithmetic mean:

Figure 2: Piano keyboard layout spanning 88 keys and 7 complete octaves. Fundamental frequencies range from A0 (27.5 Hz) to C8 (4186.01 Hz), geometrically spaced according to the equal-tempered scale.

Figure 3: Constant-Q Transform (CQT) spectrogram. The log-frequency axis maintains constant musical interval spacing across octaves, providing sharp resolution for fundamental frequencies in the lower register.
While the Short-Time Fourier Transform (STFT) and Mel-Frequency Cepstral Coefficients (MFCC) are popular in general audio processing, they possess notable shortcomings for music transcription. The STFT enforces a uniform frequency resolution across the entire spectrum, which produces insufficient frequency resolution at low frequencies (where adjacent piano semitones differ by only a few Hertz) and redundant resolution at high frequencies. Conversely, MFCCs discard fine harmonic partial structures vital for multi-pitch disambiguation.
To align the spectral analysis with musical acoustics, we compute the Constant-Q Transform (CQT) [7]. The CQT employs geometrically spaced frequency bins where the ratio of center frequency to bandwidth remains constant:
where denotes the number of bins per octave. In our implementation, the CQT is evaluated across 7 octaves with bins per octave (yielding 3 bins per semitone for pitch nuance) and a hop size of samples (corresponding to a temporal resolution of ms per frame). The resulting spectral feature vector at each time frame comprises:
The continuous spectrogram is depicted in Figure 3. Audio frames are grouped into continuous chunks of 40,000 frames to facilitate uniform batch tensor operations during training.
3.3 Ground Truth Label Formulation and Data Imbalance
The ground truth text files report musical events characterized by triplets:langle, offset, pitch), as exemplified in Table 2. Because a standard piano comprises 88 keys spanning MIDI pitch numbers 21 (A0, 27.5 Hz) to 108 (C8, 4186.01 Hz) (Figure 2), we formulate the transcription target as a frame-level binary vector:

(a) Sparse pitch activations
(b) Polyphonic chord events
(c) Sustained note transitions
Figure 4: Visual illustration of frame-level multi-label ground truth matrices . Rows correspond to the 88 piano pitches and columns represent consecutive time frames.

Figure 5: Class distribution imbalance in the training corpus. Inactive pitch labels (0) total 5.36 billion instances, whereas active pitch labels (1) total 0.129 billion instances, establishing a severe ratio of approximately 41:1.
where indicates that pitch is sounding at time frame , and otherwise. Stacking these vectors across time produces the binary piano-roll representation shown in Figure 4.
Data Imbalance Insight: Statistical auditing of the compiled training corpus reveals an acute class imbalance. As shown in Figure 5, the aggregate count of inactive labels reaches , whereas active notes account for only entries. The resulting ratio of negative-to-positive instances is approximately:
If left unaddressed, standard neural models trained with unweighted cross-entropy converge toward a trivial local optimum that predicts zeros across all pitches, yielding superficially high unweighted accuracy but near-zero recall. This empirical insight directly motivates our loss formulation in Section 4.
4 Proposed Methodology
4.1 Mathematical Formulation of the Constant-Q Transform
The discrete Constant-Q Transform of a discrete-time signal is formulated as:
where denotes the frequency bin index, is a window function (e.g., Hamming window) of length , and the window length varies inversely with the bin center frequency :
By scaling inversely with frequency, lower octaves utilize longer temporal windows to achieve fine spectral separation, while higher octaves utilize shorter windows to capture rapid transient percussive attacks.

Figure 6: Internal architecture of the Long Short-Term Memory (LSTM) cell. The cell state serves as a constant-error conveyor belt regulated by the forget gate , input gate , and output gate [8].
4.2 Recurrent Base Networks
4.2.1 Long Short-Term Memory (LSTM)
Standard Recurrent Neural Networks (RNNs) maintain a hidden state vector . However, when backpropagated over extended sequences, gradient magnitudes vanish or explode exponentially [8], preventing vanilla RNNs from learning long-term musical dependencies such as cadential closures or sustained notes.
The LSTM architecture overcomes this by introducing an explicit cell state vector regulated by three multiplicative gating mechanisms (Figure 6). At time step , given input feature vector and previous hidden state , the forward computations are:
where denotes the logistic sigmoid activation, represents the Hadamard (element-wise) product, and denotes tensor concatenation.
4.2.2 Bidirectional LSTM (BiLSTM)
Unidirectional LSTMs process musical signals strictly chronologically ( ). In musical compositions, however, the harmonic function of a note is frequently clarified by its subsequent resolution (e.g., a dominant seventh chord resolving to a tonic chord). Bidirectional LSTMs (BiLSTM) process the sequence in both forward and backward directions using two independent hidden layers (Figure 7):
The combined representation at frame t is formed by concatenation:
The aggregated probability vector combines the forward and backward predictions:
4.3 Attention Mechanisms for Music Transcription
4.3.1 Baseline Additive Attention (Bahdanau)
The classical additive attention mechanism [24] computes alignment scores between encoder hidden states and the decoder query state :

Figure 7: Bidirectional Long Short-Term Memory architecture. The input sequence is processed concurrently in both chronological (forward) and reverse (backward) temporal directions.
where , and are learnable projection matrices. Normalized attention weights are obtained via the softmax operator:
and the context vector is computed as the weighted sum:
4.3.2 Proposed Modified Attention Mechanism
Standard additive attention was originally formulated for sequence-to-sequence text generation with variable input/output lengths. In frame-level AMT, input spectral frames and output prediction vectors are temporally synchronized. To tailor attention to this dense setting, we introduce a bias parameter and wrap the full alignment function within a bounded hyperbolic tangent operator:
The bounded range prevents extreme logit divergences in frame-level spectral attention. Attention weights are computed via softmax:
and the resulting context vector is obtained by modulating the hidden state:
4.3.3 Proposed Modified Multihead Attention Mechanism
In Transformer architectures [25], standard Multi-Head Attention computes scaled dot-product attention over parallel projections:
followed by concatenation:
To integrate multihead capacity into recurrent latent representations without excessive parameter inflation, we propose the Modified Multihead Attention module illustrated in Figure 8. Instead of scaled dot-product operations, each head computes alignment using our modified attention formulation (Equation 21). Rather than concatenating heads, the head outputs are aggregated via summation, transformed by a projection matrix and bias , and passed through a hyperbolic tangent activation:

Figure 8: Proposed Modified Multihead Attention module. Parallel attention heads compute subspace alignment scores, which are summed, projected via with bias , and activated by hyperbolic tangent before softmax normalization.
The final attention weights and context vectors are derived as:
This structure enables the network to attend to complementary spectral sub-bands and temporal dependencies across multiple projection subspaces simultaneously.
4.4 Activation and Loss Functions
4.4.1 Activation Functions
For hidden layers and attention projections, the hyperbolic tangent activation function is utilized:
mapping activations to . For the final transcription output layer, each of the 88 pitch nodes employs the independent sigmoid activation function:
where denotes the predicted probability that pitch is sounding at time frame . Unlike the softmax function (which imposes a categorical probability distribution summing to 1 and assumes monophony), independent sigmoid activations naturally accommodate arbitrary polyphonic note combinations.
4.4.2 Binary Cross-Entropy (BCE)
Standard Binary Cross-Entropy treats all pitch predictions uniformly across frames:
4.4.3 Weighted Binary Cross-Entropy (WBCE)
Given the severe 41:1 class imbalance documented in Section 3, standard BCE penalizes false positives and false negatives symmetrically, causing models to favor all-zero outputs. To counteract this, we employ Weighted Binary Cross-Entropy (WBCE):
where and represent positive (active note) and negative (inactive note) weighting parameters. In our benchmark experiments, we configure and , placing higher penalty on missed notes to drive aggressive recall recovery.
4.5 Post-Processing and Evaluation Metrics
4.5.1 Post-Processing
Raw model probabilities are binarized using a threshold . To refine the frame-level output into clean symbolic notes, we apply a lightweight morphological post-processing filter:
-
Minimum Duration Thresholding: Active note segments shorter than a minimum threshold (e.g., < 3 frames, ≈ 35 ms) are eliminated as spurious acoustic noise.
-
Gap Filling: Gaps of 1 to 2 frames between consecutive activations of the same pitch are bridged to eliminate false note-off events caused by temporary harmonic dips.
4.5.2 Evaluation Metrics
Model transcription accuracy is quantified using frame-level Precision, Recall, Accuracy, and F1-score:
where TP, FP, and FN denote the aggregate counts of True Positives, False Positives, and False Negatives, respectively, computed across all 88 pitches over the test corpus.

(a) Baseline LSTM [22]

(b) Modified Base LSTM (Ours)
Figure 9: Architectural transition from baseline to modified base model. Replacing MSE loss with WBCE and ReLU with Sigmoid eliminates saturation and enables effective multi-label learning.
5 Experimental Configurations and Architectures
To systematically dissect the contribution of each architectural innovation, we implement and benchmark seven sequential model configurations under identical training protocols:
5.1 Model 1: Base Unidirectional LSTM
Following the baseline setup of Morán [22], the architecture consists of 3 stacked unidirectional LSTM layers with 256 hidden units per layer, each followed by a Dropout layer with rate . In contrast to [22] (which used MSE loss and ReLU outputs), our modified baseline adopts Sigmoid output activations and WBCE loss (Figure 9). Total parameters: 1.59M.
5.2 Model 2: Bidirectional LSTM (BiLSTM)
The 3 unidirectional LSTM layers are replaced with 3 Bidirectional LSTM layers (Figure 10a). Each BiLSTM layer contains 256 forward units and 256 backward units (512 total hidden units per layer), followed by Dropout (). Total parameters: 4.24M.
5.3 Model 3: LSTM-Attention
Following the architecture of Bahdanau et al. [24], an attention layer is placed between two recurrent stages: an initial LSTM layer (256 units), our Modified Attention module, and two subsequent LSTM layers (256 units each) with Dropout () (Figure 10b). Total parameters: 1.66M.
5.4 Model 4: Bidirectional LSTM-Attention
Extending Model 3, all LSTM layers are converted to Bidirectional LSTM layers (512 units per layer) flanking the Modified Attention module. Dropout is set to (Figure 10c). Total parameters: 4.35M.
5.5 Model 5: Attention-LSTM
Inspired by the Transformer paradigm where attention operates at the front of processing, we position the Modified Attention module at the input stage directly over the CQT spectral representations. The attended representations are subsequently processed by 3 stacked LSTM layers (256 units each), followed by a dense linear projection layer prior to the Sigmoid classifier (Figure 10d). Total parameters: 1.66M.
5.6 Model 6: Attention-Bidirectional LSTM
Retaining the front-end Attention placement from Model 5, the recurrent backbone is upgraded to 3 BiLSTM layers (512 units each) with Dropout () and linear projection (Figure 10e). Total parameters: 4.35M.

(a) Bidirectional LSTM

(b) LSTM-Attention

(c) BiLSTM-Attention

(d) Attention-LSTM

(e) Attention-BiLSTM

(f) Multihead Attention-BiLSTM
Figure 10: Systematic architectural configurations investigated in this study. (a) Bidirectional LSTM; (b) Interleaved LSTM-Attention; (c) Interleaved BiLSTM-Attention; (d) Input Attention-LSTM; (e) Input Attention-BiLSTM; (f) Proposed Multihead Attention-BiLSTM architecture.
Table 3: Comprehensive benchmark evaluation of transcription models. Precision, Recall, Accuracy (%), and F1-score (%) on the polyphonic piano test dataset.
| Model Architecture | Parameters | Precision | Recall | Accuracy (%) | F1-score (%) |
|---|---|---|---|---|---|
| LSTM (Base Model) [22] | 1.59M | 0.76 | 0.66 | 55.20 | 71.20 |
| Bidirectional LSTM | 4.24M | 0.77 | 0.74 | 61.20 | 75.98 |
| LSTM–Attention | 1.66M | 0.74 | 0.75 | 59.80 | 74.80 |
| Bidirectional LSTM–Attention | 4.35M | 0.80 | 0.83 | 69.50 | 82.00 |
| Attention–LSTM | 1.66M | 0.80 | 0.84 | 69.80 | 82.20 |
| Attention–Bidirectional LSTM | 4.35M | 0.84 | 0.88 | 75.50 | 86.10 |
| Multihead–Bidirectional LSTM (WBCE) | 4.43M | 0.84 | 0.90 | 77.30 | 87.20 |
| Multihead–BiLSTM + BCE (Best Model) | 4.43M | 0.89 | 0.86 | 78.90 | 88.20 |
| Multihead–BiLSTM (Single Dataset: MAPS only) | 4.43M | 0.83 | 0.87 | 74.50 | 85.40 |
5.7 Model 7: Multihead Attention–Bidirectional LSTM (Proposed Best Model)
Replacing the single-head attention module of Model 6, we deploy our Modified Multihead Attention module (Equation 26) configured with parallel attention heads. The multi-head context representations feed into 3 BiLSTM layers (512 units each), a dense linear layer, and the 88-dimensional Sigmoid output classifier (Figure 10f). Total parameters: 4.43M.
5.8 Training Protocol and Optimization
All models are implemented in PyTorch and optimized using the Adam optimizer with an initial learning rate of and default momentum parameters (). Training is monitored via validation loss with early stopping configured at a patience of 10 epochs to prevent over-fitting.
6 Results and Comparative Analysis
6.1 Quantitative Performance Comparison
Table 3 reports the quantitative transcription performance across all 7 evaluated models, along with ablation variants examining loss functions and training data diversity.
Several key findings emerge from the empirical results:
-
Impact of Bidirectional Context: Transitioning from unidirectional LSTM to Bidirectional LSTM produces an immediate gain of +4.78% in F1-score (from 71.20% to 75.98%) and +6.00% in accuracy. This confirms that backward temporal context is critical for resolving pitch ambiguities.
-
Attention Placement Matters: Placing the attention module at the input front-end (Attention–LSTM, F1: 82.20%) substantially outperforms placing it between recurrent layers (LSTM–Attention, F1: 74.80%), yielding a +7.40% margin. Input-level attention enables the model to selectively filter relevant spectral bins prior to recurrent temporal integration.
-
Synergy of Multihead Attention and BiLSTM: Combining front-end multihead attention with BiLSTM layers achieves an F1-score of 87.20% under WBCE. The 3 attention heads independently attend to low-register fundamentals, mid-range chord harmonies, and upper partials.
-
Loss Function Tuning: When using the Multihead–BiLSTM architecture, standard BCE achieves the highest overall accuracy (78.90%) and F1-score (88.20%), improving precision from 0.84 to 0.89. While WBCE maximizes recall (0.90) by heavily penalizing false negatives, it introduces a slight increase in false positive detections, whereas BCE provides a superior precision-recall balance once the model capacity is sufficiently high.
-
Dataset Diversity: Restricting training exclusively to the MAPS dataset reduces F1-score to 85.40% (a 2.80% drop), demonstrating that co-training on MAPS and MAESTRO enhances generalizability across diverse piano timbres and recording environments.

(a) Base Model: Training Loss

(b) Base Model: Training Accuracy

(c) Best Model: Training Loss

(d) Best Model: Training Accuracy
Figure 11: Training dynamics of Base Model (LSTM) versus Best Model (Multihead Attention–BiLSTM). The proposed best model converges to a substantially lower training loss while maintaining rapid, steady accuracy improvements without over-fitting.
6.2 Training Dynamics
Figure 11 illustrates the training loss and accuracy trajectories for the baseline LSTM versus the proposed Multihead Attention–BiLSTM. The baseline LSTM exhibits slower convergence and plateauing accuracy around 55%. In contrast, the Multihead Attention–BiLSTM demonstrates steep loss descent and steady accuracy escalation reaching nearly 80%, benefiting from stabilized gradient propagation via the tanh-bounded multihead attention module.
6.3 Qualitative Piano-Roll Visualizations
Figure 12 displays qualitative transcription predictions against the ground truth piano roll. The baseline LSTM (Figure 12a) suffers from substantial temporal fragmentation, spurious dropouts in sustained notes, and missed pitches in dense polyphonic intervals. In contrast, the predictions generated by our Multihead Attention–BiLSTM model (Figure 12b) closely match the ground truth (Figure 12c), preserving continuous pitch contours and precisely capturing polyphonic chord onsets.

(a) Predicted transcription: Base Model (LSTM)

(b) Predicted transcription: Best Model (Multihead Attention-BiLSTM)

(c) Ground Truth piano-roll annotation
Figure 12: Visual comparison of transcribed piano rolls against Ground Truth. The Base Model exhibits substantial temporal fragmentation and missed notes, whereas our Best Model closely reconstructs note onsets, sustained durations, and polyphonic chords.
6.4 Ablation Studies
6.4.1 Weighted BCE versus Standard BCE
Figure 13 compares piano-roll outputs generated under WBCE versus standard BCE. While WBCE successfully prevents the network from collapsing into all-zero predictions during early training and maximizes recall (0.90), its higher positive weighting can induce faint ghost activations during soft reverberant decays. Standard BCE, when applied to our high-capacity attention architecture, effectively suppresses background noise while maintaining high precision (0.89), resulting in an optimal overall F1-score of 88.20%.

(a) Prediction: Multihead–BiLSTM with Weighted Binary Cross-Entropy (WBCE)

(b) Prediction: Multihead–BiLSTM with standard Binary Cross-Entropy (BCE)

(c) Ground Truth annotation
Figure 13: Qualitative ablation of loss formulation: WBCE versus standard BCE. WBCE promotes higher sensitivity but introduces occasional background noise, whereas BCE achieves cleaner background suppression with high harmonic fidelity.
6.4.2 Single Dataset versus Multi-Dataset Training
Figure 14 compares the model trained solely on MAPS against the model trained on both MAPS and MAESTRO. The single-dataset model exhibits sporadic false detections in the upper register, where overtone partials from lower octaves are mistakenly classified as independent notes. The multi-dataset model resolves these partial collisions more effectively, demonstrating the benefits of diverse training acoustics.

(a) Prediction: Multihead–BiLSTM trained on Combined Datasets (MAPS + MAESTRO)

(b) Prediction: Multihead–BiLSTM trained on Single Dataset (MAPS only)

(c) Ground Truth annotation
Figure 14: Qualitative ablation of dataset diversity: Combined Datasets versus Single Dataset. Training on both MAPS and MAESTRO provides broader acoustic exposure, reducing false insertions in higher octaves.
7 Discussion and Limitations
While our proposed Multihead Attention–BiLSTM model achieves competitive transcription performance with a lightweight architecture (4.43M parameters), qualitative error analysis reveals several remaining challenges:
-
Dense Polyphony and Octave Collisions: When multiple notes sharing exact harmonic intervals (e.g., octaves, fourths, fifths) sound concurrently, the fundamental frequency of the upper note coincides with a strong harmonic overtone of the lower note. In passages with high polyphonic density, the model occasionally misattributes lower partial energy to secondary notes or misses soft inner chord voices.
-
Tremolo and Rapid Articulations: In tremolo passages where a performer rapidly repeats a single pitch, acoustic energy decays and builds within short intervals. Because CQT temporal integration and hop size introduce a frame resolution of ≈ 11.6 ms, rapid re-attacks can blur into a single continuous activation contour.
-
Up-Tempo Passages: In virtuoso prestissimo compositions, note durations may span only 3 to 5 frames. Any minor misalignment in frame-level boundaries can exert a disproportionate impact on precision and recall metrics.
-
Heuristic Post-Processing: Our current post-processing relies on fixed minimum-duration thresholds and small-gap filling. Incorporating a trainable language model or Hidden Markov Model (HMM) could provide context-aware temporal smoothing without manual threshold tuning.
8 Conclusion and Future Work
In this paper, we presented a learning-based framework for polyphonic piano transcription that combines log-frequency Constant-Q Transform representations with Bidirectional LSTMs and specialized attention mechanisms. We designed a modified additive attention module and a modified multihead attention mechanism with hyperbolic tangent compression tailored to recurrent hidden states. Furthermore, we formulated a Weighted Binary Cross-Entropy loss to counteract the acute 41:1 negative-to-positive class imbalance. Systematic experiments across seven model variants on the MAPS and MAESTRO benchmarks proved that front-end attention combined with bidirectional temporal modeling achieves strong transcription accuracy: our Multihead Attention-BiLSTM model reached an F1-score of 88.20% and an accuracy of 78.90% with only 4.43M parameters.
Future work will explore hybrid convolutional-recurrent architectures (CRNNs) to learn adaptive low-level spectro-temporal filters directly from waveforms, multi-task learning incorporating joint onset, sustain, and velocity prediction heads, and transformer-based autoregressive music language models for score refinement.
Acknowledgments
We express sincere gratitude to Mr. Nguyen Quoc Trung and Mr. Le Phu Nguyen for their constructive feedback and insightful technical reviews.
Author Contributions
Do Phu Anh Tai: Conceptualization, lead research on recurrent deep learning architectures for AMT, and model development.
Nguyen Huu Hoang: Design and implementation of the modified attention and modified multihead attention mechanisms, and initial manuscript preparation.
Nguyen Duc Hoang: Development of the data preprocessing pipeline (CQT feature extraction, audio segmentation, multi-label annotation formatting), and manuscript review.
Le Thanh Hai: Research supervision, methodology refinement, project administration, and final manuscript editing. All authors have reviewed and approved the final manuscript.
Conflicts of Interest
The authors declare no conflicts of interest regarding the publication of this paper.
References
[1] Emmanouil Benetos, Simon Dixon, Zhiyao Duan, and Sebastian Ewert. Automatic music transcription: An overview. IEEE Signal Processing Magazine, 36(1):20–30, 2018.
[2] Anssi Klapuri. Introduction to music transcription. Technical report, Institute of Signal Processing, Tampere University of Technology, Tampere, Finland, 2006.
[3] Valentin Emiya, Roland Badeau, and Bertrand David. Multipitch estimation of piano sounds using a new probabilistic spectral smoothness principle. IEEE Transactions on Audio, Speech, and Language Processing, 18 (6):1643–1654, 2010.
[4] Emmanuel Vincent, Nancy Bertin, and Roland Badeau. Adaptive harmonic spectral decomposition for multiple pitch estimation. IEEE Transactions on Audio, Speech, and Language Processing, 18(3):528–537, 2010.
[5] Emmanouil Benetos and Simon Dixon. Multiple-instrument polyphonic music transcription using a temporally-constrained shift-invariant model. The Journal of the Acoustical Society of America, 133(3):1727–1741, 2013.
[6] Siddharth Sigtia, Emmanouil Benetos, and Simon Dixon. An end-to-end neural network for polyphonic piano music transcription. IEEE/ACM Transactions on Audio, Speech, and Language Processing, 24(5):927–939, 2016.
[7] Judith C. Brown. Calculation of a constant Q spectral transform. The Journal of the Acoustical Society of America, 89(1):425–434, 1991.
[8] Sepp Hochreiter and Jürgen Schmidhuber. Long short-term memory. Neural Computation, 9(8):1735–1780, 1997.
[9] Valentin Emiya, Nancy Bertin, Bertrand David, and Roland Badeau. MAPS database: A piano database for multipitch estimation and automatic transcription of music. https://adasp.telecom-paris.fr/resources/2010-07-08-maps-database/, 2010.
[10] Curtis Hawthorne, Andriy Stasyuk, Adam Roberts, Ian Simon, Cheng-Zhi Anna Huang, Sander Dieleman, Erich Elsen, Jesse Engel, and Douglas Eck. Enabling factorized piano music modeling and generation with the MAESTRO dataset. In International Conference on Learning Representations (ICLR), 2019.
[11] James Anderson Moorer. On the Segmentation and Analysis of Continuous Musical Sound by Digital Computer. PhD thesis, Stanford University, 1975.
[12] James Anderson Moorer. On the transcription of musical sound by computer. Computer Music Journal, 2(1): 7–11, 1977.
[13] Masataka Goto and Yoichi Muraoka. A beat tracking system for acoustic signals of music. In Proceedings of the Second ACM International Conference on Multimedia, pages 365–372, 1994.
[14] Paris Smaragdis and Judith C. Brown. Non-negative matrix factorization for polyphonic music transcription. In IEEE Workshop on Applications of Signal Processing to Audio and Acoustics (WASPAA), pages 177–180, 2003.
[15] Zhiyao Duan, Bryan Pardo, and Changshui Zhang. Multiple fundamental frequency estimation by modeling spectral peaks and non-peak regions. IEEE Transactions on Audio, Speech, and Language Processing, 18(8): 2121–2133, 2010.
[16] Peter H. Peeling, Ali Taylan Cemgil, and Simon J. Godsill. Generative spectrogram factorization models for polyphonic piano transcription. IEEE Transactions on Audio, Speech, and Language Processing, 18(3):519–527, 2010.
[17] Bernardo Fuentes, Roland Badeau, and Gaël Richard. Harmonic adaptive latent component analysis of audio and application to music transcription. IEEE Transactions on Audio, Speech, and Language Processing, 21(9): 1854–1866, 2013.
[18] Graham E. Poliner and Daniel P. W. Ellis. A discriminative model for polyphonic piano transcription. EURASIP Journal on Applied Signal Processing, 2007(1):154–154, 2007.
[19] Siddharth Sigtia, Emmanouil Benetos, and Simon Dixon. An end-to-end neural network for polyphonic piano music transcription. arXiv preprint arXiv:1508.01774, 2015.
[20] Rainer Kelz, Matthias Dorfer, Filip Korzeniowski, Sebastian Böck, Andreas Arzt, and Gerhard Widmer. On the potential of simple framewise approaches to piano transcription. In Proceedings of the 17th International Society for Music Information Retrieval Conference (ISMIR), pages 475–481, 2016.
[21] Karen Ullrich and Erik van der Wel. Music transcription with convolutional sequence-to-sequence models. In Proceedings of the 18th International Society for Music Information Retrieval Conference (ISMIR), pages 464–471, 2017.
[22] Diego González Morán. Deep neural networks for piano music transcription. https://github.com/diegomorin8/Deep-Neural-Networks-for-Piano-Music-Transcription, 2017.
[23] Luoqi Li, Isabella Ni, and Liang Yang. Music transcription using deep learning. Stanford University CS229 Final Project Report, 2017.
[24] Dzmitry Bahdanau, Kyunghyun Cho, and Yoshua Bengio. Neural machine translation by jointly learning to align and translate. In International Conference on Learning Representations (ICLR), 2015.
[25] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. In Advances in Neural Information Processing Systems (NeurIPS), volume 30, pages 5998–6008, 2017.