Skip to content

Examples

JythonMusic supports music transcription and playback, audio looping, computer-aided music composition, development of computer-based musical instruments (including hybrid instruments), and live performance.


Here is a “Hello World!” program to get you started. It plays a single note.

playNote.py
1
2
3
4
5
6
7
# playNote.py
# Demonstrates how to play a single note.

from music import *        # import music library

note = Note(C4, HN)        # create a middle C half note
Play.midi(note)            # and play it!

To run it, download PythonMusic.


More examples

Additional code examples are organized by chapter:

Contents
Ch. 1 — Introduction and History
Ch. 2 — Elements of Music and Code
Ch. 3 — Organization and Data
Ch. 4 — Transformation and Process
Ch. 5 — Iteration and Lists
Ch. 6 — Randomness and Choices
Ch. 7 — Sonification and Big Data
Ch. 8 — Interactive Musical Instruments
Ch. 9 — Making Connections
Ch. 10 — Music, Number and Nature
Ch. 11 — Exploring Powerful Ideas