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

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