Skip to content

Commit

Permalink
tuned algorithm and renamed langlang to london
Browse files Browse the repository at this point in the history
  • Loading branch information
wilson428 committed Mar 1, 2018
1 parent 1b30977 commit 552b877
Show file tree
Hide file tree
Showing 35 changed files with 1,738 additions and 1,365 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,4 +1,5 @@
.DS_Store
demo

# Node
logs
Expand Down
2 changes: 1 addition & 1 deletion Compare.py
Expand Up @@ -3,7 +3,7 @@
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches

filenames = ["columbia", "philadelphia", "royal", "slovak", "langlang"]
filenames = ["columbia", "philadelphia", "royal", "slovak", "london"]

data = {}
for filename in filenames:
Expand Down
15 changes: 9 additions & 6 deletions Generate_Frequencies.py
Expand Up @@ -53,23 +53,26 @@
# first, identify all the outliers and move them closer to the correct position
corrected = [pitches[0]]
for i in range(1, len(pitches)-1):
diff = abs(pitches[i]-corrected[i-1])
if diff > 150:
diff = abs(pitches[i]-corrected[i-1]) / corrected[i-1]
if diff > 0.4:
corrected += [corrected[i-1]]
elif diff > 100:
#print(1, i, pitches[i], corrected[i-1], diff, average)
elif diff > 0.25:
average = (corrected[i-1] + pitches[i+1]) / 2
#print(1, i, pitches[i], corrected[i-1], diff, average)
corrected += [average]
else:
corrected += [pitches[i]]

# then iterate over the corrected array, gradually bringing the outliers into line
for x in range(2,20):
arr = corrected
for i in range(1, len(arr)-1):
diff = abs(arr[i] - arr[i+1])
threshold =100 - 5 * x
diff = abs(arr[i] - arr[i+1]) / arr[i+1]
threshold = 1 - 0.06 * x
if diff > threshold:
average = (arr[i-1] + arr[i+1]) / 2
#print(x, i, threshold, arr[i], corrected[i-1], diff, average)
corrected[i] = average

fig = plt.figure(figsize=(12, 9), frameon=True)
Expand Down
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -17,7 +17,7 @@ You'll need Node and Python 3, which you can download directly or install via Ho
+ [Philadelphia Orchestra](https://www.youtube.com/watch?v=xWB5m3ycYg0)
+ [Royal Philharmonic Orchestra](https://www.youtube.com/watch?v=hpynmrUI4oI)
+ [Slovak National Philharmonic Orchestra](https://www.youtube.com/watch?v=ynEOo28lsbc)
+ [Lang Lang](https://www.youtube.com/watch?v=ss2GFGMu198)
+ [London Symphony Orchestra](https://www.youtube.com/watch?v=ss2GFGMu198)

## Getting the clips

Expand All @@ -27,7 +27,7 @@ The [`get_audio.js`](get_audio.js) script downloads the YouTube url, extracts ju
+ `node get_audio.js --name=philadelphia --url=https://www.youtube.com/watch?v=xWB5m3ycYg0 --start=3 --end=9`
+ `node get_audio.js --name=royal --url=https://www.youtube.com/watch?v=hpynmrUI4oI --start=3 --end=8`
+ `node get_audio.js --name=slovak --url=https://www.youtube.com/watch?v=ynEOo28lsbc --start=5 --end=8`
+ `node get_audio.js --name=langlang --url=https://www.youtube.com/watch?v=ss2GFGMu198 --start=6 --end=12`
+ `node get_audio.js --name=london --url=https://www.youtube.com/watch?v=ss2GFGMu198 --start=6 --end=12`

(I cleaned up each sample in Audacity to make sure it starts right at the beginning of the glissando and ends right before the rest of the orchestra joins in)

Expand Down Expand Up @@ -75,7 +75,7 @@ Here are the command-line scripts for all five samples. (Again, depending on you
+ `python Generate_Frequencies.py --name=philadelphia --title="Philadelphia Orchestra"`
+ `python Generate_Frequencies.py --name=royal --title="Royal Philharmonic Orchestra"`
+ `python Generate_Frequencies.py --name=slovak --title="Slovak National Philharmonic Orchestra"`
+ `python Generate_Frequencies.py --name=langlang --title="Lang Lang"`
+ `python Generate_Frequencies.py --name=london --title="London Symphony Orchestra"`

Let's compare them and see how they stack up!

Expand Down

0 comments on commit 552b877

Please sign in to comment.