Unit 35: Review


unit 35

unit 34

unit 33

unit 32

unit 31

unit 30

unit 29

unit 28

unit 27

unit 26

unit 25

unit 24

unit 23

unit 22

unit 21

unit 20

unit 19
Some review stuff.
The AI is borrowed from the movie Ex Machina, where Ava is played by Alicia Vikander. Since Apple calls one of the voices Ava and Ava is a palindrome, I use Ava. She is also ``One", the first one. You see part of the interview here and also some math (primes) appearing in a programming part.
Here are the basic harmonies of the 1a song! I believe the harmonies are original but there are not many songs of that shortness possible and 90 percent of all pop songs are constructed from such simple harmonies. The numbers are the Midi numbers.
S=Sound; SN[{a_,t_}]:=SoundNote[a,t];T=4; 
d={1,5,8};g={1,6,10};a={0,3,8};h={-2,1,5};e={3,6,10};
A={{d,4},{d,4},{g,4},{d,4},{a,4},{d,4},{a,4},{a,4}}; 
B={{h,4},{h,4},{e,4},{a,4},{d,4},{g,4},{a,4},{a,4}}; 
U=S[{S[{"Piano",SN/@A},{0,T}],S[{"Viola",SN /@B},{T,2T}]}];
Export["1aharmonies.mp3",U,"MP3"];
Here is the MP3 file produced.
And here is Ava's first song. I (the human) cleaned out notation (if you compare with the slides). While having lost the contest, we humans still proud ourselves to write beautiful and poetic code. Machines just do not have good taste! (Yet ...)
rise[x_]:=Table[{x[[k,1]]+12,x[[k,2]]},{k,Length[x]}];
down[x_]:=Table[{x[[k,1]]-12,x[[k,2]]},{k,Length[x]}];
SN[{a_,t_}]:=SoundNote[a,t];T=6;
d0={1,5,8};g0={1,6,10};a0={0,3,8};h0={-2,1,5};e0={3,6,10};
a1={{{1},4},{{8},4},{{10},1},{{8},1},{{6},2},{{8},4},{{6},1},
    {{5},1},{{3},2},{{5},2},{{3},1},{{1},1},{{3},3},{{},1},{{3},4}};
b1={{{1},4},{{1},4},{{3},4},{{-4},4},{{1},2},{{0},1},{{-2},1},
    {{-2},2},{{-4},1},{{-6},1},{{-4},3},{{},1},{{-4},4}};
a2={{d0,4},{d0,4},{g0,4},{d0,4},{a0,4},{d0,4},{a0,4},{a0,4}};
b2={{h0,4},{h0,4},{e0,4},{a0,4},{d0,4},{g0,4},{a0,4},{a0,4}};
s1=Sound[{"Flute", SN/@rise[a1]},{0T,1T}]; s2=Sound[{"Guitar",SN /@down[a2]},{0T,1T}];
s3=Sound[{"Viola", SN/@rise[a1]},{1T,2T}]; s4=Sound[{"Harp",  SN /@down[a2]},{1T,2T}];
s5=Sound[{"Violin",SN/@rise[b1]},{2T,3T}]; s6=Sound[{"Piano", SN /@down[b2]},{2T,3T}];
s7=Sound[{"Viola", SN/@rise[b1]},{3T,4T}]; s8=Sound[{"Cello", SN /@down[b2]},{3T,4T}];
S=Sound[{s1,s2,s3,s4,s5,s6,s7,s8}];Export["ava1.mp3",S,"MP3"]
The MP3 produced. (Mathematica file)
The MP3 of stochastic version.
And here are some details on composing with Mathematica from 2018 (Math 21b course).
Finally, here are some review slides. (The beginning a bit infantile. But we take these days things too seriously anyway. It is also a bit to honor Gonick, who did not find Harvard a very fertile ground for humor when he was here. (See this.) Be warned as it is silly. If you do not find it funny, it is not Harvard's fault. )