0% found this document useful (0 votes)
7 views

Introduction To Digital Music With Python Programming Learning Music With Code 1st Edition Horn download

The document introduces 'Introduction to Digital Music with Python Programming,' a beginner-friendly book that combines music and coding to enhance creative expression and simplify music production. It covers fundamental concepts of rhythm, melody, and digital production through interactive examples, making it suitable for individuals with no prior experience in music or programming. The authors, Michael S. Horn, Melanie West, and Cameron Roberts, aim to empower readers by teaching programming concepts through music.

Uploaded by

jqiqbwnb2725
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Introduction To Digital Music With Python Programming Learning Music With Code 1st Edition Horn download

The document introduces 'Introduction to Digital Music with Python Programming,' a beginner-friendly book that combines music and coding to enhance creative expression and simplify music production. It covers fundamental concepts of rhythm, melody, and digital production through interactive examples, making it suitable for individuals with no prior experience in music or programming. The authors, Michael S. Horn, Melanie West, and Cameron Roberts, aim to empower readers by teaching programming concepts through music.

Uploaded by

jqiqbwnb2725
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 83

Introduction To Digital Music With Python

Programming Learning Music With Code 1st Edition


Horn download

https://ebookbell.com/product/introduction-to-digital-music-with-
python-programming-learning-music-with-code-1st-edition-
horn-37322724

Explore and download more ebooks at ebookbell.com


Here are some recommended products that we believe you will be
interested in. You can click the link to download.

Introduction To Digital Control Of Linear Time Invariant Systems


Ayachi Errachdi

https://ebookbell.com/product/introduction-to-digital-control-of-
linear-time-invariant-systems-ayachi-errachdi-47290706

Introduction To Digital Media Design Transferable Hacks Skills And


Tricks David Leicester Hardy

https://ebookbell.com/product/introduction-to-digital-media-design-
transferable-hacks-skills-and-tricks-david-leicester-hardy-50675518

Introduction To Digital Communications Ali Grami

https://ebookbell.com/product/introduction-to-digital-communications-
ali-grami-50885846

Introduction To Digital Systems Modeling Synthesis And Simulation


Using Vhdl 1st Edition Mohammed Ferdjallah

https://ebookbell.com/product/introduction-to-digital-systems-
modeling-synthesis-and-simulation-using-vhdl-1st-edition-mohammed-
ferdjallah-55139888
Introduction To Digital Navigation Including Fundamentals Of
Navigation Alexander Arnfinn Olsen

https://ebookbell.com/product/introduction-to-digital-navigation-
including-fundamentals-of-navigation-alexander-arnfinn-olsen-55839132

Introduction To Digital Signal Processing Computer Musically Speaking


Park Th

https://ebookbell.com/product/introduction-to-digital-signal-
processing-computer-musically-speaking-park-th-2046588

Introduction To Digital Signal Processing And Filter Design Shenoi Ba

https://ebookbell.com/product/introduction-to-digital-signal-
processing-and-filter-design-shenoi-ba-2047578

Introduction To Digital Speech Processing Foundations And Trends In


Signal Processing Lawrence R Rabiner

https://ebookbell.com/product/introduction-to-digital-speech-
processing-foundations-and-trends-in-signal-processing-lawrence-r-
rabiner-2089294

Introduction To Digital Communication Systems Krzysztof Wesolowski

https://ebookbell.com/product/introduction-to-digital-communication-
systems-krzysztof-wesolowski-2336578
Introduction to Digital Music
with Python Programming

Introduction to Digital Music with Python Programming provides a foundation


in music and code for the beginner. It shows how coding empowers new
forms of creative expression while simplifying and automating many of
the tedious aspects of production and composition.
With the help of online, interactive examples, this book covers the fun-
damentals of rhythm, chord structure, and melodic composition along-
side the basics of digital production. Each new concept is anchored in a
real-world musical example that will have you making beats in a matter
of minutes.
Music is also a great way to learn core programming concepts such as
loops, variables, lists, and functions, Introduction to Digital Music with Python
Programming is designed for beginners of all backgrounds, including high
school students, undergraduates, and aspiring professionals, and requires
no previous experience with music or code.

Michael S. Horn is Associate Professor of Computer Science and Learn-


ing Sciences at Northwestern University in Evanston, Illinois, where he
directs the Tangible Interaction Design and Learning (TIDAL) Lab.

Melanie West is a PhD student in Learning Sciences at Northwestern


University and co-founder of Tiz Media Foundation, a nonproft dedi-
cated to empowering underrepresented youth through science, technol-
ogy, engineering, and mathematics (STEM) programs.

Cameron Roberts is a software developer and musician living in Chicago.


He holds degrees from Northwestern University in Music Performance
and Computer Science.
Introduction to Digital
Music with Python
Programming
Learning Music with Code

Michael S. Horn, Melanie West,


and Cameron Roberts
First published 2022
by Routledge
4 Park Square, Milton Park, Abingdon, Oxon OX14 4RN
and by Routledge
605 Third Avenue, New York, NY 10158
Routledge is an imprint of the Taylor & Francis Group, an informa business
© 2022 Michael S. Horn, Melanie West, and Cameron Roberts
The right of Michael S. Horn, Melanie West, and Cameron
Roberts to be identifed as author of this work has been asserted
in accordance with sections 77 and 78 of the Copyright, Designs
and Patents Act 1988.
All rights reserved. No part of this book may be reprinted
or reproduced or utilised in any form or by any electronic,
mechanical, or other means, now known or hereafter invented,
including photocopying and recording, or in any information
storage or retrieval system, without permission in writing from
the publishers.
Trademark notice: Product or corporate names may be trademarks
or registered trademarks, and are used only for identifcation and
explanation without intent to infringe.
British Library Cataloguing-in-Publication Data
A catalogue record for this book is available from the British Library
Library of Congress Cataloging-in-Publication Data
A catalog record has been requested for this book

ISBN: 978-0-367-47083-8 (hbk)


ISBN: 978-0-367-47082-1 (pbk)
ISBN: 978-1-003-03324-0 (ebk)

DOI: 10.4324/9781003033240

Typeset in Bembo
by codeMantra
Melanie dedicates her contribution of the book to the
memory of her friend, Bernie Worrell, who taught her
how to listen.
Mike dedicates his contribution to his wife, Diana Reed,
and his children, Madeleine and Lucas.
Contents

List of fgures ix
Photo and illustration credits xiii
Foreword xiv
Acknowledgments xvi

1 Why music and coding? 1


Interlude 1: Basic pop beat 12
2 Rhythm and tempo 18
Interlude 2: Custom trap beat 49
3 Pitch, harmony, and dissonance 53
Interlude 3: Melodies and lists 68
4 Chords 71
Interlude 4: Playing chords 84
5 Scales, keys, and melody 88
Interlude 5: Lean on me 100
6 Diatonic chords and chord progressions 103
Interlude 6: Random chord progressions 114
7 Frequency, fourier, and flters 117
Interlude 7: Creative efects 136
8 Note-based production efects 140
Interlude 8: How to make a drum fll 153
9 Song composition and EarSketch 158
viii Contents
Interlude 9: How to make a snare drum riser 172
10 Modular synthesis 177
Interlude 10: Drum machine function 191
11 History of music and computing 194

Appendix A: Python reference 207


Appendix B: TunePad programming reference 231
Appendix C: Music reference 240
Index 255
Figures

1.1 A TunePad program to play a simple rock beat 5


1.2 Typical DAW software 6
1.3 TunePad project workspace 13
1.4 Selecting instruments in TunePad 13
1.5 Parts of a TunePad cell 14
1.6 Python syntax error in TunePad 15
1.7 Selecting an instrument’s voice in TunePad 16
2.1 TunePad project information bar. You can click on the
tempo, time signature, or key to change the settings for
your project 19
2.2 Standard notation example 20
2.3 Waveform representation of Figure 2.2 21
2.4 Piano or MIDI roll representation of Figure 2.2 21
2.5 Common note symbols starting with a whole note (four
beats) on the top down to 16th notes on the bottom.
The notes on each new row are half the length of the
row above 23
2.6 Drums in a typical drum kit 26
2.7 Roland 808 drum sequencer 28
2.8 Changing an instrument’s voice in TunePad 28
2.9 Example of a Python syntax error in TunePad. This line
of code was missing a parenthesis symbol 29
2.10 Calling the playNote function in TunePad with two
parameters inside the parentheses 30
2.11 How to show the print output of your code in a TunePad cell 35
2.12 Anatomy of a for loop in Python 36
2.13 Example of a Python syntax error. The command
‘ployNote’ should instead say ‘playNote’ 39
2.14 Example of a Python syntax error. Here the problem is
actually on line 1, not line 2 39
2.15 TunePad composer interface provides drum and
bass sequencers 47
x Figures
2.16 Basic drum pattern 50
2.17 Declaring a for loop for hi-hat runs in Python 51
2.18 Hi-hat stutter patterns 51
3.1 Sound is made up of compression waves of air molecules
that expand outward at a speed of around 343 meters
per second. The frequency of a sound wave refers to
how fast it vibrates; amplitude refers to the intensity of
the sound; and wavelength refers to the length of one
complete cycle of the waveform 54
3.2 Drawing of the cochlea (inner ear) 54
3.3 A waveform with varying amplitude 56
3.4 A half step is the distance between two adjacent piano
keys, measured in semitones 58
3.5 The harmonic series 60
3.6 Two waves at an interval of an octave 63
3.7 The ratio between the note C 262 Hz and the note
G 393 Hz is considered a perfect ffth 65
3.8 Select the 808 Bass voice 70
4.1 C major chord with MIDI note numbers 72
4.2 Creating chords as lists of numbers in Python. Each
major chord follows the same pattern 73
4.3 How to declare a user-defned function in
Python 74
4.4 C major chord 77
4.5 D minor chord 77
4.6 B diminished chord 78
4.7 C major 7th chord 79
4.8 D minor 7th chord 79
4.9 G dominant 7th chord 80
4.10 Csus2 chord 81
4.11 Csus4 chord 81
4.12 C augmented chord 82
5.1 Whole step and half step intervals of the C major scale 89
5.2 C Major Pentatonic Scale (top) and F♯ Major Pentatonic
Scale (bottom) 91
5.3 A representation of a list with values and indices 94
5.4 The Circle of Fifths arranges musical keys 96
6.1 The seven diatonic chords of C major 104
6.2 The dominant V and viio chords share two notes in
common. This is easy to see when you line piano
diagrams up vertically 107
6.3 Flowcharts for generating chord progressions in major
and minor keys 108
6.4 Example of using the fowchart to generate a chord
progression 108
Figures xi
6.5 C major chord in root position (top), frst inversion
(bottom left), and second inversion (bottom right) 109
6.6 Chord progression I-V-vi-IV without voice leading (top)
and with voice leading (bottom). Chords V, vi, and IV
are inverted to reduce the pitch range and to minimize
the movement of individual voices “singing” the notes
of the chords 110
7.1 Sound energy generated by a fute playing a single
note. The sound contains a series of spikes at regular
“harmonic” frequency intervals 118
7.2 Frequency combinations: fundamentals, partials,
harmonic, and inharmonic 119
7.3 A square wave (or any other audio signal) can be described
as a series of sine waves making up the partial frequencies 121
7.4 ADSR envelope 122
7.5 A spectrogram shows the intensity of frequencies in an
audio signal over time. The heatmap colors correspond
to intensity or energy at diferent frequencies. Time
is represented on the horizontal axis and frequency in
kilohertz on the vertical axis 123
7.6 Mixing console with magnetic tape 124
7.7 The mixing interface in TunePad allows you to adjust
gain, pan, and frequency response for each track
in a mix 126
7.8 Lowpass flter response curve 129
7.9 Highpass flter response curve 130
7.10 Bandpass flter response curve 131
7.11 Notch flter response curve 132
7.12 Peaking flter response curve 132
7.13 Low shelf and high shelf response curves 133
7.14 Graph of two methods for fading audio in 137
8.1 Intermediate pitches between C and C 141
8.2 Code cell in TunePad showing import statement 154
8.3 Drum fll pattern A 154
8.4 Drum fll pattern B 155
9.1 Songs are composed of nested and repeating notes,
phrases, and sections 159
9.2 The main EarSketch interface features a large library
of samples (left), an interactive timeline (middle top), a
code editor (center), and extensive documentation and
curriculum (right) 162
9.3 Close-up screenshot of EarSketch’s DAW 164
9.4 Using the ftMedia function in EarSketch 165
9.5 Snare drum riser pattern 172
9.6 Alternative snare drum riser pattern 173
xii Figures
10.1 Moog System 55 modular synthesizer 178
10.2 Audio signal from a microphone (top) and an audio
signal from an electric circuit 179
10.3 A simple Modular Synthesis patch created in TunePad 179
10.4 A patch with a delay efect 182
10.5 Two variations of an Additive Synthesis patch 184
10.6 A simple Subtractive Synthesis patch 185
10.7 An FM Synthesis patch where one sine wave is fed into
the frequency input socket of another sine wave 185
10.8 A more complex FM Synthesis patch 186
10.9 An example of physical modeling to create complex
string-like sounds 187
10.10 Complete Basic Poly/Lead patch in TunePad 188
10.11 Complete FM Synthesis example 189
11.1 The IBM 7094 computer at NASA. Public domain.
Available at Wikipedia 197
11.2 The Yamaha DX-7 200
11.3 Opcode’s Vision software for Macintosh in 1989 202
11.4 Screenshot of Teropa’s Music Mouse emulator 204
11.5 Jazz trombonist and scholar George Lewis working
on the IRCAM project. Image Credit: Michel Waisvisz
archives, ca. 1985 (used with permission) 205
A3.1 Parts of an audio wave 241
A3.2 ADSR envelope 242
A3.3 Natural notes on a keyboard 246
A3.4 Natural notes for a Treble Clef (top) and natural notes
for a Bass Clef (bottom) 247
A3.5 Circle of Fifths 250
Photo and illustration credits

George Folz (georgefolz.com) created original illustrations for


this book featured in Interludes 2, 4, and 8.
The photograph at the beginning of Chapter 3 is by
(unsplash.com/@jonathanvez)
The photograph at the beginning of Chapter 4 is by
(unsplash.com/@markus_gjengaar)
The photograph at the beginning of Chapter 5 is by
(unsplash.com/@jasmund)
The photograph at the beginning of Chapter 6 is by
(unsplash.com/@efrenbarahona3)
The photograph at the beginning of Chapter 7 is by
(unsplash.com/@pablodelafuente)
The photograph at the beginning of Chapter 8 is by
(unsplash.com/@makuph)
The photograph at the beginning of Chapter 10 is by
(unsplash.com/@didierjoomun)
The photograph at the beginning of Interlude 9 is by
(unsplash.com/@halacious)
The photograph at the beginning of Chapter 11 is by deepsonic
(fickr.com/people/73143485@N02). Creative
Commons License creativecommons.org/licenses/by/2.0.
Foreword

When I was a kid growing up in Texas, I “learned” how to play viola. I


put learned in quotes because it was really just a process of rote memori-
zation—hours and hours of playing the same songs over and over again.
I learned how to read sheet music, but only to the extent that I knew the
note names and could translate them into the grossest of physical move-
ments. I never learned to read music as literature, to understand its deeper
meaning, structure, or historical context. I never understood anything
about music theory beyond being annoyed that I had to pay attention to
accidentals in diferent keys. I never composed anything, not even infor-
mally scratching out a tune. I never developed habits of deep listening,
of taking songs apart in my head and puzzling over how they were put
together in the frst place. I never played just for fun. And, despite the best
intentions of my parents and teachers, I never fell in love with music.
Learning how to code was the complete opposite experience for me. I
was largely self-taught. The courses I took in school were electives that I
chose for myself. Teachers gave me important scafolding at just the right
times, but it never felt forced. I spent hours working on games or other
projects (probably when I should have been practicing viola). I drew art-
work, planned out algorithms, and even synthesized my own rudimentary
sound efects. I had no idea what I was doing, but that was liberating. No
one was around to point out my mistakes or to show me how to do things
the “right” way (at least, not until college). I learned how to fgure things
out for myself, and the skills I picked up from those experiences are still
relevant today. I fell in love with coding.1
But I know many people whose stories are fipped 180 degrees. For
them, music was so personally, socially, and culturally motivating that
they couldn’t get enough. They’d practice for hours and hours, not just for
fun but for something much deeper. For some it was an instrument like
the guitar that got them started. For others it was an app like GarageBand
that gave them a playful entry point into musical ideas. To the extent that
they had coding experiences, those experiences ranged from uninspiring
to of-putting. It’s not that they necessarily hated coding, but it was some-
thing they saw as not being for them.
Foreword xv
In the foreword of his book, Mindstorms: Children, Computers, and Pow-
erful Ideas, Seymour Papert wrote that he “fell in love with gears” as a way
of helping us imagine a future in which children (like me) would fall in
love with computer programming, not for its own sake, but for the cre-
ative worlds and powerful ideas that programming could open up. Part of
what he was saying was that love and learning go hand in hand, and that
computers could be an entry point into many creative and artistic domains
such as mathematics and music. Coding can revitalize subjects that have
become painfully rote in schools.
The process of developing TunePad over the past several years has been
a fascinating rediscovery of musical ideas for me. Code has given me a dif-
ferent kind of language for thinking about things like rhythm, chords, and
harmony. I can experiment with composition unencumbered by my mal-
adroit hands. Music has become something creative and alive in a way that
it never was for me before. Music theory is no longer a thicket of confusing
terminology and instead has become a fascinating world of mathematical
beauty that structures the creative process.
Melanie, Cameron, and I hope that this book gives you a similarly joy-
ful learning experience with music and code. We hope that you feel em-
powered to explore the algorithmic and mathematical beauty of music.
We hope that you discover, as we have, that music and code reinforce one
another in surprising and powerful ways that open new creative opportu-
nities for you. We hope that, regardless of your starting point—as a coder,
as a musician, as neither, as both—you will discover something new about
yourself and what you can become.

Michael Horn
Chicago, Illinois ( July 2021)

Note
1 I was also fortunate to have grown up in a time and place where these ac-
tivities were seen as socially acceptable for a person of my background and
identity.
Acknowledgments

We are grateful to the many people who have helped make this book possi-
ble. We especially want to thank Dr. Amartya Banerjee who has anchored
the TunePad development team. The TunePad project grew out of a col-
laboration with the EarSketch team at Georgia Tech that was initiated by
Dr. Brian Magerko and Dr. Jason Freeman. We thank Dr. Nichole Pinkard,
Dr. Amy Pratt, and the Northwestern Ofce of Community Education
Partnerships. We thank the TIDAL Lab team at Northwestern University
including Mmachi Obiorah, Wade Berger, Izaiah Wallace, Brian Andrus,
Jamie Gorrson, Matthew Brucker, Lexie Zhao, Ayse Hunt, Kallayah
Henderson, Cortez Watson Jr., Sachin Srivastava, and many, many oth-
ers. We thank our community partners including the Evanston Public
Library, the NAACP of DuPage County, the James R. Jordan Foun-
dation, the Meta Media program at the McGaw YMCA, the Hip-Hop
FIRM, EvanSTEM, the Center for Creative Entrepreneurship, Studio
2112, the James R. Jordan Boys and Girls Club, Lake View High School
and Marshaun Brooks, Lane Tech High School and Amy Wozniak, Gary
Comer Youth Centers, and Chicago Youth Centers, Project Exploration,
BBF Family Services, and the Museum of Science and Industry. Shout-
outs to Marcus Prince and Sam Carroll who gave us insightful curriculum
ideas, to Tom Knapp who contributed to TunePad’s graphical design, and
to the amazing interns we’ve worried with over the years.
Special thanks go to the people who gave input into the ideas and text
of this manuscript including George Papajohn and Diana Reed. We also
thank Joseph Mahanes, Abbie Reeves, and others who put up with us
while we worked on this book.
TunePad was created by the Tangible Interaction Design and Learn-
ing (TIDAL) Lab at Northwestern University in collaboration with the
EarSketch team at the Georgia Institute of Technology and with fund-
ing from the National Science Foundation (grants DRL-1612619, DRL-
1451762, and DRL-1837661) and the Verizon Foundation. Any opinions,
fndings, and/or recommendations expressed in the material are those of
the authors and do not necessarily refect the views of the funders.
1 Why music and coding?

Welcome to Introduction to Digital Music with Python: Learning Music with


Code. This book is designed for people who love music and are interested in
the intersection of music and coding. Maybe you’re an aspiring musician
or music producer who wants to know more about coding and what it can
do. Or maybe you already know a little about coding, and you want to
expand your creative musical horizon. Or maybe you’re a total beginner
in both. Regardless of your starting point, this book is designed for you to
learn about music and coding as mutually reinforcing skills. Code gives us
an elegant language to think about musical ideas, and music gives us a con-
text within which code makes sense and is immediately useful. Together
they form a powerful new way to create music that will be interconnected
with digital production tools of the future.
More and more code will be used to produce music, to compose music,
and even to perform music for live audiences. Digital production tools
such as Logic, Reason, Pro Tools, FL Studio, and Ableton Live are com-
plex software applications created with millions of lines of code written by
huge teams of software engineers. With all of these tools you can write
code to create custom plugins and efects. Beyond production tools, live
coding is an emerging form of musical performance art in which Infor-
mation Age DJs write computer code to generate music in real time for
live audiences.
In other ways, we’re still on the cusp of a radical transformation in the
way that we use code to create music. The history of innovation in music
has always been entwined with innovation in technology. Whether we’re
DOI: 10.4324/9781003033240-1
2 Why music and coding?
talking about Franz Liszt in the 19th century, who pioneered the persona
of the modern music virtuoso based on technological breakthroughs of
the piano,1 or DJ Kool Herc in the 20th century, who pioneered hip-hop
with two turntables and a crate full of funk records in the Bronx, tech-
nologies have created new opportunities for musical expression that have
challenged the status quo and given birth to new genres. We don’t have
the Franz Liszt or DJ Kool Herc of coding yet, but it’s only a matter of
time before the coding virtuosos of tomorrow expand the boundaries of
what’s possible in musical composition, production, and performance.

1.1 What is Python?


In this book you’ll learn how to create your own digital music using a
computer programming language called Python. If you’re not familiar
with programming languages, Python is a general-purpose language frst
released in the 1990s that is now one of the most widely used languages in
the world. Python is designed to be easy to read and write, which makes it
a popular choice for beginners. It’s also fully featured and powerful, mak-
ing it a good choice for professionals working in felds as diverse as data
science, web development, the arts, and video game development. Because
Python has been around for decades, it runs on every major computer
operating system. The examples in this book even use a version of Python
that runs directly inside of your web browser without the need for any
special software installation.
Unlike many other common beginner programming languages, Python
is “text-based”, which means that you type code into an editor instead of
dragging code blocks on the computer screen. This makes Python a little
harder to learn than other beginner languages, but it also greatly expands
what you can do. By the time you get through this book you should feel
comfortable writing short Python programs and have the conceptual tools
you need to explore more on your own.

1.2 What this book is not


Before we get into a concrete example of what you can do with a little bit
of code, just a quick note about what this book is not. This book is not a
comprehensive guide to Python programming. There are many excellent
books and tutorials designed for beginners, several of which are free.2
This book is also not a comprehensive guide to music theory or Western
music notation. We’ll get into the core ideas behind rhythm, harmony,
melody, and composition, but there are, again, many other resources avail-
able for beginners who want to go deeper. What we’re ofering is a dif-
ferent approach that combines learning music with learning code in equal
measure.
Why music and coding? 3
1.3 What this book is
What we will do is give you an intuitive understanding of the fundamen-
tal concepts behind both music and coding. Code and music are highly
technical skills, full of arcane symbols and terminology, that seem almost
designed to intimidate beginners. In this book we’ll put core concepts
to use immediately to start making music. You’ll get to play with ideas
at your own pace and get instant feedback as you bring ideas to life. We
skip most of the technical jargon and minutiae for now—that can come
later. Instead, we focus on developing your confdence and understanding.
Importantly, the skills, tools, and ways of thinking that we introduce in
this book will be broadly applicable in many other areas as well. You’ll be
working in Python code, but the core structures of variables, functions,
loops, conditional logical, and classes are the same across many program-
ming languages including JavaScript, Java, C, C++, and C#. After you
learn one programming language, each additional language is that much
easier to pick up.

1.4 TunePad and EarSketch


This book uses two free online platforms that combine music and
Python coding. The frst, called TunePad (https://tunepad.com), was
developed by a team of researchers at Northwestern University in
Chicago. TunePad lets you create short musical loops that you can
layer together using a simple digital audio workstation (DAW) inter-
face. The second platform, called EarSketch (https://earsketch.gatech.
edu), was created by researchers at Georgia Tech in Atlanta. EarSketch
uses Python code to arrange samples and loops into full-length com-
positions. Both platforms are browser-based apps, so all you need to
get started is a computer (tablets or Chromebooks are fne), an inter-
net connection, and a web browser like Chrome or Firefox. External
speakers or headphones are also nice but not required. Both platforms
have been around for years and have been used by many thousands
of students from middle school all the way up to college and beyond.
TunePad and EarSketch are designed primarily as learning platforms,
but there are easy ways to export your work to professional production
software if you want to go further.

1.5 A quick example


Here’s a quick example of what coding in Python looks like. This program
runs in TunePad to create a simple beat pattern, variants of which have
been used in literally thousands of songs such as Blinding Lights by The
Weeknd and Roses by SAINt JHN.
4 Why music and coding?

1 playNote(1) # play a kick drum sound


2 playNote(2) # play a snare drum sound
3 playNote(1)
4 playNote(2)
5 rewind(4) # rewind 4 beats
6 for i in range(4):
7 rest(0.5)
8 playNote(4, beats = 0.5) # play hat for a half beat

These eight lines of Python code tell TunePad to play a pattern of kick
drums, snare drums, and high-hats. Most of the lines are playNote in-
structions, and, as you might have guessed, those instructions tell TunePad
to play musical sounds indicated by the numbers inside of the parentheses.
This example also includes something called a loop on line 6. Don’t worry
too much about the details yet, but the loop is an easy way to repeat a set
of actions over and over again. In this case, the loop tells Python to repeat
lines 7 and 8 four times in a row. The screenshot (Figure 1.1) shows what
this looks like in TunePad. You can try out the example for yourself with
this link: https://tunepad.com/examples/roses.

1.6 Five reasons to learn code


Now that you’ve seen a brief example of what you can do with a few lines
of Python code, here are our top fve reasons to get started with program-
ming and music if you’re still in doubt.

1.6.1 REASON 1: Like it or note, music is already defned by code


Looking across the modern musical landscape, it’s clear that music is al-
ready defned by code. One of the biggest common factors of almost all
modern music from any popular genre is that everything is edited, if not
created entirely, with sophisticated computer software. It’s hard to over-
state how profoundly such software has shaped the sound of music in the
21st century. Relatively inexpensive DAW applications and the myriad
ubiquitous plugins that work across platforms have had a disruptive and
democratizing efect across the music industry. Think about efects plugins
like autotune, reverb, or the ability to change the pitch of a sample with-
out changing the tempo. These efects are all generated with sophisticated
software. Production studios the size of small ofces containing hundreds
of thousands of dollars’ worth of equipment now ft on the screen of a
laptop computer available to any aspiring producer with passion, a WiFi
Why music and coding? 5

Figure 1.1 A TunePad program to play a simple rock beat.

connection, and a small budget. The reasons behind the shift to digital
production tools are obvious. Computers have gotten to a point where
they are cheap enough, fast enough, and capacious enough to do real-time
audio editing. We can convert sound waves into editable digital informa-
tion with microsecond precision and then hear the efects of our changes
in real time. These DAWs didn’t just appear out of nowhere. They were
constructed by huge teams of software engineers writing code—millions
of lines of it. As an example, TunePad was created with over 1.5 million
lines of code written in over a dozen computer languages such as Python,
HTML, JavaScript, CSS, and Dart. Regardless of how you feel about the
digital nature of modern music, it’s not going away. Learning to code will
6 Why music and coding?

Figure 1.2 Typical DAW software.

help you understand a little more about how all of this works under the
hood. More to the point, it’s increasingly common for producers to write
their own code to manipulate sound. For example, in Logic, you can write
JavaScript code to process incoming MIDI (Musical Instrument Digital
Interface) data to do things like create custom arpeggiators. Learning to
code can give you more control and help expand your creative potential
(Figure 1.2).

1.6.2 REASON 2: Code is a powerful way to make music


We don’t always think about it this way, but music is algorithmic in
nature—it’s full of mathematical relationships, logical structure, and
recursive patterns. The beauty of the Baroque fugue is in part a re-
fection of the beauty of the mathematical and computational ideas
behind the music. We call Bach a genius not just because his music is
so compelling, but also because he was able to hold complex algorithms
in his mind and then transcribe them to paper using the representation
system that we call Western music notation. In other words, music
notation is a language for recording the output of the composition
process, but not a language for capturing the algorithmic nature of the
composition process itself.
Code, on the other hand, is a language specifcally designed to capture
mathematical relationships, logical structure, and recursive patterns. For
example, take the stuttered hi-hat patterns that are one of the defning
characteristics of trap music. Here are a few lines of Python code that gen-
erate randomized hi-hat stutters that can bring an otherwise conventional
beat to life with sparkling energy.
Why music and coding? 7

1 for _ in range(16):
2 if randint(6) > 1: # roll the die for a random number
3 playNote(4, beats=0.5) # play an eighth note
4 else:
5 playNote(4, beats=0.25) # or play 16th notes
6 playNote(4, beats=0.25)

Or, as another example, here’s a two-line Python program that plays a


snare drum riser efect common in house, EDM, or pop music. You’ll of-
ten hear this technique right before the beat drops. This code uses a decay
function so that each successive note is a little shorter resulting in a gradual
acceleration efect. Don’t worry about how all of this works just yet. We’ll
walk you through the details as we go along.

1 for i in range(50): # play 50 snares


2 playNote(2, beats = pow(2, -0.09 * i))

What’s cool about these efects is that they’re parameterized. Because the
code describes the algorithms to generate music, and not the music itself, it
means we can create infnite variation by adjusting the numbers involved.
For example, in the trap hi-hat code, we can easily play around with how
frequently stuttered hats are inserted into the pattern by increasing or de-
creasing one number. You can think of code as something like a power drill;
you can swap out diferent bits to make holes of diferent sizes. The drill bits
are like parameters that change what the tool does in each specifc instance.
In the same way, algorithms are vastly more general-purpose tools that can
accomplish myriad tasks by changing the input parameters.
Creating a snare drum riser with code is obviously a very diferent kind
of thing than picking up two drumsticks and banging out a pattern on
a real drum. And, to be clear, we’re not advocating for code to replace
learning how to perform with live musical instruments. But, code can be
another tool in your musical repertoire for generating repetitive patterns,
exploring mathematical ideas, or playing sequences that are too fast or
intricate to play by hand.

1.6.3 REASON 3: Code lets you build your own musical toolkit
Becoming a professional in any feld is about developing expertise with
tools—acquiring equipment and knowing how to use it. Clearly, this
is true in the music industry, but it’s also true in software. Professional
software engineers acquire specialized equipment and software packages.
They develop expertise in a range of programming languages and techni-
cal frameworks. But, they also build their own specialized tools that they
use across projects. In this book, we’ll show you how to build up your own
8 Why music and coding?
library of Python functions. You can think of functions as specialized tools
that you create to perform diferent musical tasks. In addition to the exam-
ples we described above, you might write a function to generate a chord
progression or play an arpeggio, and you can use functions again and again
across many musical projects.

1.6.4 REASON 4: Code is useful for a thousand and one other things
As we mentioned earlier in this chapter, Python is one of the most power-
ful, multi-purpose languages in the world. It’s used to create web servers
and social media platforms as much as video games, animation, and music.
It’s used for research and data science, politics and journalism. Knowing a
little Python gives you access to powerful machine learning and artifcial
intelligence (AI/ML) techniques that are poised to transform most aspects
of human work, including in creative domains such as music. Python is
both a scripting language and a software engineering platform—equal
parts duct tape and table saw—and it’s capable of everything from quick
fxes to durable software applications. Learning a little Python won’t make
you a software engineer, just like learning a few guitar chords won’t make
you a performance musician. But it’s a start down a path. An open door
that was previously closed, and a new way of using your mind and a new
way of thinking about music.

1.6.5 REASON 5: Coding makes us more human


When we think about learning to code, we tend to think about the eco-
nomic payof. You’ll hear arguments that learning to code is a resume
builder and a path to a high-paying job. It’s not that this perspective is
wrong, but it might be the wrong reason for you to learn how to code.
Just like people who are good at music love music, people who are good
at coding tend to love coding. The craft of building software can be te-
dious and frustrating, but it can also be rewarding. It’s a way to express
oneself creatively and to engage in craftwork. People don’t learn to knit,
cook, or play an instrument for the lucrative career paths that these pur-
suits open up—although by all means those pursuits can lead to remark-
able careers. People learn these things because they have a passion for them.
Because they are personally fulflling. These passions connect us to cen-
turies of tradition; they connect us to communities of teachers, learners,
and practitioners; and, in the end, they make us more human. So when
things get a little frustrating—and things always get a little frustrating
when you’re learning any worthwhile skill—remember that just like po-
etry, literature, or music, code is an art as much as it is a science. And, just
like woodworking, knitting, or cooking, code is a craft as much as it is
an engineering discipline. Be patient and give yourself a chance to fall in
love with coding.
Why music and coding? 9
1.7 The future of music and code
Before we get on with the book, we wanted to leave you with a brief
thought about the future of technology, music, and code. For as long as
there have been people on this planet there has been music. And, as long
as there has been music, people have created technology to expand and en-
hance their creative potential. A drum is a kind of technology—a piece of
animal hide stretched across a hollow log and tied in place. It’s a polylithic
accomplishment, an assembly of parts that requires skill and craft to make.
One must know how to prepare animal hide, to make rope from plant
fber, and to craft and sharpen tools. More than that, one must know how
to perform with the drum, to connect with an audience, to enchant them
to move their bodies through an emotional and rhythmic connection to
the beat. Technology brings together materials and tools with knowledge.
People must have knowledge both to craft an artifact and to wield it. And,
over time—over generations—that knowledge is refned as it gets passed
down from teacher to student. It becomes stylized and diversifed. Tools,
artifacts, knowledge, and practice all become something greater. Some-
thing we call culture.
Again and again the world of music has been disrupted, democratized,
and redefned by new technologies. Hip-hop was a rebellion against the
musical status quo fueled by low-cost technologies like recordable cas-
sette tapes, turntables, and 808 drum machines. Early innovators shat-
tered norms of artistic expression, redefning music, poetry, visual art,
and dance in the process. Inexpensive access to technology coupled with
a need for new forms of authentic self-expression was a match to the dry
tinder of racial and economic oppression.
It’s hard to overstate how quickly the world is still changing as a re-
sult of technological advancements. Digital artifacts and infrastructures
are so ubiquitous that they have reconfgured social, economic, legal, and
political systems; revolutionized scientifc research; upended the arts and
culture; and even wormed their way into the most intimate aspects of our
personal and romantic lives. We’ve already talked about the transforma-
tive impact that digital tools have had on the world of music in the 21st
century, but the exhilarating (and scary) part is that we’re on the precipice
of another wave of transformation in which human creativity will be re-
defned by Artifcial Intelligence AI and Machine Learning ML. Imagine
AI accompanists that can improvise harmonies or melodies in real time
with human musicians. Or deep learning algorithms that can listen to
millions of songs and innovate music in the same genre. Or silicon poets
that grasp human language well enough to compose intricate rap lyrics.
Or machines with trillions of transistor synapses so complex that they be-
gin to “dream”—inverted machine learning algorithms that ooze imagery
unhinged enough to disturb the absinthe slumber of surrealist painters.
Now, imagine that this is not speculative science fction, but the reality of
10 Why music and coding?
our world today. These things are here now and already challenging what
we mean by human creativity. What are the implications of a society of
digital creative cyborgs?
But here’s the trick: we’ve always been cyborgs. Western music notation
is as much a technology as Python code. Becoming literate in any suf-
ciently advanced representation system profoundly shapes how we think
about and perceive the world around us. Classical music notation, theory,
and practice shaped the mind of Beethoven as much as he shaped music
with it—so much so that he was still able to compose many of his most
famous works while almost totally deaf. Beethoven was a creative cyborg
enhanced by the technology of Western music notation and theory. The
diference is that now we’ve externalized many of the cognitive processes
into machines that think alongside us. And, increasingly, these tools are
available to everyone. How that changes what it means to be a creative
human being is anyone’s guess.

1.8 Book overview


We’re excited to have you with us on this journey through music and
code. Here’s a short guide for where we go from here. Chapters 2 and 3
cover the foundations of rhythm, pitch, and harmony. These chapters are
designed to move quickly and get you coding in Python early on. We’ll
cover Python variables, loops, which both connect directly to musical
concepts. Chapters 4, 5, and 6 cover the foundations of chords, scales,
and keys using Python lists, functions, and data structures. Chapters 7, 8,
and 10 shift from music composition to music production covering topics
such as the frequency domain, modular synthesis, and other production
efects. In Chapter 9, we switch to the EarSketch platform to talk about
how various musical elements are combined to compose full-length songs.
Finally, Chapter 11 provides a short overview of the history of music and
code along with a glimpse of what the future might hold. Between each
chapter, we provide a series of short interludes that are like step-by-step
tutorials to introduce new music and coding concepts.
A few notes about how to read this book. Any time we include Python
code, it will be shown in a programming font like this:
playNote(60)

Sometimes we’ll write code in a table with line numbers so that we can re-
fer to specifc lines. When we introduce new terms, we’ll bold the word.
If you get confused by any of the programming or music terminology,
check out the appendices, which contain quick overviews of all of the
important concepts. We’ll often invite you to follow along with online
examples. The best way to learn is by doing it yourself, so we strongly
Why music and coding? 11
encourage you to try coding in Python online as you go through the
chapters.

Notes
1 It’s said that fans were so infatuated with Liszt’s piano “rockstar” status that
they fought over his silk handkerchiefs and velvet gloves at his performances.
2 We recommend https://www.w3schools.com/python/.
Interlude 1
BASIC POP BEAT

In this interlude we’re going to get familiar with the TunePad interface by
creating a basic rock beat in the style of songs like Roses by SAINt JHN.
You can follow along online by visiting
https://tunepad.com/interlude/pop-beat

STEP 1: Deep listening


It’s good to get in the habit of deep listening. Deep listening is the prac-
tice of trying every possible way of listening to sounds. Start by loading a
favorite song in a streaming service and listening—really listening—to it.
Take the song apart element by element. What sounds do you hear? How
are they layered together? When do diferent parts come into the track and
how do they change over time? Think about how the producer balances
sounds across the frequency spectrum or opens up space for transitions in
the lyrics. Try focusing on just the drums. Can you start to recognize the
individual percussion sounds and their rhythmic patterns?

STEP 2: Create a new TunePad project


Visit https://tunepad.com on a laptop or Chromebook and set up an account.1
If you already have a gmail address, you can use your existing account. Af-
ter signing in, click on the New Project button to create an empty project
workspace. Your project will look something like this (Figure 1.3):

DOI: 10.4324/9781003033240-2
Basic pop beat 13

Figure 1.3 TunePad project workspace.

STEP 3: Kick drums


In your project window, click on the ADD CELL button and then select
Drums (Figure 1.4).
In TunePad you can think of a “cell” as an instrument that you can
program to play music. Name the new instrument “Kicks” and then add
this Python code.

1 # play four kick drums


2 playNote(1)
3 playNote(1)
4 playNote(1)
5 playNote(1)

Figure 1.4 Selecting instruments in TunePad.


14 Basic pop beat

Figure 1.5 Parts of a TunePad cell.

When you’re done, your project should look something like Figure 1.5.
Go ahead and press the Play button at the top left to hear how this
sounds. Congratulations! You’ve just written a Python program.

Syntax errors
Occasionally your code won’t work right and you’ll get a red error mes-
sage box that looks something like Figure 1.6. This kind of error message
is called a “syntax” error. In this case, the code was written as playnote
with a lowercase “n” instead of an uppercase “N”. You can fx this error
by changing the code to read playNote (with an uppercase “N”) on line
2 (Figure 1.6).
Basic pop beat 15

Figure 1.6 Python syntax error in TunePad.

STEP 4: Snare drums


In your project window, click on the ADD CELL button again and select
Drums. Now you should have two drum cells one appearing above the
other in your project. Name the second instrument “Snare Drums” and
then add this Python code.

1 # play two snare drums on the up beats only


2 rest(1) # skip a beat
3 playNote(2) # play a snare drum sound
4 rest(1)
5 playNote(2)

You might start to notice the text that comes after the hashtag symbol (#)
is a special part of your program. This text is called a comment, and it’s for
human coders to help organize and document their code. Anything that
comes after the hashtag on a line is ignored by Python. Try playing this
snare drum cell to hear how it sounds. You can also play the kick drum
cell at the same time to see how they sound together.

STEP 5: Hi-hats
Click on the ADD CELL button again to add a third drum cell. Change
the title of this cell to be “Hats” and add the following code:

1 # play four hats between the kicks and snares


2 rest(0.5) # rest for half a beat
3 playNote(4, beats=0.5) # play a hat for half a beat
4 rest(0.5)
5 playNote(4, beats=0.5)
6 rest(0.5)
7 playNote(4, beats=0.5)
8 rest(0.5)
9 playNote(4, beats=0.5)
16 Basic pop beat
When you play all three of the drum cells together, you should hear a
basic rock beat pattern:

kick - hat - snare - hat - kick - hat - snare - hat

STEP 6: Fix your kicks


You might notice that the kick drums feel a little heavy in this mix. We
can make some space in the pattern by resting on the up beats (beats 2
and 4) when the snare drums are playing. Scroll back up to your Kick
drum cell and change the code to look like this:

1 # play kicks on the down beats only


2 playNote(1)
3 rest(1)
4 playNote(1)
5 rest(1)
6 playNote(1)
7 rest(1)
8 playNote(1)
9 rest(0.5) # rest a half beat
10 playNote(1, beats = 0.5) # half beat pickup kick

STEP 7: Adding a bass line


Add a new cell to your project, but this time select Bass instead of
Drums. Once the cell is loaded up, change the voice to Plucked Bass
(Figure 1.7):

Figure 1.7 Selecting an instrument’s voice in TunePad.


Basic pop beat 17
Entering this code to create a simplifed bass line in the style of Roses by
SAINt JHN. When you’re done, try playing everything together to get
the full sound.

1 playNote(5, beats=0.5) # start on low F


2 playNote(17, beats=0.5) # up an octave
3 rest(1)
4
5 playNote(10, beats=0.5) # A sharp
6 playNote(22, beats=0.5) # up an octave
7 rest(1)
8
9 playNote(8, beats=0.5) # G sharp
10 playNote(20, beats=0.5) # up an octave
11 rest(0.5)
12
13 playNote(8, beats=0.5) # G sharp - G - G
14 playNote(12, beats=0.5)
15 playNote(24, beats=0.5)
16
17 playNote(10, beats=0.75) # C sharp
19 playNote(22, beats=0.25) # D sharp

Note
1 We recommend using the free Google Chrome browser for the best overall
experience.
2 Rhythm and tempo

This chapter dives into the fundamentals of rhythm in music. We start


with the beat—what it is, how it’s measured, and how we can visualize the
beat to compose, edit, and play music. From there we’ll provide examples
of some common rhythmic motifs from diferent genres of music and
how to code them with Python. The main programming concepts for this
chapter include loops, variables, calling function, and passing parameter
values. This chapter covers a lot of ground, but it will give you a solid start
on making music with code.

2.1 Beat and tempo


The beat is the foundation of rhythm in music. The term beat has a num-
ber of diferent meanings in music,1 but this chapter uses it to mean a unit
of time, or how long an individual note is played—for example, “rest for
two beats” or “play a note for half a beat”. Based on the beat, musical
notes are combined in repeated patterns that move through time to make
rhythmic sense to our ears.
Tempo refers to the speed at which the rhythm moves, or how quickly
one beat follows another in a piece of music. As a listener, you can feel
the tempo by tapping your foot to the rhythmic pulse. The standard way
to measure tempo is in beats per minute (BPM or bpm), meaning the
total number of beats played in one minute’s time. This is almost always a
whole number like 60, 120, or 78. At a tempo of 60 bpm, your foot taps 60
times each minute (or one beat per second). At 120 bpm, you get 2 beats
DOI: 10.4324/9781003033240-3
Rhythm and tempo 19
every second; and, at 90 bpm, you get 1.5 beats every second. Later in this
chapter when you start working with TunePad, you can set the tempo by
clicking on the bpm indicator in the top bar of a project (see Figure 2.1).
Diferent genres of music have their own typical tempo ranges (al-
though every song and every artist is diferent). For example, hip-hop
usually falls in the 60–110 bpm range, while rock is faster in the 100–140
bpm range. House/techno/trance is faster still, with tempos between 120
and 140 bpm.

Genre Tempo Range (BPM)

Rock 100–140
R&B 60–80
Pop 100–132
Reggae 60–92
Hip-hop 60–110
Dubstep 130–144
Techno 120–140
Salsa 140–250
Bachata 120–140

It takes practice for musicians to perform at a steady tempo, and they


sometimes use a device called a metronome to help keep their playing
constant with the pulse of the music. You can create a simple metronome
in TunePad using four lines of code in a drum cell. This works best if you
switch the instrument to Drums → Percussion Sounds.
playNote(3, velocity = 100) # louder 1st note
playNote(3, velocity = 60)
playNote(3, velocity = 60)
playNote(3, velocity = 60)

You can adjust the tempo of your metronome with the bpm indicator
(Figure 2.1). As this example illustrates, computers excel at keeping a per-
fectly steady tempo. This is great if you want precision, but there’s also a
risk that the resulting music will sound too rigid and machine-like. When
real people play music they often speed up or slow down, either for dra-
matic efect or just as a result of being a human. Depending on the genre,
performers might add slight variations in rhythm called swing or shufe,

Figure 2.1 TunePad project information bar. You can click on the tempo, time
signature, or key to change the settings for your project.
20 Rhythm and tempo
that’s a kind of back and forth rocking of the beat that you can feel almost
more than you can hear. We’ll show you how to add a more human feel to
computer generated music later in the book.

2.2 Rhythmic notations


Over the centuries, musicians and composers have developed many dif-
ferent written systems to record and share music. With the invention of
digital production software, a number of other interactive representations
for mixing and editing have become common as well. Here are four com-
mon visual representations of the same rhythmic pattern. The pattern has
a total duration of four beats and can be counted as “1 and 2, 3 and 4”.
The frst two notes are ½ beats long followed by a note that is 1 beat long.
Then the pattern repeats.

2.2.1 Representation 1: Standard Western music notation


The frst representation (below) shows standard music notation (or Western
notation), a system of recording notes that has been developed over many
hundreds of years. The two thick vertical lines on the left side of the il-
lustration indicate that this is rhythmic notation, meaning that there is no
information about musical pitch, only rhythmic timing. The dots on the
long horizontal lines are notes whose shapes indicate the duration of each
sound to be played. Sometimes diferent percussion instruments will have
their notes drawn on diferent lines. We’ll describe what the various note
symbols mean in more detail in Figure 2.2.

Figure 2.2 Standard notation example.


Rhythm and tempo 21

Figure 2.3 Waveform representation of Figure 2.2.

2.2.2 Representation 2: Audio waveforms


The second representation shows a visualization of the actual audio wave-
form that gets sent to the speakers when you play music. The waveform
shows the amplitude (or volume) of the audio signal over time. The next
chapter talks more about audio waveforms, but for now you can think of
a waveform as a graph that shows the literal intensity of the vibration of
your speakers over time. When you compose a beat in TunePad, you can
switch to the waveform view by clicking on the small dropdown arrow at
the top-left side of the timeline (Figure 2.3).

2.2.3 Representation 3: Piano (MIDI) roll


The third representation shows a piano roll (or MIDI (Musical Instrument
Digital Interface) roll). This uses solid lines to show individual notes. The
length of the lines represents the length of individual notes, and the verti-
cal position of the lines represents the percussion sound being played (kick
drums and snare drums in this case). This representation is increasingly
common in music production software. Many tools even allow for drag
and drop interaction with the individual notes to compose and edit music
(Figure 2.4).

Figure 2.4 Piano or MIDI roll representation of Figure 2.2.


22 Rhythm and tempo
2.2.4 Representation 4: Python code
A fnal representation for now shows Python code in TunePad. In this
representation, the duration of each note is set using the beats parameter
of the playNote function calls.

playNote(2, beats = 0.5)


playNote(2, beats = 0.5)
playNote(6, beats = 1)

playNote(2, beats = 0.5)


playNote(2, beats = 0.5)
playNote(6, beats = 1)

Each of these representations has advantages and disadvantages; they are


good for conveying some kinds of information and less good at convey-
ing others. For example, standard rhythm notation has been refned over
centuries and is accessible to an enormous, worldwide community of mu-
sicians. On the other hand, it can be confusing for people who haven’t
learned how to read sheet music. The timing of individual notes is com-
municated using tails and fags attached to the notes, but there’s no consis-
tent mapping between horizontal space and timing.
The audio waveform is good at showing what the sound actually looks
like—how long each note rings out (“release”) and how sharp its onset is
(“attack”). It’s helpful for music production, mixing, and mastering. On
the other hand, waveforms don’t really tell you much about the pitch of a
note or its intended timing as recorded by the composer.
The Python code is easier for computers to read than humans—it’s
defnitely not something you would hand to a musician to sight read.
On the other hand, it has the advantage that it can be incorporated into
computer algorithms and manipulated and transformed in endless ways.
There are many, many other notation systems designed to transcribe
a musical performance—what we hear at a live performance—onto a
sheet of paper or a computer screen. Each of these representations was
invented for a specifc purpose and/or genre of music. You might pick a
representation based on the context and whether you’re in the role of a
musician (and what kind of instrument you play), a singer, a composer,
a sound engineer, or a producer. Music notation systems are as rich
and varied as the cultures and musical traditions that invented them.
One nice thing about working with software is that it’s easy to switch
between multiple representations of music depending on the task we’re
trying to accomplish.
Rhythm and tempo 23

Figure 2.5 Common note symbols starting with a whole note (four beats) on the
top down to 16th notes on the bottom. The notes on each new row are
half the length of the row above.

2.3 Standard rhythmic notation


This section will review a standard musical notation system that has roots
in European musical traditions. This system is versatile and has been re-
fned and adapted over a long period of time across many countries and
continents to work with an increasingly diverse range of instruments and
musical genres. We’re starting with percussive rhythmic note values in
this chapter, and we’ll move on to working with pitched instruments in
Chapter 3.
Figure 2.5 shows the most common symbols used in rhythmic music
notation. Notes are represented with oval-shaped dots that are either open
or closed. All notes except for the whole note (top) have tails attached to
them that can point either up or down. It doesn’t matter which direction
(up or down) the tail points. Notes that are faster than a quarter note also
have horizontal fags or beams connected to the tails. Each additional fag
or beam indicates that the note is twice as fast.

Symbol Name Beats TunePad code


Whole Note 4 playNote(1, beats = 4)
Larger open circle with no tail
and no fag.
Half Note 2 playNote(1, beats = 2)
Open circle with a tail and no
fag.
Quarter Note 1 playNote(1, beats = 1)
Solid circle with a tail and no
fag.
24 Rhythm and tempo

Eighth Note 0.5 or ½ playNote(1, beats = 0.5)


Solid circle with a tail and one
fag or bar.
Sixteenth Note 0.25 or ¼ playNote(1, beats = 0.25)
Solid circle with a tail and two
fags or bars.
Dotted Half Note 3 playNote(1, beats = 3)
Open circle with a tail. The dot
adds an extra beat to the half
note.
Dotted Quarter Note 1.5 playNote(1, beats = 1.5)
Solid circle with a tail. The dot
adds an extra half-beat.
Dotted Eighth Note 0.75 playNote(1, beats = 0.75)
Solid circle with tail and one
fag. The dot adds an extra
quarter beat.

Standard notation also includes dotted notes, where a small dot follows the
note symbol. With a dotted note, you take the original note’s duration
and add half of its value to it. So, a dotted quarter note is 1.5 beats long, a
dotted half note is 3 beats long, and so on.
There are also symbols representing diferent durations of silence or
“rests”.

Symbol Name Beats TunePad code

Whole Rest 4 rest(beats = 4)

Half Rest 2 rest(beats = 2)

Quarter Rest 1 rest(beats = 1)

Eighth Rest 0.5 or ½ rest(beats = 0.5)


Sixteenth Rest 0.25 or ¼ rest(beats = 0.25)

2.4 Time signatures


In standard notation, notes are grouped into segments called measures (or
bars). Each measure contains a fxed number of beats, and the duration of
all the notes in a measure should add up to that amount. The relationship
between measures and beats is represented by a fraction called a time sig-
nature. The numerator (or top number) indicates the number of beats in the
measure, and the denominator (bottom number) indicates the beat duration.
Rhythm and tempo 25

Four-Four Time or “Common Time”


There are 4 beats in each measure, and each beat
is a quarter note. This time signature is sometimes
indicated using a special symbol:
Two-Two Time or “Cut Time”
There are 2 beats in each measure, and the beat
value is a half note. Cut time is sometimes indicated
with a ‘C’ with a line through it.
Two-Four Time
There are 2 beats in each measure, and the quarter
note gets the beat.

Three-Four Time
There are 3 beats in each measure, and the quarter
note gets the beat.

Three-Eight Time
There are 3 beats in each measure, and the eighth
note gets the beat.

The most common time signature is 4/4. It’s so common, in fact, that
it’s referred to as common time. It’s often denoted by a C symbol shown
in the table above. In common time, there are four beats to each measure,
and the quarter note “gets the beat” meaning that one beat is the same as
one quarter note.
Vertical lines separate the measures in standard notation. In the example
below, there are two measures in 4/4 time (four beats in each measure, and
each beat is a quarter note).

If you have a time signature of 3/4, then there are three beats per measure,
and each beat’s duration is a quarter note. Some examples of songs in 3/4
time are My Favorite Things from The Sound of Music, My 1st Song by Jay Z,
Manic Depression by Jimi Hendrix, and Kiss from a Rose by Seal.
26 Rhythm and tempo
If those notes were eighth notes, it would look like this:

Other common time signatures include 2/4 time (with two quarter note
beats per measure) and 2/2 time (with two half note beats in each measure).
With 2/2 there are actually four quarter notes in each measure because
one half note has the same duration as two quarter notes. For this reason,
2/2 time is performed similarly to common time, but is generally faster.
It is referred to as cut time and is denoted by a C symbol with a line
through it (see table above).
You can adjust the time signature of your TunePad project by clicking
on the time indicator in the top bar (see Figure 2.1).

2.5 Percussion sounds and instruments


Working with rhythm, you’ll come across lots of terminology for different
percussion instruments and sounds. Here’s a quick rundown on some of the
most common drum sounds that you’ll work with in digital music (Figure 2.6).

Figure 2.6 Drums in a typical drum kit.


Figure 2.6 was modified from an original drawing by Syed Wamiq Ahmed Hashmi (com-
mons.wikimedia.org/ wiki/User:Syed_Wamiq_Ahmed_Hashmi). Creative Commons
License creativecommons.org/licenses/by-sa/3.0.
Rhythm and tempo 27

Drum names Description TunePad


note number

Kick or bass The kick drum (or bass drum) makes a loud, low 0 and 1
drum thumping sound. Kicks are commonly placed on
beats 1 and 3 in rock, pop, house, and electronic
dance music. In other genres like hip-hop and funk,
kick drums are very prominent, but their placement
is more varied.
Snare Snare drums make a recognizable sharp staccato 2 and 3
sound that cuts across the frequency spectrum. They
are built with special wires called snares that give
the drum its unique snapping sound. Snare drums
are commonly used on beats 2 and 4.
Hi-hat The hi-hat is a combination of two cymbals 4 (closed)
sandwiched together on a metal rod. A foot pedal 5 (open)
opens or closes the cymbals together. In the closed
position the hi-hat makes a bright tapping sound. In
the open position the cymbal is allowed to ring out.
Hi-hats have become an integral part of rhythm
across almost all genres of popular music.
Low, mid, Tom drums (tom-toms) are cylindrical drums that 6, 7, 8
high tom have a less snappy sound than the snare drum. Drum
kits typically have multiple tom drums with slightly
different pitches (such as low, mid, and high).
Crash A large cymbal that makes a loud crash sound, often 9
cymbal used as a percussion accent.
Claps and Different TunePad drum kits include a range of 10 and 11
shakers other percussion sounds common in popular music
including various claps, shakers, and other sounds.

2.5.1 808 Drum kit


Released in the early 1980s, the Roland 808 drum machine was a hugely
influential sound in early hip-hop music (and other genres as well). The
808 used electronic synthesis techniques to create synthetic replicas of
drum sounds like kicks, snares, hats, toms, cowbells, and rim shots. Tin-
kerers would also open up the 808s and hack the circuits to create en-
tirely new sounds. Today 808s usually refers to low, booming bass lines
that were first generated using tweaked versions of the 808s’ kick drums.
TunePad’s default drum kit uses samples that sound like the original elec-
tronically synthesized 808s (Figure 2.7).

2.5.2 Selecting TunePad instruments


When you’re coding in TunePad, the sound that your code makes will
depend on the instrument you have selected. If you’re coding a rhythm,
28 Rhythm and tempo

Figure 2.7 Roland 808 drum sequencer.


The photograph shown in Figure 2.7 and at the beginning of Interlude 10 is by Brandon
Daniel (fickr.com/photos/54581307@N00). Creative Commons License creativecom-
mons.org/licenses/by-sa/2.0.

you can choose from several diferent drum kits including an 808 and rock
kits. You can change the instrument by clicking on the selector shown
below (Figure 2.8).

2.6 Coding rhythm in Python


Let’s start coding! Before beginning to code, there are a few quick things
that you should keep in mind.

Figure 2.8 Changing an instrument’s voice in TunePad.


Rhythm and tempo 29
2.6.1 Syntax errors
Python is a text-based language, which means that you’re going to be typ-
ing code that has to follow strict grammatical rules. When you speak a nat-
ural language like English, grammar is important, but you can usually bend
or break the rules and still get your message across. When you say something
ambiguous it can be ironic, humorous, or poetic. This isn’t the case in Py-
thon. Python has no sense of humor and no appreciation for poetry. If you
make a grammatical mistake in coding, Python gives you a message called
a syntax error. These messages can be confusing, but they’re there to help
you fx your code in the same way that a spell checker helps you fx typos.
Here’s what a syntax error looks like in TunePad (Figure 2.9).
This line of code was missing a parenthesis symbol, which generated the
error message “bad input on line 5”. Notice that Python is giving you
hints about where the problems are and how to fx them, but those hints
aren’t always that helpful and can be frustrating for beginners. We’ll give
you practice fxing syntax later in this chapter.

2.6.2 Flow of control


A Python program is made up of a list of statements. For the most part,
each statement goes on its own line in your program. Python will read
and perform each line of code from the top to the bottom in the order
that you write them. In programming this is called the fow of control.
This is similar to the way you would read words in a book or notes on a
line of sheet music. The diference is that programming languages also
have special rules that let you change the fow of control. Those rules
include loops (which repeat some part of your code multiple times),
conditional logic (which runs some part of your code only if some
condition is met), and user-defned functions (which lets you create
your own functions that can be called). We’ll talk about these special
“control structures” later in the book.

Figure 2.9 Example of a Python syntax error in TunePad. This line of code was
missing a parenthesis symbol.
30 Rhythm and tempo
2.7 Calling functions
Almost everything you do in Python involves calling functions. A func-
tion (sometimes called a command or an instruction) tells Python to do
something or to compute a value. For example, the playNote function tells
TunePad to make a sound. There are three things you have to do to call a
function:
First, you have to write the name of the function. Functions have one-
word names (with no spaces) that can consist of letters, numbers, and the
underscore _ character. Multi-word functions will either use the under-
score character between words as in:

my_multi_word_function()

or each new word will be capitalized as in playNote().


Second, after you type the name of the function, you have to include
parentheses. The parentheses tell Python that you’re calling a function.
Third, you include any parameters that you want to pass to the function
in between the left and right parentheses. A parameter provides extra in-
formation or tells the function how to behave. For example, the playNote
statement needs at least one parameter to tell it which note or sound to
play. Sometimes functions accept multiple parameters (some of which can
be optional). The playNote function accepts several optional parameters
described in the next section. Each additional parameter is separated with
a comma (Figure 2.10).

Figure 2.10 Calling the playNote function in TunePad with two parameters in-
side the parentheses.
Rhythm and tempo 31
2.8 The playNote function
The playNote function tells TunePad to play a percussion sound or a
musical note. The playNote function accepts up to four parameters con-
tained within the parentheses.

playNote(1, beats = 1, velocity = 100, sustain = 0)

Name Description

note This is a required parameter that says which note or


percussion sound to play. The kind of sound depends on
which instrument you have selected in TunePad for this
code. You can play more than one note at the same time
by enclosing notes in square brackets.
beats An optional parameter that says how long to play the
note. The TunePad playhead will be moved forward
by the duration given. This parameter can be a whole
number (like 1 or 2), a decimal number (like 1.5 or 0.25),
or a fraction (like 1/2).
velocity An optional parameter that says how loud to play the
note or sound. A value of 100 is full volume, and a value
of 0 is no volume (muted). Velocity is a technical term in
digital music that means how fast or how hard you hit the
instrument. You might imagine it as how loud a drum
sounds based on how hard it gets hit.
sustain An optional parameter that allows a note to ring out
for an additional number of beats without advancing the
playhead.

2.8.1 Optional parameters


Sometimes parameters are optional, meaning that they have a value
that gets provided by default if you don’t specify one. For playNote,
only the note parameter is required. If you don’t pass the other param-
eters, it provides values for you by default. You can also include the
names of parameters in a function call. For example, all four of the lines
below do exactly the same thing; they play a note for one beat. The
frst two use parameters without their names. The second two include
the names of the parameter, followed by the equals sign (=), followed
by the parameter value.

playNote(60) # the beats parameter is optional


playNote(60, 1) # with the beats parameter set to 1
playNote(60, beats = 1) # with a parameter name for beats
playNote(note = 60, beats = 1) # with a parameter name for note and beats
32 Rhythm and tempo
2.8.2 Comments
In the code above, some of the text appears after hashtag (#) symbols
on each line. This text is called a comment. A comment is a freeform
note that programmers add to make their code easier to understand.
Comment text is ignored by Python, so you can write anything you
want after the hashtag symbol on a line. You can also use a hashtag at
the beginning of a line to temporarily disable code. This is called “com-
menting out” code.

2.9 The rest function


Silence is an important element of music. The rest function generates
silence, or a break in the sound. It only takes one parameter, which is the
length of time the rest is held. So, rest(beats = 2) will trigger a rest for a
length of two beats. If you don’t provide a parameter, rest uses a value of
1.0 by default.
rest() # rest for one beat
rest(1.0) # rest for one beat
rest(0.25) # rest for one quarter beat
rest(beats = 0.25) # rest for one quarter beat

2.10 Examples of playNote and rest


Let’s try a few examples of playNote and rest to get warmed up. This
rhythm plays two eight notes (beats = 0.5) followed by a quarter note
(beats = 1). The pattern then repeats a second time.

Here’s how we would code this in TunePad with a kick drum and snare:

playNote(1, beats = 0.5) # play a kick drum (1) for half a beat
playNote(1, beats = 0.5)
playNote(2, beats = 1) # play snare (2) for one beat
playNote(1, beats = 0.5) # play kick (1) for half a beat
playNote(1, beats = 0.5)
playNote(2, beats = 1) # play snare (2) for one beat

Here’s another example that plays a quarter note followed by a rest of


0.5 beats followed by an eight note (beats = 0.5). The pattern is repeated
two times in a row:
Rhythm and tempo 33

playNote(2, beats = 1) # play a snare drum (2) for one beat


rest(beats = 0.5) # rest for half a beat
playNote(1, beats = 0.5) # play a kick drum (1) for half a beat
playNote(2, beats = 1) # play a snare drum (2) for one beat
rest(beats = 0.5) # rest for half a beat
playNote(1, beats = 0.5)

Here’s a third example that plays eight notes in a row, each an eight note
(beats = 0.5). See if you can write the code to make this pattern.

# write your Python code here


Another Random Scribd Document
with Unrelated Content
nothing, granted the armistice. Meanwhile the Turks approached,
and Khatun felt herself strong enough to attack the besiegers and
put them to flight. The defeat itself was not denied by the Arabian
historians: they only add, that the Mussulman army took a rich booty
in gold, silver, clothing stuffs, and weapons, in which were the
golden and jewelled boots of the queen, Khatun, the worth of which
was estimated at 200,000 drachmas. Abdullah-ben-Ziad felled all the
trees in the vicinity, and destroyed all the towns. Khatun felt anxious
for the fate of her land, and concluded peace with the Arabians,
which she bought, they say, for one million drachmas. In the year
56, Heg., Said ben Osman was named governor of Khorassan. He
crossed the Oxus and fell on Bokhara. Khatun wished to buy a peace
for a similar sum to that which she gave Abdullah ben Ziad. Despite
of this offer, Said, who stood with 120,000 men in Kesch (Shehr
Sebz) and Nakhsheb (Karschi), refused compliance, gave battle, and
after he had beaten the army of Khatun, made peace. The queen
was obliged to submit, and entered the army of the Arab as a vassal.
[37]
The submissive State gave eighty hostages, and Said ben Osman
went to Samarkand, which he also took, and thence, laden with rich
treasures, returned back to Medina. The report goes, that the
hostages which Khatun gave to the Arabian field-marshal were
officers who doubted the legitimacy of Tugshade, and plotted
together against the queen. According to agreement, they wanted
merely to accompany the Arab army as long as they remained in
Bokhara, but Said wished to have them with him as trophies of his
victory when he entered Medina. This moved the deceived
Bokharians; and when they saw their ruin unavoidable, they wished,
at least, to die avenging themselves. They slew Said, and then
severally destroyed each other. In his turn, Muslim ben Ziad was
named ruler of Khorassan. He hastened quickly to his post, drew
together a considerable army, and fell on Bokhara, again become
faithless. Khatun quickly perceived that she, alone, was no match for
him, and sought everywhere help. She gave her hand to Terkhan,
Prince of Samarkand, to purchase protection for her country; also
the mighty Turkish prince, Bendun, was called in to aid. When all the
assistance had been promised, Khatun hastened to conclude a truce:
the Arabs consented; when Bendun appeared with 120,000 men,
and induced the reluctant queen to violate the truce. The Arabian
field-marshal was extremely incensed, and sent one of his officers,
by name Mehleb, to Khatun, to remind her of her blameable neglect
of duty. Mehleb took from each company a man with him, quitted
secretly the camp by night, with the intention to surprise, on some
point, the enemy's army. He was already arrived on the banks of the
river (Zerefshan), when some Arabs, thinking that the question was
a matter of booty, joined him. Their united force was not more than
900 men. The enemy's cavalry discovered this, and at the first onset
cut down 400 of them. The rest fled quickly back, but were followed,
and towards daylight reached near to Khoten. The Turks opened a
bloody battle; Mehleb was surrounded on all sides, and announced,
by a powerful shout, his position to the nearest Arabian camp. The
signal was heard; Muslim knew the voice of Mehleb, heeded it but
little, and only Abdullah, who blamed the indifference of the
commander-in-chief, mounted his horse in order to assist his brother,
who was hard pressed. This approach gave courage to Mehleb and
his followers. The battle was renewed; Bendun fell, and the Turks
were put to flight with great loss. An immense booty fell into the
hands of the conquerors; and it is said that each horseman received
about 1,000 dirrhems. After this incident Khatun made peace, and
did homage to the Arabs. She also appeared in the camp, and did
homage again. She requested to see Abdullah, whose heroic deeds
had astonished the whole army. Muslim called him. He wore a blue
tunic with red girdle, and favourably impressed the Queen by his
noble appearance, and she made him great presents. The fourth
Arabian field-marshal was Kuteibe ben Muslim. He went to
Khorassan, under the Kaliphate of Hudjadj, conquered on his way
the provinces of Tocharistan, and crossed the Oxus, in 88 Heg.
Peykend was apprised of his approach, a strong walled fortress, the
taking of which cost him a hard struggle. The Arabs were forced to
besiege it fifty days, and suffered considerably. Since force could
produce no effect, he was obliged to employ stratagem, and caused
it to be undermined, and the fortress was thus surprised. He
pardoned the inhabitants, made peace with them, and leaving Varka
ben Nasr-ullah as governor, went to Bokhara. Intelligence soon
reached him that the Peykendis had killed the governor, whom he
had left behind, and who, as it proved, had provoked the revolt by
his cruel deeds. Kuteibe hastened back, plundered the city,
destroyed it, killed all the men able to bear arms. The rich and
mighty Peykend, which maintained an extensive commerce in teas
from China and other goods, was utterly destroyed. Some portions
were restored later, but its prosperity was gone for ever. They relate
that the Arabs, among abundant treasures, found a silver idol,
which, with the robes, was worth 150 miskal. Among things most
worthy of remark, were two pearls, as large as a pigeon's egg.
These, according to the report of the Peykendis, were brought into
the temple by a bird. Kuteibe sent such things to the Khalif Hudjadj
as a present, who, in a letter of thanks, expressed both his
admiration for the objects, and the high spirit of the sender. From
hence he went to Vardun, (now Vardanzi) which he spoiled, with all
the other villages belonging to it. These successful advances of the
Arabian army terrified the small princes of that neighbourhood, and
they united, and attacked, with joint forces, the invaders. As the
Arab historian affirms, Kuteibe was greatly distressed. He was also
destitute of arms; and they say that a lance was bought for 5
dirrhems, a helmet for 50, the cuirass for 900. Happily, the ruler of
Samarkand, by cunning and deceit, had withdrawn from the alliance
to go over to the Arabs; and the Turkish leader having obtained
information that fresh auxiliary troops had arrived in Kesh and
Nakhsheb, retreated to Vardun; and Kuteibe remained undisturbed
in the possession of the conquered province in Transoxiana.

Tugshade and Mokanna, the Veiled Prophet of


Khorassan.
Tugshade, who, after the death of his mother, was chosen King of
Bokhara, had to thank Kuteibe, alone, for his throne, since he
supported him against his powerful neighbour, the Governor of
Vardun, who invaded Bokhara repeatedly, but was always driven
back by Kuteibe. This feeling of gratitude may have been the
principal cause that Tugshade went over to Islam, and distinguished
himself by his remarkable ardour in favour of the new opinions. He
reigned thirty-two years, not so much as an independent prince, but
as the vassal of Kuteibe, who found in him a mighty aid in
propagating by force the doctrine of Mohammed, which the
inhabitants of Bokhara were much disposed to reject. As the Arabian
adventurers made conversion to Islam the chief condition in
submitting, the Bokhariots, at each capture of their capital,
acknowledged, in appearances, Islam, but after the departure of
their conquerors returned to their beloved national religion, the
Parsi. Kuteibe wished to check this. He ordered, therefore, that the
half of the houses of the whole town should be given up to the
Arabs. The proselytes were placed, by these means, in the
immediate neighbourhood of men who continually watched them,
and urged them to the new doctrine. In the year 94 Heg., he
permitted a large Mosque to be built, in which all were to assemble
for prayer on Fridays, and in which the Koran should be read, in an
emphatic manner, in the Persian language. This mosque existed
even in the time of our author's writing, who besides adds that upon
the doors figures of animals were cut, (which, as is known in every
place of Islam, to say nothing of a mosque, is treated as a gross
offence): the reason of this, they say, was, that these animals were
taken from an earlier temple of the Fire-Worshippers, and retained
afterwards.
Tugshade reigned thirty-two years. After his death, Kuteibe, his son,
(whom he so named, from attachment to the Arabian field-marshal),
took the throne. At the commencement of his reign he affected the
Musulman, but, as it was soon apparent that he was secretly
attached to the old religion, he was executed by order of Ebn
Muslim, the ruler of Khorassan, and in his stead, Benyat, also a son
of Tugshade, was named Lord of Bokhara. Under both these latter
reigns, it happened that the Sefiddjamegan (the white-clothed), as
the followers of Mokanna, the Veiled Prophet of Khorassan, have
been called, raised, with the new doctrine, the standard of rebellion
against the Arabian conquerors. In like manner with Kuteibe, the son
of Tugshade, did the other son, Benyat, go over to the rebels, and
was put to death by order of the Khalif, 166 Heg. The family of
Tugshade held the throne of Bokhara till 301 Heg., when Ibn Ishak,
the son of Ibrahim, the son of Khalid, the son of Benyat, ceded his
rights to Emir Ismael, the Samanide.
As to the history of Mokanna and the Sefiddjamegan, this movement
might have had, certainly, dangerous consequences for Islam in
Central Asia, if the authorities in Bokhara, and particularly the Khalif
Mehdi, had not used all proper precaution. Mokanna, (as is related in
the MS. lying before me), the veiled prophet of Khorassan, whose
real name was Hashim bin Hekim, was born in the village of Geze,
near Merw, and early occupied himself with many kinds of
knowledge, but especially with enchantments and secret arts.
He was named Mokanna, or the Veiled Prophet, on this account,
because he covered his head constantly with a veil, for he was
deformed in features, one-eyed, and, moreover, bald. He had, no
doubt, under Ibn Muslim a high military rank, as he there once came
out in his character of prophet; he was seized, sent to Bagdad, and
there put in prison. He escaped thence and came back to Merw, and
when he showed himself among his people, for the first time, he
demanded, "Know ye who I am?" They said unto him, that he was
Hashim bin Hekim. He replied, "You are in error. I am your God, and
I am the God of all people. I call myself what I will. I was earlier in
the world in the form of Adam, Ibrahim, Moses, Jesus, Mohammed,
Ibn Muslim, and now in the form in which you see me." "How is it,
then," they asked of him, "that these make themselves known as
prophets, but you wish to be God?" "They were too sensual, but I
am through and through spiritual, and have constantly possessed
power to appear in any form." He lived, then, in Merw, but his
agents moved about everywhere in order to gain followers, and his
letters of mission began thus:—
"In the name of the Merciful and Gracious God, I, Hashim, son of
Hekim, Lord of all lords. Praised be the One God, He who was before
in Adam, Noah, Ibrahim, Moses, Christ, Mohammed, Ibn Muslim; He
who was manifested before all these, namely, I Mokanna, lord of
might, brightness, truth,—rally round me and learn, for mine is the
lordship of the earth, mine the glory and power. Besides me there is
no god; he who is with me goes to Paradise; he who flies from me
goes to hell."
Among his adherents an Arab, named Abdullah, principally
distinguished himself, and, in the vicinity of Kesh, misled very many.
At a later period the greater part of the villages around Samarkand
and Bokhara went over to him. The professors of the new sect
became from day to day stronger, and with their numbers increased
also both uproar and riot, and the alarm and cries of the Musulmans.
When the governor of Khorassan was informed of this issue he
wished to seize Mokanna; who then kept himself concealed a long
time, and though all the passes of the Oxus were guarded, he
succeeded in escaping over to the Transoxanian side, and effected a
retreat into a strong fortress on the mountain of Sam, near the town
of Kesh (the modern Shehr Sebz). The Khalif Mehdi also was struck
with terror at the intelligence. He sent first troops, and then arms in
person to Nishapur, for it had become a question whether the
partisans of Mokanna would not obtain the upper hand, and Islam
sink to the ground. At that time in the new sect robbery and murder
having been permitted, immense hordes out of Turkestan joined the
revolters, the Musulmans were hard pressed on all sides, their
villages plundered, their women and children carried away to prison.
In the year 159 Heg. the commandant of Bokhara went against
them with a considerable force, and the contest between the
partisans of Mokanna and the Mohamedans lasted in that country
many years. The Veiled Prophet moved not from his fortified
position, his spiritual influence was sufficient to stimulate his
followers.
The Arabian garrison of Bokhara, with the few which remained true
to Islam, soon felt itself too weak against the number and fanaticism
of their far superior enemy. Aid was sent from Bagdad under the
command of Djebrailo bin Yahya; and the well fortified place,
Narshakh, which was a residence of the Sefiddjamegan, was first
attacked. After a close and vain siege the walls could only so far be
damaged as to allow a ditch that was fifty yards long to be filled with
wood and naphtha: this they fired, and the cross beams of the wall
became consumed, and the whole mass without support fell. With
sword in hand the Mohamedans rushed into the fortress, many were
massacred, many yielded under the condition of retreating with their
arms. The fortress was evacuated, yet when the Sefiddjamegan
heard that their commanders were put to death in a traitorous
fashion, they themselves took up arms in the enemy's camp. A fresh
contest arose, in which the Arabs conquered, and the supporters of
Mokanna were partly destroyed, partly put to flight. After Narshakh,
Samarkand had to be forced, the inhabitants of which, in great part,
were known to belong to the new sect. The sieges and battles of
these places lasted more than two years (because a great number of
the Turks had joined the Samarkanders without any result being
obtained).
Mokanna, the mysterious prophet, kept himself during this period
always in his fortress, attended by one hundred of the loveliest
women of Transoxiana. The interior of the castle was kept only for
these with himself and one male page; besides these was no earthly
eye permitted to penetrate into his sanctuary. They say that 50,000
of his followers lay at the gate of the fortress, and earnestly
implored him to show but once his god-like splendour. He refused,
sent his page with the message:—"Say to my servants that Musa
(Moses) also wished to see my godhead, but the beams of my
splendour he could not support. My glance kills instantly the earth-
born." The enthusiastic adherents assured him that they would
gladly offer their lives as a sacrifice if this high enjoyment was
allowed to them. When he could not furthermore deny them,
Mokanna consented to their entreaty, and appointed them to come
at a certain time before the gate of the fortress, where he promised
to show himself. On the evening of the appointed day he ordered
that his women should be placed in a line, with looking-glasses in
their hands, as the beams of the setting sun were reflected in the
looking-glasses, and when everything was illuminated by that
reflection, he ordered them to open the doors. The splendour
blinded the eyes of his devoted adherents, who fell prostrate, and
called out,—"God! enough for us of thy glory, for if we see it more
all will be destroyed!" They lay long in the dust supplicating him,
until at length he sent his page with the message:—"God is pleased
with you, and he has given you for your use the good of all the
world."
Fourteen years long Mokanna is reported to have lived in this
fortress consuming his time with women in drinking and carousing.
The Arab field marshall, Said Hersi, had at last, after a hard siege,
driven him into straits. The outer part was taken, and there was only
the inaccessible citadel on a higher eminence. With the extinction of
his ascendant star Mokanna was abandoned by his followers, and
when he saw the inevitable ruin nigh he decided, in order not to fall
into the hands of his enemies, rather to destroy himself with his
women and treasures. He gave to the women at a last carouse a
strong dose of poison in wine, and challenged them to empty a
goblet with him. All drank but one, who poured the wine into her
bosom, and as an eye-witness, told later the whole catastrophe.
According to her, Mokanna, after all the women had fallen dead, cut
off the head of his faithful page, and, quite naked, burnt himself,
with his treasures, in a furnace, which had been heated for three
days. He announced before that he wished to go to heaven to call
the angels to his help. "I have long watched the furnace," said the
fortunate woman who escaped, "but he never came back in that
fashion." After the death of Mokanna there were many curious sects
and creeds, but they concealed themselves from the ever increasing
power of Islam. Under the Samanides the doctrine of Mohammed
spread more and more, and Transoxanian countries became soon
famous for their religious zeal.
CHAPTER XVI.
ETHNOGRAPHICAL SKETCH OF THE TURANIAN
AND IRANIAN RACES OF CENTRAL ASIA.
THE TURKS OF EASTERN ASIA.—PHYSIOGNOMY AND
CUSTOMS.

I think that there are few points upon the whole terrestrial globe,
which are of greater importance for our historical researches than
the oases of Central Asia. These in the primitive times were
inexhaustible floodgates for those warlike hordes, who often
inundated and conquered the most beautiful spots of Asia, streaming
towards the west in wild torrents, and even occasioning alarm
among Europeans. No people can be so interesting for us upon the
subject of Ethnography as the Turko-Tartars, who, under such
various names and forms, have appeared on the scene of the events
of the world, and have had such powerful influence over our own
circumstances. Is it not surprising that of all nations we are the least
acquainted with these? Huns, Avars, Utigurs, Kutrigurs, Khazars, and
so many others, float before our sight only in the mist of fable. The
clash of arms which sounded through them from the Yaxartes to the
heart of Gaul and Rome has long since ceased. In vain should we
inquire even into their origin, did we not find in the scanty dates of
the Western chronicles of that period some points of reliance. These
dates show us that between the Tartar tribes of that age and the
present inhabitants of Central Asia there did exist an analogy of an
unmistakeable character. We detect this in descriptions of them—in
the accounts of their manner of living—all evincing much
resemblance to the customs and physical condition of the present
inhabitants of Turkestan. A similar life to what Priscus describes in
the Court of the King of the Huns is met with to-day in the tent of a
nomadic chief. Attila is more original than Djingis or Taimur, but as
historical personages they resemble each other. Energy and good
fortune could now almost produce upon the borders of the Oxus and
Yaxartes one of those heroes, whose soldiers, like an avalanche,
carrying everything before them, would increase to hundreds of
thousands, and would appear as a new example of God's scourge, if
the powerful barriers of our civilisation, which has a great influence
in the East, did not stop the way. The people of Central Asia,
particularly the nomadic tribes, are, in the internal relations of their
existence, the same as they were two thousand years ago. In these
physiognomical signs we find already changes from a mixture of
Iranian and Semitic blood (chiefly after the Arabian occupation). The
features of the Mongolian-Kalmuck type here and there approach the
Caucasian race. The Tartar in Central Asia is no longer what we see
him represented by the Greek-Gothic writers, for even in the times of
Djingis he was no longer the same. It is, therefore, of great interest
to mark how this change in physiognomical type continually
decreases from the east to the west—how this Deturkism, if I may
so express myself, is perceptible among the various races of Central
Asia, and in what degree their various gradations through social
circumstances came, more or less, in contact with foreign elements.
This will especially be seen by a cursory view of the Turkish nations
of Central Asia from Inner China to the Caspian Sea; but those Turks
who stretch hence up to the Adriatic, or to the banks of the Danube,
are West Turks, and cannot be included in the unity of race so much
by physiognomical type as by analogy of speech, characters, and
customs.
With the former, whose masses have retained compactly together
the unity of the race, in spite of all those ways in which the Central
Asiatics differ remarkably from one another—in spite of our
ethnographical names,—the distinction shows itself clearly in their
features and common physical type. Whatever views we may
entertain of the origin of the Turks, so much is certain, that they are
closely related to the Mongols; the relation being much closer than
those which subsist between the Indians and Persians in Iran. Much,
very much indeed, is to be done before we have investigated the
mutual relations of the whole Turko-Tartaric race, which stretches
from the Hindu Kush to the Polar Sea, from the interior of China to
the shores of the Danube. Our present sketch is only a weak attempt
at a small portion—general views upon all that personal experience
has presented to our observation; and it may here and there exhibit
somewhat of novelty. Through the extent known to us from East to
West, we divide the Turks into the following classes:—
1. Buruts, black or pure Kirghese. 2. Kirghis, properly Kazaks. 3.
Karakalpaks. 4. Turkomans. 5. Œzbegs.

Buruts.

These are pure, or black (Kirghis), and dwell on the eastern


boundary of Turkestan, namely, the valleys of the Thian-shan chain
of mountains, and inhabit several points on the shores of the Issik
Köl, close upon the frontier towns of Khokand. As I am told (I have
only seen a few of them), they are thick-set, but of powerful stature,
strong-boned, but remarkably agile, to which last quality their
warlike renown is attributed. By their physiognomy alone are they to
be distinguished from the Mongolians and Kalmucks: the face is less
flat, their cheeks less fleshy, their foreheads somewhat higher, their
eyes are less almond-shaped than those of the latter. With regard to
their colour, they can be little distinguished from the neighbouring
nomadic races; red or fair hair and white complexion (by which type
our European scholars would claim relationship for this race with the
Finlanders and other north Altaic races) are rarely found; at least,
my Khokand friends assured me that among hundreds there were
scarcely one or two.[38] In all likelihood the Kiptchaks, of whom I
have made mention in my travelling journal at page 382, are no
other than a division of the Buruts, who are settled down in and
around Khokand, and have caught, both from Islam and from their
social relationship with Turkestan, far more than the rest of the
Buruts, who, through their contact with Kalmucks and Mongolians,
now and then profess themselves more or less Islam. Their language
also contains many more Mongolian words than the dialect of the
Kiptchaks. From this most original Turkish people we pass over to
the second gradation, which is—

The Kirghis.

Among the Kirghis or Kasak (as he calls himself), the character of


the Mongol Kalmuck type is no longer to be met with in such a
striking manner as among the Buruts, although he is hardly to be
distinguished from the latter in language and manner of life. In
colour, he nearly resembles the rest of the inhabitants of the deserts
of Central Asia. The women and youths, in general, have a white
and almost European complexion; still this becomes soon altered,
through the manner of living in the open air, in heat and cold. The
Kirghis are of thick-set and powerful frames, with large bones; they
have mostly short necks,—a real type of the Turanian, opposed to
the long-necked Iranian; not very large heads, of which the crown is
round, more pointed than flat. They have eyes less almond-shaped,
but awry and sparkling, prominent cheek-bones, pug noses, a broad
flat forehead, and a larger chin than the Buruts. Their beards have
little hair on the chin, only on both ends of the upper lip; and it is
remarkable, that they lament this deficiency, and by no means find
such delight in this physiognomical characteristic as in the projecting
cheek-bones, small eyes, &c., which are esteemed by them as
beauties.[39]
Since, as we have said, the type of the primitive race is no longer so
striking among them and universal as among the Buruts and
Kalmucks, so also we find their ideal of perfect beauty derived only
from their neighbours, with whom they gladly intermix; and
Lewschine[40] has rightly stated a fact, when he mentions the
preference they allow the Kalmuck women before their own. That
from their great extension through the northern desert lands of
Central Asia, perceptible shades may be met with in the external
traits is scarcely to be doubted;[41] but one easily comprehends that
our classification into great, little, and middle hordes, is unknown to
them; for, from the mutual tie of the manner of living, customs and
dispositions, they remain always the same, in spite of the many
subdivisions into branches, families and lines, which they, like the
Turkomans, gladly consider as decided separations. Whether on the
shores of the Emba or of the Sea of Aral, as well as in the environs
of the Balkhash and Alatau, there is little difference to be found in
the dialects spoken by them. Many tales and songs, many national
dishes, and national games, are, throughout the year, to be met with
in like manner; and although they may occur but seldom, still, love
of travelling and warlike disturbances have often brought together
the most distant races.
In their dress, the Kirghis are to be distinguished from the rest of
the nomadic tribes and settlers: in Central Asia, mostly by their
head-gear. The men wear, in summer, a felt hat (kalpak); in winter, a
cap (tumak), with fur covered with cloth, the back-flaps of which
protect the neck and ears. Besides these, they have still a little fur
cap (koreysh), which, however, is employed more for in-door use.
The women wear a sheokele, which is distinguished from the
Turkoman head-dress in that it is more conical, and allows the veil to
fall not before, but down the back to the loins. The hair, also, is
dressed in a different fashion. The young Turkoman women plait the
hair in two plaits; the Kirghis with eight thin ones, four on either
side. They cover their heads with a letshek, in cloth, which covers
head and neck. In negligé attire, the girls twist red handkerchiefs
round their heads, but the women white or dark-coloured ones. The
upper garments have the same tasteless form, with many folds, as
everywhere in Central Asia, only more of the bright and glittering
colours are liked; and in the north of Khokand it is the custom for
the young Kirghis to prepare for themselves a garment from the raw
hide of the fox-coloured horse, besides which they let the horse's tail
hang down from the neck as an ornament. In their coverings for
their feet, the only distinction is, that the western have adopted the
Russian form of boot; the eastern, on the contrary, the Chinese;
namely, with pointed, curved toes, and slender, high heels.
The religion is almost universally the Mohammedan; still, in a very
lax condition, which is the case with nearly all the nomadic tribes in
connexion with Islam.[42] Before and long after the Arabian
occupation of Central Asia, the Kirghis professed Shamanism, and it
is not to be wondered at, considering the little influence which the
teachers of Mohammed could maintain there, that much of the early
faith remains there now, and out of a whole tribe, which consists of
many hundred tents, there are often only one or two persons among
the chiefs who can read the Koran a little.
The greater part of them are the bad students out of the schools of
the three Khanats, who for pay go into the army in the deserts. The
true proselyte zeal has long become extinct, and the able seek
employment in the town.[43] To keep a Mollah or an Akhond is
besides more fashionable, for it points out the affluent condition of a
party. To the nomadic tribes their material condition is of more
consequence; they look upon religion as a secondary object. They
call themselves Mohammedans, but prayers, fasts, and other
religious acts are little observed by them, and it will in consequence
not appear at all remarkable that superstition, that reminiscence of
the infancy of all people, still plays here an important part.
Chiromancy, astrology, casting out devils, breathing on the sick, and
other humbugs we will not mention, since we find them in the
educated Islamite countries, as Persia, Turkey, and even in
enlightened Europe. Of the superstitions of the Kirghis those only
are most interesting for us which relate especially to the earlier
faiths of these nomadic tribes, and furnish us thereby with some
ideas as to their earlier social relations. That sacrifices were offered,
the still existing oracle upon the shoulder-blades and entrails proves.
The first, called Keöze süyeghi, consists in placing on the fire, clean
and pure, the shoulder-blade of a sheep just slaughtered, keeping it
in the flames until it is quite reduced to powder. It is then carefully
laid down, and the experienced person, who is generally a grey-
beard, a Bakhshi, or a Quack (Kam) studies the crevices of the burnt
leg with the greatest seriousness and a countenance full of
importance.[44] When the cracks run parallel with the broad end of
the leg it signifies good fortune, but if in the opposite direction a
misfortune. The latter, naturally, is seldom detailed. Still this is no
wonder, for when the civilized Greeks were cheated at Delphi and
Dodona, why should not this happen among the Kirghis deserts. To
prophesy from the position and twisting of the entrails is a rare
knowledge, in which the Kalmucks pretend to be particularly
distinguished. It is remarkable that this oracle is only consulted
when they are curious to know the sex of a child that is to be born.
Fire also must probably have been held in high honour, because it
was not allowed to spit on it. Ceremonies and dances are held
around it, a custom which exists in a wonderful manner in so many
parts of Asia, Africa, and Europe, and is still carried on in this district
as well as in Khiva and Khokand. To blow out a light is considered
very ill bred by the Kirghis in the whole of Central Asia; and finally
from the colour of burning oil, fat, &c., many prognostics are
divined. The superstition of the women is enormous, and really
deserves the trouble of a particular study. A girl, when only in her
fourth year, is possessed with it as completely as an elderly nomadic
matron who has passed her whole life in the lonely desert which
developed all her intellectual faculties in that direction. Each
individual part of the tent, each utensil, has some superstition in
connexion with it, which is strictly observed in pitching a tent, in
milking, cooking, spinning, and weaving, far more than the laws of
Islam, which are never particularly taken to heart. But the favourite
divination of these soothsayers is from fresh-spun thread. Four
stones are laid down, two white and two black; in the midst is a
thread, strong twisted, and the other end suddenly set free. If the
thread in its fall sink down to the black stones, it signifies
misfortune; to the white, the contrary. From the hand of the twister
no action is descried, for the oracle must be infallible. This is called
Tyik Yip, and is to be found everywhere in Central Asia.
Of food which is peculiar to the Kirghis we will name Sürü, which
consists of smoke-dried flesh (horse or sheep's flesh) cut into small
pieces, roasted in fat. The preference for this arises from its keeping
for weeks carried about without spoiling. Ködje, ordinary wheat, is
cooked in water and eaten in sour milk.
As national games of the Kirghis, we may mention tadjak-kisimo
(stocks). It consists in leaping over a rope held high. The winner is
applauded, the clumsy, on the contrary, are pressed between two
chairs, and exposed to the jeers of the company. Further, "eshek
yagiri" (wounded asses' back), in which in running they must leap
over three or four squatting play-fellows.

3. Karakalpaks.

These form the third division in the race, and are essentially different
from the Kirghis in physiognomical expression, although allied in
language and customs. The Karakalpaks are distinguished by a tall,
vigorous growth and a more powerful frame than all the tribes of
Central Asia. They have a large head with flat full face, large eyes,
flat nose, slightly projecting cheek-bones, a coarse and slightly
pointed chin, remarkably long arms and broad hands. Taken as a
whole, their coarse features are in good harmony with their not less
clumsy forms, and the nickname of the neighbouring people
Karakalpak.
Yüze yalpak.
Üzi yalpak.
Karakalpak, (has a flat face, and is himself totally flat). This
sobriquet has not been uttered without reason. The complexion
approaches that of the Œzbegs, particularly that of the women, who
long retain their white complexion, and with their large eyes, full
face, and black hair, do not make an unpleasant impression. In
Central Asia they are highly renowned for their beauty. The men
have pretty thick, but never long beards. The Karakalpaks, who are
sometimes falsely ranked with the Kirghis, are at present only to be
met with in the Khanat of Khiva, to which they moved at the
beginning of this century. A man of this tribe relates to me that they
lived earlier on the banks of the Yaxartes, and certainly near its
mouth, whilst another portion abides in the neighbourhood of the
Kalmucks, probably in the government of the Semipalatinsk.
The first part of this report does not seem to me to be a mere
invention, for Lewschine (in the above-cited work, p. 114), reports,
speaking of the ruins of Djemkend, that even in the last century
Karakalpaks had lived there. According to all probability they have
separated for a long time from the Kirghis, to whom they approach
nearest, and now they form, with respect to their physiognomy, the
transit point from the latter to the Œzbegs. In their dress they draw
nearer to the Œzbegs than the Kirghis. The men wear large telpek
(fur caps) which fit low in the neck and cover ears and brow; the
women have a cape like a cloak round the throat, and are delighted
with red and green boots. The tent of the Karakalpaks is much
larger, and of stronger construction than that of the rest of the
nomadic tribes, and is guarded by a species of large dog, only to be
met with among this tribe. In their dwellings in general they are
distinct from the other nomadic tribes in dirt and uncleanliness; they
evince also in their food and clothing a carelessness, which makes
them abundantly ridiculed and disliked by their neighbours. To their
national dishes belongs the torama, which consists of finely chopped
meat, and is cooked with a large quantity of onions (which vegetable
is much liked there) and mixed meal. Kazan djappay, meal baked in
a pan in fat, which is considered a dainty. Lastly, baursak, a meal
which consists of a four-cornered piece of pasty filled with meat.
A favourite game is kumalak, resembling the game in Europe. It is
played with dried excrements of sheep. Many of them devote
themselves to games of chance.

4. The Turkomans.

These, which I designate as the fourth gradation of the Mongolian


Turkish race in their westerly extension, possess many of the
peculiarities of the Kirghis as well as of the Karakalpaks. The pure
Turkoman type, which is to be found among the Tekke and Tchaudor,
living in the heart of the desert, is denoted by a middling stature,
proportionately small head, oblong skull (which is ascribed to the
circumstance, that they are not placed at an early period in a cradle,
but in a swing, made of a linen cloth), cheek-bones not high,
somewhat snub noses, longish chin, feet bent inwardly, probably the
consequence of their continual riding on horseback, and particularly
by the bright, sparkling, fiery eyes, which are remarkable in all sons
of the desert, but especially in the Turkomans. As regards colour, the
blond prevails, and there are even whole tribes, as, for example, the
Kelte race among the Görgen Yomuts, which are generally half
blond. On the borders of the desert, but particularly at the Persian
frontiers we find this principal trait already quite altered by the
frequent and considerable intermixture with the Iranian race, in
which one sees many men with thick black beards, and often
without the least trace of the Mongolian Turkish race. Indeed, the
Göklens are those who, with the exception of the formation of the
eyes, most resemble the majority of the Persians.
Slave-dealing, which from immemorial times has been practised in
the northern provinces of Persia, has there, where the intermediate
trade with Persian slaves takes place, left many traces behind. Still,
only upon the borders, for those living in the interior of the desert
and occupying themselves more with the peaceable occupation of
keeping cattle than with alamans (foray) have, on the average,
preserved the marks of the pure Turkoman type. As the nomads are
generally more agile and quick than the settled tribes, which is
naturally to be attributed to the endless wanderings of their
adventurous existence; so the Turkomans are to be distinguished in
this peculiarity from all the dwellers in tents in Central Asia. And
their slender frames, hardened by a very poor food, can outdo even
the Arab in privations and endurance. Taken as a whole, the
Turkomans cultivate (spite of the type of a family unity) a strange
mixture of customs and habits, which are found either here and
there among the neighbouring nomads and Œzbegs, or only among
themselves. While their language approaches to the Azerbaïdjan
dialect, their customs have the pure Turko-Tartarian stamp; and in
their social relations, as well as in their warlike existence and their
abundant religious usages, they have more in common with the
Kiptchaks than with the Kirghis, Karakalpaks, and Œzbegs, with
whom they have lived in close connexion for so many centuries. That
they separated themselves early, very early, from the greater part of
the Turko-Tartarian nations, admits of no question. There is no
doubt, according to their own assertions, that they moved first from
the east to the north-west, namely, towards the southern frontier of
the former main horde, and thence towards the south. This assertion
is very probable, and as alleged proofs of it, we may cite the small
number who have remained behind on the road as remnants, and
are still now to be found. As such, are cited the Turkomans to the
north of Kermineh and Samarkand, who, in the midst of kindred
elements have remained true to their nationality. Their emigration
from Mangishlak, unquestionably the oldest abode of the
Turkomans, is indicated by the Central Asiatics themselves in the
following chronological order. As the oldest in their present native
country, we name the Salor and Sariks; after them come the
Yomuts, who, before the period of the Sefevides, stretched from the
north towards the south along the shores of the Caspian. It is said
that the Tekke, at the time of Taimur, were transplanted to Akhal in
small numbers, in order to paralyse the great strength of the Salor.
The Ersaris, towards the end of the last century, from Mangishlak
have settled upon the shores of the Oxus; whilst, finally, the
Tchaudors, of the more recent period of Mohammed Emin Khan
(Khiva), from the shores of the Aral and Caspian Seas, are shifted to
the opposite bank of the Oxus, although many of that tribe are to be
found in the old places. As the Turkoman's chief employment aims at
pillage, it is natural to expect that many of their customs should
harmonize with this. Their attire, although in its origin of the Khiva
fashion, is made shorter and closer, that they may be able more
easily to take hard exercise: the heavy fur cap is replaced by a
smaller one. Their drawers, which supply the place of trousers, are
very wide, and remind one of the national garb of the Hungarian
peasants. The curls of hair which hang down behind the ears far
over the shoulders of the young, are peculiar to this tribe. These are
allowed to grow by the young; during the first year of married life,
they are worn concealed in the cap, and only after its lapse cut off.
This ornament gives to the young cavalier a stately appearance
whilst riding, and he is not a little proud of it. The dress of the
women, also, has some peculiarities, to which belong the upper
garment, hanging down, long-armed, like the Hungarian jacket; the
head-gear, and the masses of silver ornaments,—as bracelets,
necklaces, amulets, etuis, &c. It is not unusual to meet among the
women perfect beauties, not inferior to the Georgians in growth and
regularity of features. Though the young girls in all nomadic tribes
are tolerably practised riders, the young Turkoman women stand
pre-eminent in this art. With regard to their religious zeal for Islam,
their proneness to superstition is the same as that of the Kirghis;
and as the readers of my "Travels" are more acquainted with them,
we will pass from them to the Œzbegs.

Œzbegs.

These may be considered the established and civilized inhabitants of


Central Asia, and they have retained only feeble traces of the
Mongolian-Turkish race, owing to considerable intermixture with the
ancient Persian elements, and also the great number of slaves, who
are brought there out of the present Iran. In their broad faces,
sound of voice, the sharp angle which the temples form, and
especially the eyes, we recall their Tartar origin. The Œzbegs were
always pointed out by the Tadjiks by the nickname of Yogunkelle
(thick skull), and really this part of their body is thicker and coarser
than that of the rest of their Turanian fellow races. Besides the
diversity that reigns among them in the three Khanats and in
Chinese Tartary, you may further observe that the dwellers in
villages generally possess more signs of the national type than
townsmen. For instance: Œzbegs of Khiva are to be recognised by
the broad, full face, low, flat forehead, large mouth; the Œzbegs of
Bokhara, by the somewhat more arched foreheads, more oval faces,
and long, pointed, oblong chin, and the great majority by black hair
and eyes. Also in colour there are some shades of resemblance. In
the neighbourhood of Kashgar and Aksu yellowish-brown to blackish
tint prevails; in Khokand, brown; in Khiva, white is the reigning
colour. Indeed, the Œzbegs are bastards of the Turanian race, in the
same manner as the Tadjik and Sarts (the aborigines of the ancient
Transoxiana, Sogdia, and Fergana[45]). Of the origin, immigration,
and settlement of the Œzbegs, we have but little information, and
that highly confused. Whilst some maintain that the name of Œzbeg
was the name of one of their most renowned princes, who, in the
time of Djingis, ruled over the whole desert; others discover, in the
etymology of the word Œzbeg (independent prince, independent
head), the signification of that actual independence for which the
tribe was distinguished, as it disengaged itself from any ruler, and
attempted, on its own account, its march of conquest toward the
west. The name becomes prominent with the family of Sheibani, viz.,
with Ebul Kheir Khan, as founder, in the foreground; for, although
Taimur may belong to the same tribe, still the Turkish state is more
prominent than the Œzbeg.
If I am not deceived, it appears to me, at least, that the Œzbegs of
to-day form a tribe, which, as a colony, highly inconsiderable in
numbers, only increased after it had received into its bosom
contingents of the various nomadic tribes passing from the north to
the south. This assertion is, perhaps, bold, still the following
circumstances render it not impossible.
1st. The already indicated diversity which shows itself between the
Œzbegs of Turkestan from Komul to the Sea of Aral, whereby the
degree of resemblance which exists between the latter and those
nomadic tribes living in the vicinity is not to be mistaken, who,
induced by certain circumstances, in which riches and religion play
an important part, settled in towns, and are amalgamated with
Œzbegs.
2nd. Many names of branches and families of the Œzbegs are
common amongst the rest of the tribes of Central Asia. Thus, for
example, we find the tribes Kungrat, Kiptchak, Naiman, Taz,
Kandjigale, Kanli, Djelair, by which the thirty-two chief divisions of
the Œzbegs are named, figuring also among the Kirghis. The
Turkomans and Karakalpaks can produce some, which, from the
great importance the nomadic tribes attach to family names,
certainly would not be the case if earlier mutual relations had not
existed. We know little of their origin, little in regard to the time of
their settlement. The opinion of Persian historians, that the Œzbeg
power rose upon the ruins of the Taimur dynasty is, indeed, correct,
but forms no guide to the Œzbegs themselves. The name only is
apparent; but who can tell us to which tribe that Turkish population
professed to belong, which at a period long anterior to Taimur, and
before Djingis, in the time of the Kharezmian princes, Sahi
Charezmian, and even further back in the thirteenth century, were
established in the three Khanats? In Khiva I often heard of the
brilliant period of ancient Ürgendj, namely, before the inroad of the
Mongolians, described as Œzbeg. Was this merely national vanity, or
had the Turks at that time at Khiva really called themselves Œzbegs?
Turks were already settled during the Arabian occupation, as may be
seen in the ancient history of Bokhara, although not directly in the
centre, certainly in the neighbourhood of the old Persian towns, in
the time of the Samanides; and it would be highly interesting to
know to which type they really belonged. In the customs of the
Œzbegs, also, much foreign admixture has been introduced chiefly
through Islam, and the restless manner of existence pursued by
them; but not nearly so much as with the Western Turks, who
through the foreign elements that they receive are already quite
denationalized. The Œzbegs are pious—one might say zealous—
Musulmans. Nowhere in Islam, Kashmir excepted, does the tendency
to asceticism flourish more than here: a third of the inhabitants of a
town are Ishan, Khalfa, Sofi, or aspirants to those holy titles, and
nevertheless the doctrine of Mohammed has little limited their
customs in regard to all this. In Khiva, and in some parts of Chinese
Tartary, they have remained truest to nomadic customs. They build
houses, which are used as stables and granaries; but for dwelling-
places, they prefer always the raised tent in the court-yard;—
building durable dwellings is scoffed at by the pure Œzbeg, and
ridiculed as even now usual only with the Sart (Persian aborigines).
A general habit is marked out in the proverb: "Sart baïsa tam salar—
as soon as the Sart becomes rich, he builds a house," in
contradistinction to the Œzbeg, who procures rather a horse or
arms. Also in food and clothing but few refinements have crept in,
the chief towns excepted. Whilst in the towns the Harem life is in full
force, one finds in the country all Œzbeg women unveiled, for, to the
great anger of the Mollah, they resist that restriction, to which their
nature is averse. Ceremonies at burials, weddings, births, contain
much of what is not only foreign to Islam, but even criminal. This
false step is a striking contrast with the otherwise enthusiastic
feelings of Central Asiatics. Not less does the rigid adherence to a
warlike existence, in which the Œzbegs are distinguished from the
rest of the established nations of Central and Western Asia, deserve
our attention. Agriculture and durable dwellings render people more
peaceable; but this is not the case with the Œzbegs, because they
excel so many nomadic tribes in bravery.

Character.

However great the extent over which the diverse branches of Turkish
tribes may be found, however variously the influence of strange
elements may have acted upon their social relations, still the
features of a common type of character cannot be denied;—a picture
in which more traces of analogy are to be found than in the
physiognomy and other physical signs respectively. The Turk is
everywhere heavy and lethargic in his mental and corporeal
emotions, therefore firm and stedfast in his resolves; not, perhaps,
from any principle of life philosophy, but from apathy, and sincere
aversion to everything which would alter his adopted position. This
lends him an earnest and solemn aspect, which is so often extolled
by European travellers. As upon the shores of the Bosphorus the
Osmanli, in his keïf, can gaze for hours on the clear sky, while he
only makes as much movement as will blow the blue wreaths of
smoke from his pipe towards the yet bluer firmament; so the Œzbeg
or the Kirghis can sit for hours, motionless, in the narrow tent, or in
the immeasurably wide desert; for, while the former turns his gaze
upon the colours of the felt coverlet or carpet, already seen
thousands of times,—the latter looks on the waving, curling
quicksands, which are to amuse him. As those who go about briskly
and nimbly, or even gesticulate, are only compassionated by the
Osmanlis as living proofs of partial insanity and misfortune; so each
quick movement of the feet and hands is considered by the Œzbegs
as highly unseemly. Indeed, when I called out to one of my Tartar
fellow-travellers to save himself from some falling bales of goods by
a side-spring, he exclaimed, indignantly: "Am I, then, a woman, that
I should disgrace myself by springing and dancing!" With this
profound seriousness and marble-cold expression of countenance,
we find everywhere among the Turks a great inclination to pomp and
magnificence; but this does not degenerate into frivolity or
fanfaronades, as is the case with the Persians. In Constantinople one
often hears the proverb: "Intellect is peculiar to Europe, riches to
India, and splendour to the Ottoman." The solemn processions
(alay) of the sultan and of the great nobles are alike celebrated in
the East and the West, and the imposing exterior which is exhibited
on such occasions is nowhere to be found so faithfully reflected as
among their fellow tribes in Central Asia. An Œzbeg or Turkoman,
when upon his horse, or seated in his tent at the head of his family,
has the same proud bearing, the same self-consciousness of
greatness and power. He is quite convinced that he is born to rule,
and the foreign nations which surround him to obey,—just in the
same way as the Osmanli thinks with regard to Bulgarians,
Armenians, Kurds, and Arabians. His love for independence is
boundless, and is also the chief cause why he cannot long remain
under the chieftain whom he loves in many respects; and he would
rather command ten or twelve miserable highwaymen or
adventurers than stand at the head of a well-equipped, elegant
troop, who might, in common with himself, own a greater master.
Coinciding with these traits of character, is also the predilection of
the Turks for repose and inactivity; for, although diligence and
activity, according to our European notions, are not to be met with
anywhere in Asia, still, work is not so much abhorred, either by the
Iranian or Semitic nations, as by the Turks, who consider hunting
and war alone worthy of man. Upon them husbandry is only forcibly
imposed, and is considered ignominious. A wondrous prosperity has
never befallen Turkey. The peasant was always idle and careless; the
number of craftsmen limited. Officials had only wealth when the
Janitchars came back from their pillaging excursions, laden with
treasures.
In Central Asia, agriculture is exclusively in the hands of the Persian
slaves; commerce and business with the Tadjiks, Hindoos, and Jews;
for even the Œzbegs, settled there for centuries, meditate robbery
and war, and if they can procure no foreign enemy they attack each
other mutually in bloody brother strife.
As concerns intellectual capacity, I have found that the Turk is
everywhere far inferior to other Asiatic nations, namely, the Iranian
and Semitic; and that, through narrowness of mind, he loses those
prerogatives which his superiority in other respects would acquire for
him. This weakness is denoted by the word Türklük (Turkdom), of
which Kabalik (coarseness), and Yogunluk (thickness), are
synonyms. By Türklük, one understands also rudeness and
roughness in manners; and if here and there this defect is palliated
by the appellation, Sadelik (simplicity), still, for the most part, they
are subjoined to the Turkish name as insulting epithets. As the
Osmanli is over-reached by the Armenian, Greek, and Arab; so is the
Œzbeg baffled by the subtle and yielding Tadjik, and the no less
crafty and avaricious Hindoo. Whether this is to be ascribed to a
national defect or to an extreme nonchalance, it were hard to
determine; still, it is highly remarkable that the Turk in the far east,
as well as in the immediate vicinity of the civilised western country,
shuns meditation, and that nowhere are his attempts at wit
particularly brilliant. This disadvantage is partially the reason that
among the Turks more honesty, frankness and confidence, is to be
met with than among the remaining nations of Asia.
Türklük, by which strangers understand the above-named fault, is
often used by the Turks themselves as a mark of plainness,
simplicity, and uprightness. The lights and shades of Türklük have
been at all times observable and discoursed on, whenever parallels
are drawn between the character of the Turks and of other nations,
especially the Persians. People praise the acuteness, the refined
manners of the latter; but still, he who wants to find a faithful
servant, an attached soldier, or an upright man, will always give the
preference to the Turks. Therefore, we find in earliest times that
foreign princes liked to use Turkish troops; they call them into their
country, and invest their officers with the highest dignities; and as
bravery, perseverance, and love of governing, is more innate in them
than in any other Asiatic people, it is very easy to explain how they
rise from simple mercenaries to governors; and how they subjugated
Iranian and Semitic peoples, from their home up to the Adriatic,
many of whom are still ruled by them. In my opinion, it is not only
superiority of physical powers which has sustained the Turkish
dynasties upon foreign thrones, and still does so: this is also greatly
ascribable to their superiority of character. They are unpolished, and
by nature wild, uncultivated, but seldom cruel out of malice. They
enrich themselves at the cost of their subjects, but again divide
generously the collected treasures. They are severe towards their
subordinates, but seldom forget the duties that they have to fulfil
towards the latter, as patriarchal heads. In a word, in all deeds and
works of the Turks a sort of kindness is perceptible, which is,
perhaps, more to be ascribed to indolence and laisser-aller, than to a
fixed purpose to do good; but still it works as a virtue, whatever may
be its origin.
Finally will we mention hospitality, in which the Turks are better
versed than the Iranian and Semitic nations, and certainly for very
simple causes. As acknowledged, hospitality is observed in
proportion to the degree in which a nation advances from a nomadic
condition to a settled manner of living, and as Asia is generally far
more prominent in this virtue than Europe, so are the Turks, the
majority of whom are incarnate nomads, to be distinguished from
Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.

More than just a book-buying platform, we strive to be a bridge


connecting you with timeless cultural and intellectual values. With an
elegant, user-friendly interface and a smart search system, you can
quickly find the books that best suit your interests. Additionally,
our special promotions and home delivery services help you save time
and fully enjoy the joy of reading.

Join us on a journey of knowledge exploration, passion nurturing, and


personal growth every day!

ebookbell.com

You might also like