This book takes the reader on a journey through music concepts in an organized approach that develops music essentials from the concepts of tone, pitch, and time, through notes, intervals, chords, and scores while at the same time interpreting these elements as software artifacts. Close attention is paid to the organization of and relationships amongst these concepts and their representation as Python classes and objects, to learn about music from a software design viewpoint.The first part of the book focuses on software representation of the main elements found in music theory. Its objective is to provide direction to students on how to build a music software model from basic concepts and grow towards more complex concepts. Chapter by chapter, music concepts are introduced, and each is broken apart into related data properties and methods with the goal that by the end of this section, the reader will have developed a relatively complete library of music elements in software. The second part takes on the task of applying that foundation to the subject of “music transformations”. The focus is on localized transformations, that is, transformations isolated to a few measures. After a general introduction, the discussion includes topics of pitch assignment, key change, melodic inversion, melodic shaping, harmonic transcription, retrograde, melodic search and dilation.
This textbook is designed as a principal or supplemental source for computer science, software engineering, and programming courses. It can also be used as a main textbook for advanced computer music courses or electronic music courses. Computer music software professionals interested in learning how to model the complexities of music theory artifacts, or music students who want to learn advanced programming techniques in their domain will also find the book helpful.
Author(s): Donald P. Pazel
Edition: 1
Publisher: Springer
Year: 2022
Language: English
Pages: 353
Tags: Music Representation; Music Transformation; Python; Chromatic Scale; Intervals; Modality; Tonality; Scales; Time in Music; Notes; Chords; MIDI
Preface
Introduction
The Origin of this Book
Prerequisites and Approach
What this Book is Not About
Intended Audience
Students
Instructors
Practitioners
Experienced Researchers
Regarding the Musical Examples
About the Software
Acknowledgements
Contents
Part 1: Representation
1 Software Modeling and Object-Oriented Design
1.1 Object-Oriented Design by Example
1.2 A Concise Introduction to Python Classes
Properties
Multiple Inheritance
1.3 What Can Go Wrong in Object-Oriented Design
Over Abstraction
Concurrency and Side-effects
Still Requires Good Practice
1.4 The Meaning of Music Representation
2 The Chromatic Scale and the Diatonic Foundation
2.1 The Pythagorean Scale
2.2 Just Intonation and Equal-Tempered Chromatic Scales
2.2.1 The Chromatic Scale Representation
2.3 Tones, Pitches, and the Diatonic Foundation
2.3.1 Diatonic Tone Representation
2.3.2 DiatonicToneCache
2.3.3 Diatonic Pitch Representation
2.4 Exercises
3 Intervals
3.1 What is a Music Interval?
3.1.1 Compound Intervals
3.1.2 Interval Inversion
3.2 Interval Analytics
3.2.1 Negative Intervals
3.2.2 Interval Reduction
3.2.3 Inversions
3.2.4 Interval Addition
3.2.5 Afterword on Interval Operators
3.3 Interval Representation and Implementation
3.3.1 Negation, Inversion, and Reduction
3.3.2 Interval Addition and Operator Overloading
3.3.3 Exceptions
3.3.4 Computing Start and End Pitches
3.4 Examples
3.5 Exercises
4 Modality, Tonality, and Scales
4.1 Modality and Tonality
4.1.1 A Traditional Approach to Modality
4.1.2 An Intervallic Approach to Modality
4.1.3 Counterexamples
4.1.4 Modes, Derived Modalities and Modal Index
4.2 Modality and Tonality Representation
4.2.1 Defining and Creating Modality
4.2.2 System Modalities
4.2.3 Modality Factory
4.2.4 Modal Index, Incremental Intervals, and Tonal Scale
4.2.5 Tonality Representation
4.2.6 Pitch Scales
4.3 Exercises
5 Time in Music
5.1 Three Notions of Time in Music, an Introduction
5.2 Whole Note Time: Measuring Time in Fractions
5.3 Time Signature and Tempo
5.3.1 Time Signature
5.3.2 Tempo
5.4 Whole Time / Actual Time Conversions
5.5 Whole Time / Beat Time Conversion
5.6 Representational Considerations
5.6.1 Whole Note Time Representation
5.6.2 Position and Duration
5.6.3 Beat Position
5.6.4 TimeSignature and Tempo classes
5.6.5 The Time Conversion Algorithms
5.7 Exercises
6 The Note and Note Aggregates
6.1 Notes and Their Aggregative Partners
6.1.1 The Note
6.1.2 Beams
6.1.3 Tuplets
6.2 Representation
6.2.1 The Note Inheritance Hierarchy
6.2.2 Semantic Clarifications
6.3 Algorithms
6.3.1 Accessing Notes
6.3.2 Adding a Note
6.3.3 Reversing a Melody
6.4 Exercises
7 Chords
7.1 A Brief Introduction to Chords
7.1.1 Tertian Chord Types
7.1.2 Secundal Chord Types
7.1.3 Quartal Chord Types
7.1.4 Secondary Chord Types
7.2 Chord Template and Chord Representation
7.2.1 Template and Chord Class Design
7.2.2 Chord Construction
7.3 Chord Categories: Syntax and Examples
7.3.1 Tertian Chords
7.3.2 Secundal Chords
7.3.3 Quartal Chords
7.3.4 Secondary Chords
7.4 Exercises
8 Instruments
8.1 A Simple Genealogical Model for Instruments
8.2 A Software Model for an Instrument Catalog
8.3 The Instrument Catalog Class Model
8.3.1 Articulations
8.3.2 Accessing Instrument Data
8.3.3 The Instrument Catalog as Persistent Data
8.3.4 Instrument Catalog Initialization
8.4 Exercises
9 Score Representation
9.1 What is a Musical Score?
9.2 Score as a Class Model
9.2.1 Voices and Lines
9.2.2 Event Sequences for Tempo, Time Signature, and Dynamics
9.2.3 What Happened to Key Signature?
9.2.4 Putting It All Together
9.3 Time-Based Note Search
9.3.1 Red-Black Trees
9.3.2 Notes and Intervals
9.3.3 Interval Search Trees
9.3.4 Finding all Notes Sounding in an Interval
9.3.5 Finding All Notes Starting in an Interval
9.3.6 Adding Note Search to Score
9.4 Score Management
9.4.1 Interval Tree Update using the Observer Pattern
9.5 Final Remarks
9.6 Exercises
10 Rendering Score to MIDI
10.1 An Introduction to MIDI
10.1.1 Tracks, Channels, and Messages
10.1.2 Time Representation in MIDI
10.1.3 MIDI Messages
10.2 Mapping a Score to a MIDI File
10.3 Time Conversions
10.4 Score to MIDI Conversion Algorithms
10.5 Converting a Line to a MIDI File
10.6 Exercises
11 Variable Dynamics and Tempo
11.1 What are Variable Dynamics and Tempo?
11.1.1 An Introduction to Variable Dynamics and Tempo
11.2 Functions and Graphs
11.2.1 The Piecewise Linear Function
11.2.2 The Stepwise Function
11.2.3 The Constant Function
11.2.4 Generic Univariate Function
11.2.5 Domain Reset with Affine Transformations
11.3 Using Functions for Variable Tempo
11.3.1 Tempo Functions and the TempoEventSequence
11.3.2 Tempo Functions, MIDI Generation and Time Conversion
11.4 Using Variable Dynamics Functions
11.4.1 Details on Variable Dynamics Functions
11.4.2 Computing MIDI Velocity Events
11.5 Exercises
12 Further Representations
12.1 Harmonic Context
12.1.1 HarmonicContext and HarmonicContextTrack Representations
12.2 A Syntax for Constructing Music Structures
12.2.1 The Music Parser
12.2.2 A Music Syntax
Text Structure
Harmonic Notation
Note Notation
Beams and Tuplets
User-Defined Modalities
12.2.3Invoking the Parser in Code
12.3 LiteScore
12.4 Exercises
Part 2: Music Transformations
13 An Introduction to Music Transformations
13.1 What is a Music Transformation?
13.2 Outline on Transformations
13.3 A Word on Machine Learning
13.4 Moving Forward
14 A Constraint Engine for Pitch Assignment
14.1 Constraint Programming
14.2 Music Constraints and Solution Spaces
14.3 Music Constraint Programming Elements
14.3.1 PMaps
14.3.2 Constraints
14.3.3 Types of Constraints
Unary Constraints
Binary Constraints
Mulit-Actor Constraints
14.3.4 Invoking the Pitch Constraint Solver
14.4 Examples
14.5 Final Thoughts
15 Shift: A Transform for Key Change
15.1 An Overview of the Shift Transform
15.2 Structural Design of the Shift Transform
15.3 Tonal and Pitch Functions
15.3.1 Tonal Functions
15.3.2 CrossTonalityShiftTonalFunction
15.3.3 GeneralPitchFunction
15.3.4 CrossTonalityShiftPitchFunction
15.4 The Shift Transform
15.4.1 Problem Context and Interface
15.4.2 The Main Loop
15.4.3 Clarifying Shifting with Mode Change
15.4.4 Clarifying Shift with Secondary Chords
15.5 Examples
15.5.1 Simple Key Shift using Intervals
15.5.2 Shift with Modality Change
15.5.3 Modality and Modal Index Change
15.5.4 Modulating Sequence
15.6 Final Thoughts
16 Reflection: A Transform for Melodic Inversion
16.1 An Overview of Melodic Reflection
16.2 Permutations
16.2.1 Definition and Permutation Composition
16.2.2 Using Permutations
16.3 Class Structures for the Reflection Transform
16.4 Scalar Reflection
16.4.1 Scalar Reflection Details
16.4.2 TDiatonicReflection
16.4.3 Examples of Scalar Reflection
16.5 Chromatic Reflection
16.5.1 Chromatic Reflection Details
16.5.2 TChromaticReflection
16.5.3 Examples of Chromatic Reflection
16.6 Final Thoughts
17 Reshape: A Transform for Melodic Shaping
17.1 Introduction
17.2 A Model for Shaping Functions
17.2.1 Shaping Functions
17.2.2 The Pitch Range Interpreter
17.3 A Representation for Shaping Functions and Pitch Interpreters
17.3.1 The Pitch Range Interpreters, Description and Examples
17.3.2 Shaping Classes, Description and Examples
17.4 Melodic Forms and Constraints
17.5 The Reshape Transform
17.5.1 The TReshape Transform API
17.6 Examples
17.7 Final Thoughts
18 Harmonic Transcription: Preserving Melody over Harmonic Change
18.1 Introduction
18.2 Melodic Analysis for Similarity
18.2.1 Harmonic Role Analysis
18.2.2 Melodic Contour Analysis
18.2.3 Software Design
18.3 Further Constraining the Search Space
18.3.1 The Melodic Window
18.3.2 Melodic Variance (Tunnel)
18.4 The Harmonic Transcription Transform
18.5 Examples
18.6 Final Thoughts
19 Retrograde: Reversing a Melody
19.1 Introduction
19.2 The Retrograde Transform
19.2.1 The Retrograde Transform Design
19.2.2 The Retrograde Transform API
19.3 Examples
19.4 Final Thoughts
20 Melodic Search and Pattern Substitution
20.1 Melodic Search
20.1.1 Melodic Search Options
20.1.2 Melodic Search Technical Details
Search Setup
Search Algorithm Overview
Finer Details
20.1.3 Melodic Search API
20.1.4 Melodic Search Examples
20.2 The Melodic Pattern Substitution Transform
20.2.1 The Foundations of Melodic Pattern Substitution
20.2.2 An Approach to Melodic Pattern Substitution
20.2.3 Harmonic Context Expression Rules
20.2.4 The Melodic Pattern Substitution API
20.3 Examples
20.4Final Thoughts
21 Dilation: Musical Expansion and Contraction
21.1 A Discussion on Dilation
21.1.1 Dilation Dynamics
21.1.2 The Dilation Transform API
21.2Examples
21.3 Final Thoughts
22 The Step Shift Transform and Sequences
22.1 An Introduction to Step Shift
22.2 Step Shift Dynamics
22.2.1 Pitch Remap
22.2.3 Simple Chord Remap
22.2.3 Secondary Chords
22.2.4 The Step Shift API
22.3 Examples
22.4 Final Thoughts
23 Final Thoughts
23.1 The Quest for a Broader Musical Synthesis
23.2 The Quest for Real-time Synthesis
23.3 Automated Score Analysis
23.4 Forward
Appendices
A. Modality Varieties
A.1. Diatonic Modalities
A.2. Pentatonic Modalities
A.3. Octatonic Modality
A.4. Whole Tone Modality
A.5. Blues Modality
B. OrderedMap
C. The Observer Pattern
D. Chords
D.1. Tertian Chords
D.2. Secundal Chords
D.3. Quartal Chords
E. A Brief Introduction to XML
E.1. Tags, Elements, and Attributes
E.2. Data Structuring
E.3. Reading an XML File with Python
F. Binary Search Trees
G. Processing Constraints: The Design of a Pitch Constraint Engine
G.1. Two Straight Forward Solutions
G.1.1 Depth-First Search
G.1.2 Breadth-First Search and Chains
G.2. Improvements on the Constraint Solution Algorithm
Bibliography