Download presentation
Presentation is loading. Please wait.
1
Key Detection In Musical Signals Philip Brown, ’07 Advisor: Dr. Shane Cotter
2
Goals Develop a Key Detection Algorithm Implement Algorithm in Real Time Create Stand-Alone Device to Perform Desired Calculations
3
Background There are twelve musical notes Each note is a frequency f and all other frequencies of 2f, 4f, 8f … 2^x*f Keys are groups of musical notes that comprise most of the notes in a piece of music
4
Key Detection SignalWindow Spectrum Analysis Function Peak Finding Note Identification Data Storage Data Manipulation Data Summation Logic Statements Key Identification
5
Spectral Analysis FFT vs. Constant Q FFT: Spectral Data with uniform Frequency Resolution Constant Q: Spectral Data with Exponential Frequency Resolution, Frequencies fall on Musical Notes
6
Problems With FFT 60 Hz 90-94.5 Hz150Hz Intended Frequencies: 61.74 Hz, 92.5 Hz, 146.83Hz FFT: 0.2s Window 44100 Samples/ second
7
Constant Q Intended Frequencies: 61.74 Hz, 92.5 Hz, 146.83Hz Constant Q: b = 24 fo = 27.5 fmax = 3520 44100 Samples/second 62.5Hz 92.5Hz146.83Hz
8
Problem! Lower frequencies take longer amounts of time to calculate In order to use Constant Q, these frequencies must be cut out Key Detection Still possible in most cases
9
Key Detection SignalWindow Spectrum Analysis Function Peak Finding Note Identification Data Storage Data Manipulation Data Summation Logic Statements Key Identification
10
Peak Finding Use for loops to find relative maxima of spectral content
11
Peak Find [frequency, amplitude] = Peakfind(signal,b,fk,minamp) Will find all peaks above minimum amplitude. For signal = constant q of 308.7, 617.4, and 1648.1Hz sine waves. [frequency,amplitude] = Peakfind(signal,24,fk,minamp) outputs: frequency = [311.8 623.6 1664.9] amplitude = [0.1229 0.1225 0.0742] Which corresponds to the peak on the constant q plot.
12
Key Detection SignalWindow Spectrum Analysis Function Peak Finding Note Identification Data Storage Data Manipulation Data Summation Logic Statements Key Identification
13
Note Identification Peak Finder outputs array of frequencies Sorts through array of musical frequencies and find closest one Takes amplitude of that note and add it to corresponding note in note matrix: [A Bb B C C# D Eb E F F# G G#]
14
Note Identification [notestrengths] = noteid(frequency,amplitude) Take previous example Will output: notestrengths = [0 0 0 0 0 0 0.2455 0 0 0 0 0.0742]
15
Key Detection Music Signal Window Spectrum Analysis Function Peak Finding Note Identification Data Storage Data Manipulation Data Summation Logic Statements Key Identification
16
Data Each Note Matrix stored Separately Every time new matrix is added to data, oldest matrix is deleted To calculate key, all Note Matrices in data are added Logic Statements determine key by looking at notes with greatest amplitude
17
Key Detection Start with output of summation of note strengths: [12 1 6 2 10 9 3 11 4 7 5 8] Set the 5 lowest to 0 [12 0 6 0 10 9 0 11 0 7 0 8] Set the rest to 1 [ 1 0 1 0 1 1 0 1 0 1 0 1] See if this matches any stored keys YES! Key is A.
18
Putting It All Together MATLAB Program Implements All of these processes together to output Key vs. Time
19
Sample Data Key vs. Time Numbers Correspond to Different Keys Expected Keys: A, Key Change to Dm Keys Approximated: A,D,Dm
20
Problems Key isn’t always correct In some pop pieces, key is arguable However, incorrect keys are generally 5ths of the expected key (as close as possible) Some pieces have too many accidentals (notes outside of key)
21
Successes Key changes are noticeable Generally, one can determine the key from the output graph In most cases, if the entire piece is examined, the findkey will output the correct overall key
22
Real Time A 3 minute song takes 10 minutes to output key vs. time Constant Q is very much like DFT In order to process Constant Q in real time, need to relate it to FFT (possible future project)
23
More Accurate Key Approximation Right now, key approximation takes into account 7 strongest notes, regardless of order Attempts to account for fewer notes unsuccessful More complicated logic statements could more accurately calculate key (possible future project)
24
What’s Next Transfer code to C Implement code on TI TMS320C6713 DSP Chipset Tempo?
25
Acknowledgements and Questions Thanks to Prof. Catravas for help on music theory Any Questions?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.