Topics: Pythagoras (music, nature, and number), the Antikythera mechanism, Kepler’s harmony of the world, cymatics, fractals, electronic music, computers and programming, the computer as a musical instrument, running Python programs.
This chapter provides a quick tour of some of the major technological landmarks in Western music history and computer science. When we think of computer music, we usually imagine electronic technologies, particularly the synthesizer, computer, and sound recording devices. These devices are products of the information age in which we live. This age focuses on computational thinking, i.e., using computers in creative ways to manipulate data and perform various tasks, usually involving some form of programming. The introduction of computers and, in particular, computer programming has also expanded the sonic and structural boundaries of music composition and performance.
Below is the program from chapter 1.
Play a musical note
There are two ways to write Python code: directly into the interpreter, and using an editor.
The first way is easier for small programs that you intend to run only once. For example, if you want to perform a quick calculation, or if you want to create a melody consisting of a few notes, you may use the interpreter directly.
For a more substantial program (or a program that you intend to run many times) you should use an editor to type your code.
This code sample (Ch. 1, p. 22) demonstrates how to play a single musical note. Run it to test your Jython Music installation.
(To play a melody, see code samples in chapter 3.)
# 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!