Fugue in C Minor, BWV 847 by J.S. Bach

Source Notebook

Fugue number 2 in C Minor from the Well-Tempered Clavier, composed by Johann Sebastian Bach

Details

This data resource requires Wolfram Language version 15 or higher.
The data is represented as a MusicScore object.
The fugue is a keyboard composition written by Johann Sebastian Bach included in the first book of The Well-Tempered Clavier. The Well-Tempered Clavier is a collection of preludes and fugues written by the composer in the 1720s.

Examples

Basic Examples (2) 

In[1]:=
ResourceData[\!\(\*
TagBox["\"\<Fugue in C Minor, BWV 847 by J.S. Bach\>\"",
#& ,
BoxID -> "ResourceTag-Fugue in C Minor, BWV 847 by J.S. Bach-Input",
AutoDelete->True]\)]
Out[1]=

Find the lowest and highest pitch in the composition:

In[2]:=
MusicMeasurements[ResourceData[\!\(\*
TagBox["\"\<Fugue in C Minor, BWV 847 by J.S. Bach\>\"",
#& ,
BoxID -> "ResourceTag-Fugue in C Minor, BWV 847 by J.S. Bach-Input",
AutoDelete->True]\)], "Ambitus"]
Out[2]=

Visualizations (1) 

Plot the composition:

In[3]:=
MusicPlot[ResourceData[\!\(\*
TagBox["\"\<Fugue in C Minor, BWV 847 by J.S. Bach\>\"",
#& ,
BoxID -> "ResourceTag-Fugue in C Minor, BWV 847 by J.S. Bach-Input",
AutoDelete->True]\)]]
Out[3]=

Analysis (4) 

Find the key of the composition:

In[4]:=
score = ResourceData[\!\(\*
TagBox["\"\<Fugue in C Minor, BWV 847 by J.S. Bach\>\"",
#& ,
BoxID -> "ResourceTag-Fugue in C Minor, BWV 847 by J.S. Bach-Input",
AutoDelete->True]\)];
MusicMeasurements[score, "EstimatedKey"]
Out[5]=

Normalize the accidentals in the score to match the estimated key:

In[6]:=
MusicTransform[score, {"NormalizeAccidentals", %}]
Out[6]=

Plot histograms of the notes for each of the voices:

In[7]:=
Histogram[
 Map[Flatten, MusicMeasurements[score, {"NoteList", "MIDINumber"}]], {1}]
Out[7]=

Show the relative occurrences of different pitch classes:

In[8]:=
RadialAxisPlot[
 KeySort[Counts[
   Flatten[MusicMeasurements[score, {"NoteList", "PitchClass"}]]]]]
Out[8]=

Wolfram Research, "Fugue in C Minor, BWV 847 by J.S. Bach" from the Wolfram Data Repository (2026)  

Data Resource History

Source Metadata

Publisher Information