610 likes | 631 Views
Explore a new notion of pattern matching tailored for musical sequences to analyze rhythms with varying event durations. Discover a novel approach to identifying extended musical patterns in sequences.
E N D
Song Classification for Dancing Manolis Cristodoukalis, Costas Iliopoulos, M. Sohel Rahman, W.F. Smyth PSC 2006
Classical Pattern Matching • Input: A text T = T[1..n], A Pattern P = P[1..m], both over the alphabet . • Output: • Whether P occurs in T • If yes, then the set occ(P) = {i | T[i..i+m-1] = P} PSC 2006
Example – Pattern matching Pattern P = AAGCTA Text T = CAAGCTAAGCTAC A A G C T A Pattern A A G C T A 1 2 3 4 5 6 7 8 9 10 11 12 13 Text C A A G C T A A G C T A C Occ(P) = {2, 7} PSC 2006
Our Case • Input: • Text A musical Sequence • Pattern Rhythm • Output: • Slightly different from Classical PM • A ‘extended/modified’ notion of PM PSC 2006
Musical Sequence • A string t = t[1]t[2]…t[n] • t[i] N+ • Example: • [0,50,100,200,250,300,350,400,500,550] • Significance: Sequence of events! PSC 2006
Musical Sequence • A string t = t[1]t[2]…t[n] • t[i] N+ • Example: • [0,50,100,200,250,300,350,400,500,550] • Some (musical) event occurs at 0 ms PSC 2006
Musical Sequence • A string t = t[1]t[2]…t[n] • t[i] N+ • Example: • [0,50,100,200,250,300,350,400,500,550] • Some (musical) event occurs at 0 ms • Some (musical) event occurs at 50 ms PSC 2006
Musical Sequence • A string t = t[1]t[2]…t[n] • t[i] N+ • Example: • [0,50,100,200,250,300,350,400,500,550] • Some (musical) event occurs at 0 ms • Some (musical) event occurs at 50 ms • Some (musical) event occurs at 100 ms • And so on… PSC 2006
Musical Sequence • [0,50,100,200,250,300,350,400,500,550] • Alternative Representation (We use) • [50,50,100,50,50,50,50,100,50] • Significance: Sequence of “duration” of theevents! PSC 2006
Musical Sequence First Representation 0 50 100 200 250 300 350 450 500 550 50 Duration of First Event = 50 – 0 = 50 PSC 2006
Musical Sequence First Representation 0 50 100 200 250 300 350 450 500 550 50 50 Duration of Second Event = 100 – 50 = 50 PSC 2006
Musical Sequence First Representation 0 50 100 200 250 300 350 450 500 550 50 50 100 Duration of Second Event = 200 – 100 = 100 PSC 2006
Musical Sequence First Representation 0 50 100 200 250 300 350 400 500 550 50 50 100 50 50 50 50 100 50 Alternative Representation PSC 2006
Rhythm • A string r = r[1]r[2]…r[m] • r[j] {Q, S} • Q means a quick(er) event • S means a slow(er) event • S is double the length (duration) of Q • Exact length of Q or S is not a priori known PSC 2006
New Notion of Match • Let Q q N+ • Then S 2 q • Q matches t[i..i’] iff • q = t[i] + t[i+1] + … + t[i’] • 1 i i’ n • If i = i’ then the match is SOLID PSC 2006
New Notion of Match Let q = 150 1 2 3 4 5 6 7 8 9 50 50 100 50 50 50 50 100 50 Q 50+100 = 150 = q PSC 2006
New Notion of Match Let q = 150 1 2 3 4 5 6 7 8 9 50 50 100 50 50 50 50 100 50 Q Q 100 + 50 = 150 = q PSC 2006
New Notion of Match Let q = 150 1 2 3 4 5 6 7 8 9 50 50 100 50 50 50 50 100 50 Q Q Q Q Q Q PSC 2006
New Notion of Match Let q = 100 1 2 3 4 5 6 7 8 9 50 50 100 50 50 50 50 100 50 Q Q Q Q Q Q Solid Match PSC 2006
New Notion of Match • S 2 q • S matches t[i..i’] iff either of following is true: • i = i’ and t[i] = 2q (SOLID) • i i’ and there exists i i1 i’ such that • q = t[i] + t[i+1] + … + t[i1] = t[i1+1] + t[i+1] + … + t[i’] • 1 i i’ n • So, S is either solid or a tile of 2 consecutive Q’s PSC 2006
New Notion of Match Let q = 100, then S 2q = 200 1 2 3 4 5 6 7 8 9 50 50 100 50 50 50 50 100 50 S t[1] + t[2] = 100 = t[3] PSC 2006
New Notion of Match Let q = 100, then S 2q = 200 1 2 3 4 5 6 7 8 9 50 50 100 50 50 50 50 100 50 S S t[4] + t[5] = 100 = t[6] + t[7] PSC 2006
New Notion of Match Let q = 100, then S 2q = 200 1 2 3 4 5 6 7 8 9 50 50 100 50 50 50 50 100 50 S S S S PSC 2006
New Notion of Match Let q = 100, then S 2q = 200 1 2 3 4 5 6 7 8 9 50 50 100 50 50 50 50 100 50 S S S S S Although, t[2] + t[3] + t[4] = 200 = 2q PSC 2006
New Notion of Match Let q = 100, then S 2q = 200 1 2 3 4 5 6 7 8 9 50 50 100 50 50 50 50 100 50 S S S S S S PSC 2006
New Notion of Match Let r = QSS and Let q = 50 1 2 3 4 5 6 7 8 9 50 50 100 50 50 50 50 100 50 Q S S r r matches t[2..5] PSC 2006
New Notion of Match Let r = QSS and Let q = 50 1 2 3 4 5 6 7 8 9 Q S 50 50 100 50 50 50 50 100 50 S Q S S r r r matches t[5..8] PSC 2006
New Notion of Match Let r = QSS and Let q = 50 1 2 3 4 5 6 7 8 9 Q S 50 50 100 50 50 50 50 100 50 S Q S S r r r covers t[2..8] PSC 2006
Our Problem • Input: • A musical Sequence t • A rhythm r • Output: • The longest substring t[i..i’] that is covered by r PSC 2006
Restriction • For each match of r, at least one S must be solid Let r = QSS and Let q = 50 1 2 3 4 5 6 7 8 9 r 50 50 100 50 50 50 50 50 100 Q S S SOLID S PSC 2006
Restriction • For each match of r, at least one S must be solid Let r = QSS and Let q = 50 1 2 3 4 5 6 7 8 9 r 50 50 100 50 50 50 50 50 100 Q S S r At least one S must be Solid PSC 2006
Restriction • For each match of r, at least one S must be solid Let r = QSS and Let q = 50 1 2 3 4 5 6 7 8 9 r 50 50 100 50 50 50 50 50 100 Q S SOLID S S At least one S must be Solid r PSC 2006
Motivation • Our aim is to classify music according to dancing rhythm • Music seq can be considered as a series of events corresponding to music signals • Drum beats • Guiter picks • Horn hits PSC 2006
Motivation • The intervals between these events characterize how the song is danced • Basically two dancing rhythms: Quick & Slow • Example: • cha-cha SSQQSSSQQS • foxtrot SSQQSSQQ • jive SSQQSQQS PSC 2006
Motivation • So solution to our problem can classify songs according to dancing rhythms! PSC 2006
Algorithm • Stage 1: Find all occurrences of S for a chosen value such that /2 . • Stage 2: Transform areas around each S into sequences of Q. • Stage 3: Find the matches of r and consequently the cover. PSC 2006
Algorithm: Stage 1 • We construct two arrays: • first[1..||]: first[] = i iff the first occurrence of symbol appears at position i. • next[1..n]: next[i] = j iff the next occurrence of symbol at t[i] appears at t[j]. PSC 2006
Algorithm: Stage 1 1 2 3 4 5 6 7 8 9 50 50 100 50 50 50 50 100 50 = {50, 100}, assume indexed alphabet PSC 2006
Algorithm: Stage 1 1 2 3 4 5 6 7 8 9 50 50 100 50 50 50 50 100 50 = {50, 100}, assume indexed alphabet First occurrence of 50 first[1] = 1 PSC 2006
Algorithm: Stage 1 1 2 3 4 5 6 7 8 9 50 50 100 50 50 50 50 100 50 = {50, 100}, assume indexed alphabet first[1] = 1 first[2] = 3 First occurrence of 100 PSC 2006
Algorithm: Stage 1 1 2 3 4 5 6 7 8 9 50 50 100 50 50 50 50 100 50 next[1] = 2 Next occurrence of t[1] = 50 PSC 2006
Algorithm: Stage 1 1 2 3 4 5 6 7 8 9 50 50 100 50 50 50 50 100 50 next[1] = 2 next[2] = 4 Next occurrence of t[2] = 50 PSC 2006
Algorithm: Stage 1 1 2 3 4 5 6 7 8 9 50 50 100 50 50 50 50 100 50 next[1] = 2 next[2] = 4 next[3] = 8 Next occurrence of t[3] = 100 And so on… PSC 2006
Algorithm: Stage 2 1 2 3 4 5 6 7 8 9 10 11 … 100 50 25 25 100 50 15 30 5 30 50 … S Consider an S at t[5]. PSC 2006
Algorithm: Stage 2 1 2 3 4 5 6 7 8 9 10 11 … 100 50 25 25 100 50 15 30 5 30 50 … S Q PSC 2006
Algorithm: Stage 2 1 2 3 4 5 6 7 8 9 10 11 … 100 50 25 25 100 50 15 30 5 30 50 … S Q Q PSC 2006
Algorithm: Stage 2 1 2 3 4 5 6 7 8 9 10 11 … 100 50 25 25 100 50 15 30 5 30 50 … S 30+50 > 50 Q Q So Stop! PSC 2006
Algorithm: Stage 2 1 2 3 4 5 6 7 8 9 10 11 … 100 50 25 25 100 50 15 30 5 30 50 … S Q Q Q PSC 2006
Algorithm: Stage 2 1 2 3 4 5 6 7 8 9 10 11 … 100 50 25 25 100 50 15 30 5 30 50 … Q S Q Q Q So we get a new sequence t consisting of Q and S PSC 2006
Algorithm: Stage 3 • Here we get t consisting of Q and S. • We first want to find the matches of r in t. • Define St S in t, Qt Q in t • Define Sr S in r, Qr Q in r PSC 2006