annotate toolboxes/MIRtoolbox1.3.2/MIRToolboxDemos/demo7tonality.m @ 0:cc4b1211e677 tip

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
parents
children
rev   line source
Daniel@0 1 function demo7tonality
Daniel@0 2 %To get familiar with some approaches of tonal analysis using MIRtoolbox,
Daniel@0 3 % and to assess their performances.
Daniel@0 4
Daniel@0 5 % Part 1. We will first investigate the performance of the chromagram
Daniel@0 6 % analysis, using very simple musical samples.
Daniel@0 7
Daniel@0 8 % 1.3. In the audio file ÔtrumpetÕ, the same pitch is played by a trumpet.
Daniel@0 9 % Compute its chromagram. What are the chromas detected by the function?
Daniel@0 10 % Can you explain the result?
Daniel@0 11 mirchromagram('trumpet')
Daniel@0 12
Daniel@0 13 % 1.4. A more detailed representation of the chromagram can be obtained by
Daniel@0 14 % decomposing each pitch class into its different possible absolute values.
Daniel@0 15 % For that purpose, just add the parameter:
Daniel@0 16 c = mirchromagram('trumpet','Wrap',0)
Daniel@0 17
Daniel@0 18 % 1.5. Compute also the key strength related to the chromagram.
Daniel@0 19 mirkeystrength(c)
Daniel@0 20
Daniel@0 21 pause, close all
Daniel@0 22
Daniel@0 23 % 1.6. In the audio file ÔpianoF4Õ, the same pitch is played by a piano.
Daniel@0 24 [ks c] = mirkeystrength('pianoF4')
Daniel@0 25
Daniel@0 26 a = miraudio('pianoF4','excerpt',.7,2);
Daniel@0 27 [ks c] = mirkeystrength(a)
Daniel@0 28
Daniel@0 29 pause, close all
Daniel@0 30
Daniel@0 31 % 1.7. Investigate the chromagram analysis of triad chords
Daniel@0 32 [ks c] = mirkeystrength('Amin3')
Daniel@0 33 p = mirpeaks(ks)
Daniel@0 34 mirkey(p)
Daniel@0 35
Daniel@0 36 pause, close all
Daniel@0 37
Daniel@0 38 [k kc ks] = mirkey('Amaj3')
Daniel@0 39 [k kc ks] = mirkey('Amin4')
Daniel@0 40 [k kc ks] = mirkey('Amaj4')
Daniel@0 41
Daniel@0 42 pause, close all
Daniel@0 43
Daniel@0 44 [k kc ks] = mirkey('Amin5')
Daniel@0 45 [k kc ks] = mirkey('Amaj5')
Daniel@0 46 [k kc ks] = mirkey('Cmaj')
Daniel@0 47
Daniel@0 48 pause, close all
Daniel@0 49
Daniel@0 50 [k kc ks] = mirkey(miraudio('Amin3','Excerpt',.2,1))
Daniel@0 51 [k kc ks] = mirkey(miraudio('Amin4','Excerpt',.2,1))
Daniel@0 52 [k kc ks] = mirkey(miraudio('Amaj3','Excerpt',.2,1))
Daniel@0 53 [k kc ks] = mirkey(miraudio('Amaj4','Excerpt',.2,1))
Daniel@0 54
Daniel@0 55 pause, close all
Daniel@0 56
Daniel@0 57 [k kc ks] = mirkey(miraudio('Amin5','Excerpt',.2,1))
Daniel@0 58 [k kc ks] = mirkey(miraudio('Amaj5','Excerpt',.2,1))
Daniel@0 59 [k kc ks] = mirkey(miraudio('Cmaj','Excerpt',.2,1))
Daniel@0 60
Daniel@0 61 pause, close all
Daniel@0 62
Daniel@0 63 %Part 2. Let's analyze several extracts from
Daniel@0 64 %real music. For each extract, try the
Daniel@0 65 %following:
Daniel@0 66
Daniel@0 67 %2.1. Listen to the piece:
Daniel@0 68 mirplay('vivaldi')
Daniel@0 69 soundsc(sin(2*pi*440*(0:1/8192:1)))
Daniel@0 70
Daniel@0 71 %2.2. Compute the chromagram of the
Daniel@0 72 %whole extract. What tonal center could be
Daniel@0 73 %inferred from the curve? Does it
Daniel@0 74 %correspond to your expectation?
Daniel@0 75 c = mirchromagram('vivaldi')
Daniel@0 76
Daniel@0 77 %2.3. Compute the key strength related to
Daniel@0 78 %the chromagram. Is the result congruent
Daniel@0 79 %with the tonality inferred in 2.1. and 2.2.?
Daniel@0 80 ks = mirkeystrength(c)
Daniel@0 81 [k kc ks] = mirkey(ks)
Daniel@0 82
Daniel@0 83 %2.4. A more detailed representation of the
Daniel@0 84 %key strengths can be obtained by
Daniel@0 85 %computing the self-organizing map:
Daniel@0 86 som = mirkeysom(c)
Daniel@0 87
Daniel@0 88 pause, close all
Daniel@0 89
Daniel@0 90 %2.5. Analyse in the same way other audio files
Daniel@0 91 [k kc ks] = mirkey('czardas')
Daniel@0 92 mirkeysom('czardas')
Daniel@0 93
Daniel@0 94 pause, close all
Daniel@0 95
Daniel@0 96 %Part 3. The temporal evolution of the
Daniel@0 97 %tonal dimension can be assessed by
Daniel@0 98 %decomposing first the audio into frames
Daniel@0 99 [k kc ks] = mirkey('czardas','frame')
Daniel@0 100 mirkeysom('czardas','frame')