An Introduction to Markov Chains: Machine Learning in Max

Get to grips with the basics of Markov Chains and begin using them to generate music.

Course Instructor: Samuel Pearce Davies

Course level


Unlock full course & much more:

Getting Started

Going Deeper

Compare membership plans

Or just buy this single course:

£ 9.9

Markov chains are mathematical models that have existed in various forms since the 19th century, which have been used to aid statistical modelling in many real-world contexts, from economics to cruise control in cars. Composers have also found musical uses for Markov Chains, although the implied mathematical knowledge needed to implement them often appears daunting.

What you'll learn

  • In this workshop we will demystify the Markov Chain and make use of the popular library in Max/MSP to implement Markov Chains for musical composition. This will involve preparing and playing MIDI files into the system (as a form of Machine Learning) and capturing the subsequent output as new MIDI files. By the end of the session you will have the knowledge of how to incorporate Markov Chains into your future compositions at various levels.


  • You should have a basic understanding of the Max workflow and different data types.
  • Knowledge of MIDI format and routing to DAWs (Ableton, Logic etc) would be a plus, although Max instruments will be provided.
  • No prior knowledge of advanced mathematical or machine learning concepts are necessary, the focus will be on musical application.

Course content

  • ---- Part 1 - A Non-Musical Probability Example
  • ---- Part 2 - Building a Basic Markov Chain from Scratch
  • ---- Part 3 - Implementing ml.markov and Using a Longer Melody to Explore Markov Chain Order
  • ---- Part 4 - Training on MIDI Data
  • ---- Part 5 - Increasing the Complexity of the Markov Chain Setup: Velocity
  • ---- Part 6 - Increasing the Complexity of the Markov Chain Setup: Chords
  • ---- Part 7 - Introducing the Finished Markov Chain with User Interface
  • ---- Part 8 - Blending Musical Data from Different MIDI Files
  • ---- Part 9 - Additional Examples and Blending

Who is this course for

  • This course is for musicians interested in getting creative with their compositions by using Markov Chains.

Useful links

About the workshop leader