Music Chords with Mathematics

Finding Consonance

How can we distinguish euphony and cacophony? The quality of sound is determined by frequency, one of the main characteristics regarding a singular tone. A chord containing several tones can be harmonious and discordant depending on its frequency set. Tuning and temperament produce the desired pitch regarding a given pitch and modify that tuning to lessen dissonance.

There is a simple and easy way to determine whether two tones are compatible. Consonance happens when there is little interference engendered by pulsations of sound waves. And it occurs only when the ratio between the frequencies of the two tones, so-called distance, is numerically simple. A distance between two pitches can be mathematically described as the ratio between the frequency of the first pitch and the second frequency.

2
3

Let's delve into an example of two pitches, 260 Hz and 390 Hz above. We can calculate the distance as 2:3, the consonant interval named the fifth (from C to G). The same process can reduce various frequency ratios. You can drag and modify each frequency value and check out the simplest integer ratio of two pitches. Clicking the fraction lets you hear a custom-made chord of two pitches.

Musical Temperament (12 tones / 1 octave)

Temperament is especially crucial for keyboard instruments, which allow players to play only the pitches assigned to the various keys. Thereby, altering a single note's pitch can spoil the whole performance. Different musical temperament methods like just intonation and meantone temperament have been developed to play reasonably well in all of the keys. We'll identify how those methods create 12 tones in 1 octave (12-TET) and whether their melodies are plausible.

From articles in Wikipedia,

  • Pythagorean tuning is a system of musical tuning in which the frequency ratios of all intervals are based on the ratio 3:2.
  • Just intonation or pure intonation is the tuning of musical intervals as whole number ratios (such as 3:2 or 4:3) of frequencies.
  • Equal temperament divides the octave into 12 parts, all of which are equal on a logarithmic scale, with a ratio equal to the 12th root of 2.

Don't hesitate to click on each entry of the table below and check out how it sounds. Listen to random music composed on each temperament. Our aural sense would find that the most familiar is the equal temperament, now commonly used in piano tuning.

260 Hz P1 m2 M2 m3 M3 P4 TT P5 m6 M6 m7 M7 P8
Pythagorean Tuning
30
20
28
35
32
23
25
33
34
26
22
31
36
29
31
21
27
34
33
24
24
32
35
27
21
30
Just Intonation
1
1
12
11
9
8
6
5
5
4
4
3
7
5
3
2
8
5
5
3
7
4
11
6
2
1
Equal Temperament 20⁄12 21⁄12 22⁄12 23⁄12 24⁄12 25⁄12 26⁄12 27⁄12 28⁄12 29⁄12 210⁄12 211⁄12 212⁄12

Nim Game against Computer

From an article in Wikipedia,

In another game which is commonly known as Nim (but is better called the subtraction game), an upper bound is imposed on the number of objects that can be removed in a turn. Instead of removing arbitrarily many objects, a player can only remove 1 or 2 or … or k at a time. The player taking the last object wins.

How to Play

In this game, we’ll slightly change the rule to get a certain number of stones. Now you can only grab as many stones as the number written inside colored circles.

  1. Drag and highlight the stones that you would like to remove.
  2. Click the Take button.
  3. Win the game against the computer.

Dame Dane

From an article in Kapwing Resources,

Deepfakes are finding their way into meme culture more than ever before and one clip is leading the charge. The “Dame Dane” meme features a Japanese song from the popular video game series Yakuza.

I will apply First Order Modeling method, which allows creating deep fakes in a few minutes.

First Order Motion Model for Image Animation in NeurIPS 2019

For further information, please refer to the video below and visit the website of the paper.

The Water Jug Riddle

The Water Jug Riddle


Detective John McClane must measure out exactly 4 gallons of water and place the resulting weight on a scale to disable a bomb. His tools are yours: a 3-gallon and a 5-gallon jug—and a single fountain. McClane did it in less than 5 minutes. Can you also do it in time and provide a generalized solution for arbitrary gallons of both jugs?

Jug 1

Jug 2

gal  

5

gal  

3

Every step can be visualized as billiard moves in the coordinate system on a triangular lattice. The above hexagonal plot gives two solutions to the 5-gallon and 3-gallon puzzle. Each point on the boundary denotes combinations achievable with the jugs. Starting at two vertices (5, 0) and (0, 3), traces of the blue points show pourable transitions. We have measured 4 gallons in 6 and 7 steps concerning the starting points. Might it be possible to get a prime gallon of water from coprime gallon jugs (e.g., to yield 7 gallons from a 9-gallon jug and 15-gallon jug)?

Music player de lucetre

Skulpt to use Python in Markdown

This is an example article showing how to embed Skulpt and Ace code editor to use Python.

  • Skulpt is an entirely in-browser implementation of Python.
  • Tutorial w. simple Python turtle code used while doing TA works.

Try This

import turtle as t print("Drawing Ryan...") t.shape("turtle") t.speed(7) t.fillcolor("#f7aa1b") t.pencolor("#111111") t.pensize(10) print("Left Ear...") t.penup() t.goto(-120, 120) t.pendown() t.begin_fill() t.circle(50) t.end_fill() t.penup() t.goto(120, 120) print("Right Ear...") t.pendown() t.begin_fill() t.circle(50) t.end_fill() t.penup() t.goto(0, -200) print("Face...") t.pendown() t.begin_fill() t.circle(200) t.end_fill() t.penup() t.pensize(15) t.goto(-120, 60) print("Left Eyebrow...") t.pendown() t.goto(-50, 60) t.penup() t.goto(120, 60) t.pendown() print("Right Eyebrow...") t.goto(50, 60) t.penup() t.goto(-80, 15) print("Left Eye...") t.pendown() t.fillcolor("#111111") t.begin_fill() t.circle(6) t.end_fill() t.penup() t.goto(80, 15) print("Right Eye...") t.pendown() t.fillcolor("#111111") t.begin_fill() t.circle(6) t.end_fill() t.penup() t.goto(-7, -25) print("Mouth...") t.pendown() t.fillcolor("#ffffff") t.begin_fill() t.left(135) t.circle(32, 290) t.right(130) t.circle(32, 290) t.end_fill() t.penup() t.home() t.goto(0, -30) print("Nose...") t.pendown() t.begin_fill() t.circle(8) t.end_fill() print("Done!") t.hideturtle()

Run (Ctrl+Enter)