Transcultural Machine Learning in Music

Most music models store pitch as one of 12 piano keys. A Thai scale, described as 7 equal steps, lands between those keys. The model moves 6 of its 7 notes, two of them by 43 cents.

Switch between the scale as played and the scale snapped to 12 keys, then press Play and listen. Then we build, piece by piece, the ruler for pitch and what a grid loses. Then the model that keeps it, and the choices about data, audience and release.

You need a little Python and what a probability is. No music theory. We build the rest from zero.

Based on Stepping Towards Transcultural Machine Learning in Music by Lamtharn (Hanoi) Hantrakul, Magenta, January 2021. The tuning, rhythm and dataset facts come from the sources named in each chapter.

Snap a seven-step scale to the piano

The scale is the textbook model of Thai tuning, 7 equal steps of 171.4 cents each (Morton 1976). Measured instruments vary from it (Garzoli 2015), so treat these exact offsets as illustrative. The 12 keys are equal temperament.

Chapter 0

A Tool Carries Its Makers' Borders

Run three melodies through a 12-key encoder and measure what each one loses

You hand a music model a recording of a Thai melody. It returns a clean transcription. Every note sits on a piano key. The transcription is wrong, and nothing in the output tells you so.

Lamtharn (Hanoi) Hantrakul names the cause in one line: "new technologies are often applied within the cultural boundaries of their inventors." He came to machine learning through wood. He apprenticed with luthiers in Thailand. Later he designed Fidular, a modular fiddle built from resonators and strings of Asia-Pacific and Middle Eastern fiddles. A tool built inside one tradition assumes that tradition, and the assumption is invisible to its makers.

Here is the assumption at its smallest. A 12-key encoder is a step that turns a pitch into the nearest piano key. Feed it three melodies. Count how often the encoder is within 10 cents of what was sung. A cent is one hundredth of a piano key's step; Chapter 1 builds it properly.

Run a melody through a 12-key encoder

Teal is the pitch as sung. Warm is what the encoder stores. Red marks every moment more than 10 cents off. Pick a melody.

All three melodies are toys made for this page. The seven-step scale is the idealized model of Thai tuning; the sliding phrase is an invented glide, not a transcription of a real performance.

The worked number for the scale: its 8 notes (one octave, up) move by 0, 28.6, 42.9, 14.3, 14.3, 42.9, 28.6 and 0 cents. The mean is 171.4 / 8 = 21.4 cents. Only 2 of 8 notes, the first and the last, stay within 10 cents. The piano tune scores 8 of 8. Same encoder, same code, a different culture.

The failure. Symptom: a model that reports high accuracy on its test set and sounds wrong to players of another tradition. Measurement: snap that tradition's pitch to the model's grid and report the share of time within 10 cents. Fix: change the representation, which is the subject of this lesson.

The road

  1. Cents: one ruler that measures any tuning.
  2. Two ways to cut an octave: 12 equal steps and 7, and the snap error between them.
  3. Pitch as a curve: what a grid does to a sliding ornament.
  4. Pitch histograms: what a 12-bin feature folds away.
  5. Rhythm cycles: tala cycles of 7, 8 and 16 beats against a 4-beat bar.
  6. DDSP: a model that takes continuous pitch and learns from 15 minutes.
  7. Sounds of India: commissioned data, a local audience, a phone-sized model.
  8. Two kinds of bias: the model's choices and the data's mix.
  9. The Guqin: a working model the team chose not to release.
  10. The field guide: numbers, checklist, code and links.
A 12-key encoder scores 8 of 8 notes on a piano tune and 2 of 8 on a seven-step scale. What does that show?

Chapter 1

Cents: One Ruler for Every Tuning

Turn any two frequencies into one distance that does not care which tradition you measure

Play A at 440 Hz. Play the A one octave up: 880 Hz. Now go up another octave: 1,760 Hz. Each octave sounds like the same step, but the gap in hertz doubles every time. The ear hears ratios, not differences. So a fair ruler for pitch must measure ratios.

The ruler music research uses is the cent. One octave is 1,200 cents. A piano key's step is 100 cents. Because it measures a ratio, it works for any tuning, piano or not.

How far apart are two pitches? Call the lower frequency f1 and the higher one f2, both in hertz. Call the distance between them in cents c.

Say it aloud

c equals twelve hundred times log base two of f-two over f-one.

c
c the distance between the two pitches, in cents.
1200
twelve hundred the number of cents in one octave, by definition.
log2
log base two counts how many doublings a ratio holds. A ratio of 2 is 1 doubling; a ratio of 1 is 0.
f2
f-two the higher frequency, in hertz.
f1
f-one the lower frequency, in hertz.
In plain words

Divide f-two by f-one. Ask how many octaves that ratio is: that is the log base two. Multiply by 1,200 to get c in cents.

With numbers

f-one is 440 Hz and f-two is 466.16 Hz, the next piano key up. The ratio is 1.0595, which is 1/12 of an octave, so c = 1200 × 0.0833 = 100.0 cents. Now try f-two = 660 Hz: the ratio is 1.5 and c = 702.0 cents, 2 cents above the key 700.

Measure a pitch in cents

The lower note stays at 440 Hz. Drag the upper note and read where it lands on the octave. Warm ticks are the 12 keys.

485.80 Hz

The arithmetic is exact. 485.80 Hz is one step of the idealized seven-step scale above 440 Hz (440 × 2 to the 1/7).

The second chip lands at 171.4 cents. No key sits there: the nearest keys are 100 and 200. That gap is the topic of Chapter 2.

The failure. Symptom: two tunings compared in hertz look closer at low notes than at high notes. Measurement: convert both to cents against the same reference. Fix: store pitch in cents (or in log frequency) from the start, never in raw hertz differences.

Why do music researchers measure pitch distance in cents and not in hertz?

Chapter 2

Two Ways to Cut an Octave

Build a scale of N equal steps and measure how far each note moves when you snap it to the piano

Every tradition picks a set of pitches inside the octave. Western music uses 12 equal steps. The essay puts the contrast plainly: "In Thai classical music, the same octave is divided into seven pitches."

How equal are the seven? The textbook account (Morton, 1976) describes 7 roughly equal steps. Garzoli (2015) measured instruments and argues they are not equidistant. So we use the 7-equal model as a toy. Either way, the seven are not a subset of the twelve.

What frequency is step k of a scale with N equal steps? Call the starting pitch f0, the step number k and the number of steps per octave N. Call the result fk.

Say it aloud

f-k equals f-zero times two to the power k over N.

fk
f-k the frequency of step k, in hertz.
f0
f-zero the starting pitch of the scale, in hertz. Here 261.63 Hz, middle C.
2k/N
two to the k over N k steps of size one N-th of an octave. With k = N it is 2: one full octave.
In plain words

Each step multiplies the frequency by the same ratio, the N-th root of 2. Do it k times starting from f-zero. In cents, each step is 1,200 / N: 100 cents for N = 12, 171.4 cents for N = 7.

With numbers

f-zero is 261.63 Hz and N is 7. Step k = 1 is 261.63 × 1.1041 = 288.86 Hz. Step k = 3 is 352.13 Hz. The piano's F (k = 5 of 12) is 349.23 Hz, so the two notes differ by 14.3 cents.

Now snap. Write a note's height above the start in cents as c. The 12-key encoder replaces c by the nearest multiple of 100. Call the amount it moves the note the snap error, e.

Say it aloud

e equals c minus one hundred times round of c over one hundred.

e
e the snap error: how far the encoder moves the note, in cents. It lies between minus 50 and plus 50.
c
c the note's true height above the start, in cents.
100
one hundred the size of one piano step, in cents.
round
round the nearest whole number: which key is closest.
c / 100
c over one hundred the note's height counted in piano steps, with a fraction.
In plain words

Count c in piano steps. Round to the nearest key. Multiply back by 100 to get the key's height. The snap error e is the true height c minus that key's height.

With numbers

Step 2 of the seven-step scale has c = 342.9. c / 100 = 3.429, which rounds to 3, so the key is 300 and e = +42.9 cents. Across the 6 steps between the octaves the errors are −28.6, +42.9, +14.3, −14.3, −42.9 and +28.6: a mean size of 28.6 cents.

Turn the octave ring

The ring is one octave. Warm ticks are the 12 keys. Teal dots are the scale you pick. Turn on the snap to see each dot pulled to a key.

Equal-step scales here are idealized models. The 5-step option shows another equal division for contrast; it is not a model of any one tradition.

The failure. Symptom: a piano-roll melody model plays a Thai tune back with sour notes. Measurement: compute e for each scale step. Fix: store pitch in cents relative to the tonic, so the tuning is data, not code.

A note sits 857.1 cents above the start. What is its snap error on the 12-key grid?

Chapter 3

Pitch Is a Curve, Not a Staircase

Draw a sliding ornament and measure what a note-by-note model throws away

A Carnatic singer moves from one note to the next. The voice does not jump. It slides up, swings around the target and settles. The essay calls these slides meend, "melodic twists and turns". In Carnatic music the wider family of ornaments is called gamaka, and many gamakas are slides and oscillations between notes. To the singer they are part of the note, not decoration on top of it.

A note-by-note model stores "this key, then that key". To it a slide is noise. Draw one and watch.

Draw a slide, then quantize it

Drag across the screen to draw a pitch curve from left to right. Purple is your curve. Turn on Quantize to see the staircase a key-based model stores.

The starting phrase is an invented slide with one swing, not a transcription of a real gamaka. Play sounds your curve, or its staircase when Quantize is on.

One number sums up the damage. Track pitch at T moments, called frames (a pitch tracker often uses 100 frames per second). At frame t the snap error is et, as in Chapter 2. Call the mean size of the error Ē.

Say it aloud

E-bar equals one over T, times the sum over t of the absolute value of e-t.

Ē
E-bar the mean snap error over the phrase, in cents.
T
T the number of frames in the phrase.
Σt
the sum over t add one term for each frame, from the first to frame T.
|et|
the absolute value of e-t the snap error at frame t with its sign dropped, so up and down errors both count.
In plain words

At every frame, find how far the staircase is from the curve, e-t, and drop the sign. Add these over all T frames. Divide by T. That is E-bar.

With numbers

A straight slide from 0 to 200 cents over T = 200 frames rises 1 cent per frame. The errors climb from 0 to 50 and fall back, twice. Their mean is E-bar = 25 cents, and only 20% of frames sit within 10 cents of a key.

The fix is in the representation. Store pitch as a continuous curve, one value in cents per frame. Tone Transfer does this. Its showcase, in the essay's words: it can "re-render a Western concert flute" to follow the meend of a Carnatic singer. The flute has no such tradition, but the model follows the curve the singer produced. Chapter 6 shows the model.

The failure. Symptom: a transcription of a Carnatic phrase shows extra short notes, or a flat line where the singer swung. Measurement: E-bar and the share of frames within 10 cents. Fix: keep a frame-level pitch curve and treat note labels as a later, optional view.

What changes when a model stores pitch as a curve in cents per frame, instead of a key per note?

Chapter 4

Pitch Histograms: What Twelve Bins Fold Away

Count where a melody spends its time, then change the bin width and watch the scale appear or vanish

Give a classifier a whole recording and ask "which scale is this?". It cannot read every frame. So engineers summarize: count how much time the pitch spends at each height. That count is a pitch histogram. Folding all octaves into one gives a pitch-class histogram.

The most common version has 12 bins, one per piano key. It is called a chroma feature. It is a good summary for piano-based music. For other music it bakes in the grid at the first step, before any learning starts.

Which bin does a pitch fall in? Call the pitch's height above the tonic c cents, the bin width w cents, and the number of bins per octave M = 1,200 / w. Call the bin number b.

Say it aloud

b equals round of c over w, mod M.

b
b the bin the pitch is counted in, from 0 to M minus 1.
round
round the nearest whole number, so each bin is centred on its point.
c
c the pitch's height above the tonic, in cents. It can be more than one octave.
w
w the bin width in cents: 100 for chroma, 10 for a fine histogram.
mod
mod the remainder after division, which folds every octave onto one.
M
M the number of bins in an octave, 1,200 / w.
In plain words

Count c in units of w and round to the nearest bin. Take the remainder after dividing by M, so the same note in any octave lands in the same bin b. Add one frame's time to bin b.

With numbers

A seven-step note at c = 342.9 and a piano note at c = 300. With w = 100 (M = 12) both land in bin 3: the histogram cannot tell them apart. With w = 10 (M = 120) they land in bins 34 and 30. A note at c = 1,250 with w = 10 goes to round(125) mod 120 = bin 5.

Change the bin width

Bars show where a seven-step melody with slides spends its time, folded into one octave. Warm ticks are the 12 keys, teal ticks the 7 steps. Pick a bin width.

The page generates the melody: the idealized seven steps held with a little wobble, plus slides between them. Real pitch histograms of Thai or Carnatic recordings have different shapes.

At 100 cents the seven steps blur into piano bins. At 10 cents seven clear peaks stand at 171.4-cent spacing. Research on Indian art music uses fine histograms of this kind, built on the tonic, for tasks like raga recognition.

The failure. Symptom: a scale classifier confuses two ragas or two tunings that a musician tells apart at once. Measurement: plot the fine histogram of both and check whether their peaks share a 100-cent bin. Fix: use 10 to 20 cent bins relative to the tonic, not chroma.

Why can a 12-bin chroma feature not tell a note at 342.9 cents from one at 300 cents?

Chapter 5

Rhythm Cycles: When the Bar Is the Wrong Size

Lay a 4-beat bar over tala cycles of 8, 7 and 16 beats and count how long until they line up again

Pitch is one grid. Time is another. Much Western popular music counts in bars of 4 beats, and many beat trackers learn that from their data. Indian art music organizes time in a tala: a cycle of beats with its own grouping, repeated through a piece. The first beat of the cycle (sam in Hindustani music) is where phrases land.

CycleTraditionBeatsGrouping
Adi talaCarnatic84 + 2 + 2
Misra chapuCarnatic73 + 2 + 2
TeentaalHindustani164 + 4 + 4 + 4

When does a cycle's first beat fall on a bar's first beat again? Call the cycle length L beats and the bar length B beats. Call the number of cycles until they line up again R.

Say it aloud

R equals the least common multiple of L and B, over L.

R
R how many cycles pass before the cycle's first beat lands on a bar's first beat again.
lcm
the least common multiple the smallest count of beats that both lengths divide evenly.
L
L the length of the tala cycle, in beats.
B
B the length of the bar the model assumes, in beats. Here 4.
/ L
over L turns that count of beats into a count of cycles.
In plain words

Find the first beat count that is a whole number of cycles and a whole number of bars. That is the least common multiple of L and B. Divide by L to get R, the cycles you wait.

With numbers

Adi tala: L = 8, B = 4, lcm = 8, so R = 1. Every cycle starts on a bar line. Misra chapu: L = 7, lcm(7, 4) = 28, so R = 4. A 4-beat model puts the cycle's first beat on a bar line only once every 4 cycles.

Lay a 4-beat bar over a tala

Teal dots are the cycle's beats; the big one is the first beat. Warm rings mark where the 4-beat model puts a bar line. Press Play and watch the bar line drift.

The beat counts and groupings are the standard ones. Real performances also change tempo and subdivide beats, which this toy leaves out. Play sounds a click per beat, accented on the first beat and on each group start.

The failure. Symptom: a downbeat tracker marks "bar 1" in the middle of a Misra chapu group, and the error repeats with period 4 cycles. Measurement: compare predicted bar lines with annotated cycle starts. Fix: make the cycle length a label the model can learn, using data annotated with tala, such as the Saraga collections (Chapter 8).

A model assumes bars of 4 beats. How many Teentaal cycles (16 beats) pass before the first beat lines up with a bar line again?

Chapter 6

DDSP: Continuous Pitch In, Sound Out

See why a model with a synthesizer inside can learn an instrument from 15 minutes of audio

Two walls stand in front of transcultural work. The representation must hold curves, which Chapters 2 to 5 showed. And the data is small: there are far fewer clean recordings of a Sarangi than of a pop guitar. A model that needs thousands of hours cannot serve a tradition that has a few.

DDSP (Differentiable Digital Signal Processing, Engel et al., 2020) answers both. Its input is a pitch curve and a loudness curve, frame by frame, with no key grid. A small network turns them into settings for a classic synthesizer. The synthesizer already knows what a periodic sound is, so the network learns only how one instrument colours it. The essay: "With as little as 15 minutes of data, you too can train your own model of lesser-known instruments." The DDSP paper's violin model used about 13 minutes of solo violin.

What does the synthesizer compute? Call the pitch f0 in hertz and the loudness A. Call the share of energy in harmonic k ck; the network predicts these. Call the sample rate fs, the sample number n, the number of harmonics K, and the output sample x[n].

Say it aloud

x of n equals A times the sum over k from one to K of c-k times sine of two pi k f-zero n over f-s.

x[n]
x of n the audio sample number n that the synthesizer outputs.
A
A the loudness: the overall amplitude, from the loudness curve.
Σk=1..K
the sum over k from one to K add one sine wave for each harmonic.
ck
c-k how strong harmonic k is. The network predicts these numbers; they make a flute sound like a flute.
sin
sine the pure wave that each harmonic is.
k
k the harmonic number: harmonic k vibrates k times faster than the pitch.
f0
f-zero the pitch in hertz, taken straight from the pitch curve. It can take any value, not only keys.
n
n the sample number: 0, 1, 2 and so on.
fs
f-s the sample rate: samples per second.
In plain words

For each harmonic k, make a sine wave k times faster than f-zero. Weight it by c-k. Add the K waves and scale by A. Keep only harmonics below half of f-s, since the samples cannot hold higher ones.

With numbers

f-zero is 440 Hz and f-s is 16,000 samples per second, so half the sample rate is 8,000 Hz. 8,000 / 440 = 18.2, so K = 18 harmonics fit. At f-zero = 220 Hz, K = 36.

Drive the harmonic synthesizer

Each bar is one harmonic c-k. The pitch slider moves continuously, with no keys. Brightness sets how fast the bars fall. Press Play to hear it.

440.0 Hz
45

The harmonic weights here follow a simple falling rule set by Brightness. In DDSP a network predicts them frame by frame from audio, and a filtered-noise part adds breath and bow noise.

Small models bring a second gain. They run in a browser on the phone. The audio need not leave the device.

The failure. Symptom: a large audio model trained on web data produces a generic "Indian flute" for any input. Measurement: count the clean hours you have per instrument before you pick a model family. Fix: if you have minutes, pick a model with a strong built-in structure, such as DDSP, over a model that learns sound from scratch.

Why can a DDSP model learn an instrument from about 15 minutes of audio?

Chapter 7

Sounds of India: Data, Audience, Device

Follow one deployment through three choices and size its model for a phone

On India's 74th Independence Day, in August 2020, Google launched Sounds of India. You sang into a phone. The phone played your melody back as a Bansuri (bamboo flute), a Shehnai (double-reed pipe) or a Sarangi (bowed string instrument). The essay says the models reached "millions of mobile phones simultaneously." Three choices made it transcultural.

  1. Data. The team used "short, commissioned recordings from three instruments". Commissioned means the team asked players to record for this purpose, instead of scraping audio from the web.
  2. Audience. In the essay's words, the models "were aimed at local audiences familiar with their original sounds." The people who know a Bansuri best judged whether it sounded right.
  3. Launch. It went out on a national holiday with Prasar Bharati, India's public broadcaster. It came from inside the culture's own institutions.

The engineering had to fit a phone. The TensorFlow write-up (Ramesh, Zats, Yu and Hantrakul, 2020) says the models ran in the browser with TensorFlow.js. No microphone audio went to a server. Compression cut one model download from 10 MB to 300 KB.

How long does a download take? Call the model size S in bytes and the connection rate r in bits per second. Call the time t.

Say it aloud

t equals eight times S over r.

t
t the download time, in seconds.
8
eight bits per byte: sizes come in bytes, speeds in bits.
S
S the model's size, in bytes.
r
r the connection rate, in bits per second.
In plain words

Turn the size S into bits by multiplying by 8. Divide by the rate r. The result is the wait t before the model can run.

With numbers

With a made-up rate r of 1 megabit per second: S = 10 MB gives t = 8 × 10,000,000 / 1,000,000 = 80 seconds. S = 300 KB gives t = 2.4 seconds. The 33-fold cut turns a wait most people abandon into a pause.

Time the download on a slow phone

Blue bars are download times for the two model sizes. Drag the connection speed down to a weak mobile signal.

1.0 Mbit/s

The two sizes, 10 MB and 300 KB, are from the TensorFlow blog post on Sounds of India (August 2020). The connection speeds are illustrative.

The failure. Symptom: a tool for a tradition launches, and its own community finds it sounds wrong or cannot load it. Measurement: who set the quality bar, and how long the first load takes on a typical local phone. Fix: commission data from players, test with listeners who know the sound, and size the model for local devices.

Who were the Sounds of India instrument models aimed at, according to the essay?

Chapter 8

Two Kinds of Bias: The Model and the Data

Turn the representation and the data mix separately and see that either one can cap the result

The essay borrows a split from Jesse Engel of Magenta. Model bias is the set of choices a researcher makes that encode properties of the data: a 12-key grid, a 4-beat bar, a chroma feature. Dataset bias comes from how the data was collected and what it contains: a corpus that is mostly Western pop. These choices are essential to make a model work, and they "bake in limitations by definition."

So no model is neutral. The job is to choose the bias on purpose and say what it is. The essay points to model cards, short documents that state what a model was built for and what it was trained on.

Turn the two bias dials

Pick how the model stores pitch, then drag the share of training audio from the target tradition. The weaker bar sets the ceiling.

5%

An illustrative toy. "Can represent" is the share of frames within 10 cents of the grid, for the Chapter 0 scale and sliding phrase. "Ceiling equals the lower bar" is a teaching simplification, not a law.

The worked number: on the toy melodies, 33% of frames stay within 10 cents of a 12-key grid. A 24-step grid keeps 50%. A continuous curve keeps all. Raise the target data to 100% and the 12-key model still tops out at 33%. Switch to continuous with 5% data and the data caps it. You must fix both.

Some groups work on the data side. The CompMusic project (Music Technology Group, Universitat Pompeu Fabra, led by Xavier Serra) built research corpora for several non-Western traditions. Its successor Saraga (Srinivasamurthy et al., 2021) releases Carnatic and Hindustani recordings under Creative Commons licences, with time-aligned melody, rhythm and structure annotations.

The failure. Symptom: a team adds more Thai audio and accuracy on Thai melodies does not move. Measurement: test the representation alone, by snapping clean ground-truth pitch to the model's grid. Fix: if that already loses the music, change the model, not the data.

A 12-key model gets far more Thai training data, but still mistunes Thai melodies. Which bias is limiting it?

Chapter 9

The Guqin: Knowing When Not to Ship

Walk the release decision for a model that worked, and see why the team held it back

The guqin is a seven-string Chinese zither. UNESCO lists guqin music as Intangible Cultural Heritage and traces the instrument back more than 3,000 years. The team trained a DDSP model of it. Technically, the model worked.

Then Hantrakul played it for a Chinese colleague from a partner design team. In his words, "his facial reaction, a priceless mix of skepticism and aversion, made me reevaluate my position entirely." The worry: "non-Chinese listeners hearing the Guqin for the first time through our technology could form incorrect impressions" of the instrument and of Chinese classical music.

A model is a lossy copy. If it is many people's first guqin, its flaws become their picture of the art form. So the team decided not to open-source the Guqin models in Tone Transfer or in the DDSP Colab notebook. The essay's reason: "models are cultural distillations that should be treated with care and respect", like anthems, fabrics and symbols. Released without care, the same power could enable "a new form of AI-powered cultural appropriation."

Walk the release decision

Set the three choices the team faced. The meter shows the risk that a listener forms a wrong first impression of the tradition.

First listeners

Faithfulness, judged by players

Release

An illustrative toy, not a scoring method from the essay. It encodes the essay's argument: risk grows with first-time listeners, rough fidelity and wide release.

The worked case is the team's own. First-time listeners, a model its tradition's members found wrong, an open release: the meter sits at its top. They chose "keep in the lab". The same DDSP method shipped for the Bansuri, where the audience knew the sound and judged it.

The failure. Symptom: a released model becomes the default sound of a tradition for people outside it. Measurement: before release, play it to people from the tradition and record their verdict. Fix: if they object, add context, limit the release, or do not release.

Why did the team not open-source the Guqin models, though they worked?

Chapter 10

The Field Guide

Keep the numbers, the checklist and the code in one place

The essay's goal: "Transcultural technologies empower cultural pluralism at every phase of engineering and design." That means the representation, the data, the audience and the release, not a sound borrowed at the end.

TermMeaningNumber to remember
CentA ratio unit of pitch distance1,200 per octave; 100 per piano key
Seven-step scaleTextbook model of Thai tuning171.4-cent steps; snap errors up to 42.9 cents
Snap errorHow far a grid moves a noteBetween −50 and +50 cents on 12 keys
Meend, gamakaSlides and swings that are part of the noteA straight slide loses 25 cents on average
Chroma12-bin pitch-class histogramUse 10 to 20 cent bins for other tunings
TalaA repeating beat cycleAdi 8, Misra chapu 7, Teentaal 16
DDSPNetwork plus built-in synthesizerAbout 15 minutes of audio per instrument
Sounds of IndiaBansuri, Shehnai, Sarangi in the browserDownload cut from 10 MB to 300 KB
Model bias, dataset biasThe model's choices, the data's mixEither one caps the result

The checklist

  1. Representation. Snap clean pitch from the target tradition to your grid. Report the share within 10 cents.
  2. Features. Replace chroma with tonic-relative histograms of 10 to 20 cent bins.
  3. Time. Check that the cycle lengths of the tradition are labels, not a fixed 4-beat bar.
  4. Model family. Count clean hours per instrument. With minutes, use a model with built-in structure.
  5. Data. Commission recordings from players of the tradition, with their consent.
  6. Audience. Let listeners who know the sound set the quality bar.
  7. Release. Ask whether a first-time listener could form a wrong impression. If yes, add context or hold it back. Write it down in a model card.
pythonimport numpy as np
from math import lcm

def cents(f2, f1):                       # distance in cents, any tuning
    return 1200 * np.log2(f2 / f1)

def snap_error(c, step=100):              # c: array of cents above the tonic
    return c - step * np.round(c / step)

def pitch_class_hist(c, w=10):            # w=100 gives chroma
    M = 1200 // w
    b = np.round(c / w).astype(int) % M
    return np.bincount(b, minlength=M) / len(c)

def cycles_to_realign(L, B=4):           # tala of L beats vs bars of B
    return lcm(L, B) // L

seven = 1200 * np.arange(8) / 7              # idealized seven-step scale
e = snap_error(seven)                         # [0, -28.6, 42.9, 14.3, -14.3, -42.9, 28.6, 0]
print(np.abs(e).mean(), (np.abs(e) <= 10).mean())  # 21.4 cents, 0.25
print(cycles_to_realign(7))                   # 4 for Misra chapu

Keep going

Sources

The takeaway. A music model carries a culture in its grid, its features, its data and its release. Measure each in numbers you can show, such as cents of snap error or cycles to realign. Then choose on purpose, including the choice not to ship.

Now press Present or Teach and explain four things from memory. Why 7 equal steps do not fit 12 keys. What a slide loses on a grid. The two kinds of bias. Why the Guqin model stayed in the lab. Then go back to the hero and say which chapter fixes each moved note.

Transcultural Machine Learning in Music
Based on "Stepping Towards Transcultural Machine Learning in Music" by Lamtharn (Hanoi) Hantrakul (Magenta, 2021) · Back to Gleams