# HG changeset patch # User Chunyang Song # Date 1426876088 0 # Node ID 031e2ccb1fb688eb035048471d7736aad5cb53d8 # Parent b2da092dc2e050755b95f4a5b5d52dc2ee874b95 Added rhythm parser and parameter setter diff -r b2da092dc2e0 -r 031e2ccb1fb6 Syncopation models/BasicFuncs.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Syncopation models/BasicFuncs.py Fri Mar 20 18:28:08 2015 +0000 @@ -0,0 +1,163 @@ +# This python file is a collection of basic functions that are used in the syncopation models. + +import math + +# The concatenation function is used to concatenate two sequences. +def concatenate(seq1,seq2): + return seq1+seq2 + +# The repetition function is to concatenate a sequence to itself for 'times' number of times. +def repeat(seq,times): + new_seq = list(seq) + if times >= 1: + for i in range(times-1): + new_seq = concatenate(new_seq,seq) + else: + #print 'Error: repetition times needs to be no less than 1.' + new_seq = [] + return new_seq + +# The subdivision function is to equally subdivide a sequence into 'divisor' number of segments. +def subdivide(seq,divisor): + subSeq = [] + if len(seq) % divisor != 0: + print 'Error: rhythmic sequence cannot be equally subdivided.' + else: + n = len(seq) / divisor + start , end = 0, n + for i in range(divisor): + subSeq.append(seq[start : end]) + start = end + end = end + n + return subSeq + + +# The ceiling function is to round each number inside a sequence up to its nearest integer. +def ceiling(seq): + seq_ceil = [] + for s in seq: + seq_ceil.append(int(math.ceil(s))) + return seq_ceil + +# The find_divisor function returns a list of all possible divisors for a length of sequence. +def find_divisor(number): + divisors = [1] + for i in range(2,number+1): + if number%i ==0: + divisors.append(i) + return divisors + +# The find_divisor function returns a list of all possible divisors for a length of sequence. +def find_prime_factors(number): + prime_factors = find_divisor(number) + + def is_prime(num): + if num < 2: + return False + if num == 2: + return True + else: + for div in range(2,num): + if num % div == 0: + return False + return True + + for i in range(len(prime_factors)-1,0,-1): + if is_prime(prime_factors[i]) == False: + del prime_factors[i] + + return prime_factors + +# The min_timeSpan function searches for the shortest possible time-span representation for a sequence. +def get_min_timeSpan(seq): + min_ts = [1] + for d in find_divisor(len(seq)): + segments = subdivide(seq,d) + if len(segments)!=0: + del min_ts[:] + for s in segments: + min_ts.append(s[0]) + if sum(min_ts) == sum(seq): + break + return min_ts + +# get_note_indices returns all the indices of all the notes in this sequence +def get_note_indices(seq): + note_indices = [] + + for index in range(len(seq)): + if seq[index] != 0: + note_indices.append(index) + + return note_indices + +# The get_H returns a sequence of metrical weight for a certain metrical level (horizontal), +# given the sequence of metrical weights in a hierarchy (vertical) and a sequence of subdivisions. +def get_H(weight_seq,subdivision_seq, level): + H = [] + #print len(weight_seq), len(subdivision_seq), level + if (level <= len(subdivision_seq)-1) & (level <= len(weight_seq)-1): + if level == 0: + H = repeat([weight_seq[0]],subdivision_seq[0]) + else: + H_pre = get_H(weight_seq,subdivision_seq,level-1) + for h in H_pre: + H = concatenate(H, concatenate([h], repeat([weight_seq[level]],subdivision_seq[level]-1))) + else: + print 'Error: a subdivision factor or metrical weight is not defined for the request metrical level.' + return H + +# The get_subdivision_seq function returns the subdivision sequence of several common time-signatures defined by GTTM, +# or ask for the top three level of subdivision_seq manually set by the user. +def get_subdivision_seq(timesig, L_max): + subdivision_seq = [] + + if timesig == '2/4' or timesig == '4/4': + subdivision_seq = [1,2,2] + elif timesig == '3/4' or timesig == '3/8': + subdivision_seq = [1,3,2] + elif timesig == '6/8': + subdivision_seq = [1,2,3] + elif timesig == '9/8': + subdivision_seq = [1,3,3] + elif timesig == '12/8': + subdivision_seq = [1,4,3] + elif timesig == '5/4' or timesig == '5/8': + subdivision_seq = [1,5,2] + elif timesig == '7/4' or timesig == '7/8': + subdivision_seq = [1,7,2] + elif timesig == '11/4' or timesig == '11/8': + subdivision_seq = [1,11,2] + else: + print 'Time-signature',timesig,'is undefined. Please indicate subdivision sequence for this requested time-signature, e.g. [1,2,2] for 4/4 meter.' + for i in range(3): + s = int(input('Enter the subdivision factor at metrical level '+str(i)+':')) + subdivision_seq.append(s) + + if L_max > 2: + subdivision_seq = subdivision_seq + [2]*(L_max-2) + else: + subdivision_seq = subdivision_seq[0:L_max+1] + + return subdivision_seq + + # The split_by_bar function seperates the score representation of rhythm by bar lines, + # resulting in a list representingbar-by-bar rhythm sequence, + # e.g. rhythm = ['|',[ts1,td1,v1], [ts2,td2,v2], '|',[ts3,td3,v3],'|'...] + # rhythm_bybar = [ [ [ts1,td1,v1], [ts2,td2,v2] ], [ [ts3,td3,v3] ], [...]] +# def split_by_bar(rhythm): +# rhythm_bybar = [] +# bar_index = [] +# for index in range(len(rhythm)): +# if rhythm[index] == '|': + +# return rhythm_bybar + +# def yseq_to_vseq(yseq): +# vseq = [] + +# return vseq + + +# # testing +# print find_prime_factors(10) \ No newline at end of file diff -r b2da092dc2e0 -r 031e2ccb1fb6 Syncopation models/BasicFuncs.pyc Binary file Syncopation models/BasicFuncs.pyc has changed diff -r b2da092dc2e0 -r 031e2ccb1fb6 Syncopation models/KTH.py --- a/Syncopation models/KTH.py Sun Oct 05 21:52:41 2014 +0100 +++ b/Syncopation models/KTH.py Fri Mar 20 18:28:08 2015 +0000 @@ -5,7 +5,7 @@ ''' ## Problems! Note indices, post bar -from basic_functions import get_min_timeSpan, get_note_indices, repeat +from BasicFuncs import get_min_timeSpan, get_note_indices, repeat # To find the nearest power of 2 equal to or less than the given number def roundDownPower2(number): diff -r b2da092dc2e0 -r 031e2ccb1fb6 Syncopation models/LHL.py --- a/Syncopation models/LHL.py Sun Oct 05 21:52:41 2014 +0100 +++ b/Syncopation models/LHL.py Fri Mar 20 18:28:08 2015 +0000 @@ -3,7 +3,7 @@ Institution: Centre for Digital Music, Queen Mary University of London ''' -from basic_functions import concatenate, repeat, subdivide, ceiling +from BasicFuncs import concatenate, repeat, subdivide, ceiling terminal_nodes = [] # Global variable, storing all the terminal nodes from recursive tree structure in time order diff -r b2da092dc2e0 -r 031e2ccb1fb6 Syncopation models/LHL.pyc Binary file Syncopation models/LHL.pyc has changed diff -r b2da092dc2e0 -r 031e2ccb1fb6 Syncopation models/PRS.py --- a/Syncopation models/PRS.py Sun Oct 05 21:52:41 2014 +0100 +++ b/Syncopation models/PRS.py Fri Mar 20 18:28:08 2015 +0000 @@ -3,7 +3,7 @@ Institution: Centre for Digital Music, Queen Mary University of London ''' -from basic_functions import repeat, subdivide, ceiling, get_min_timeSpan +from BasicFuncs import repeat, subdivide, ceiling, get_min_timeSpan def get_cost(seq,next_seq): seq = get_min_timeSpan(seq) # converting to the minimum time-span format diff -r b2da092dc2e0 -r 031e2ccb1fb6 Syncopation models/ParameterSetter.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Syncopation models/ParameterSetter.py Fri Mar 20 18:28:08 2015 +0000 @@ -0,0 +1,90 @@ +''' +Author: Chunyang Song +Institution: Centre for Digital Music, Queen Mary University of London +''' + +# Set the parameters: subdivision_seq, weight_seq, L_max, strong_beat_level + +L_max = 5 + +# {'key': time-signature} : +# {'value': [subdivision_seq, theoretical beat-level represented by index in the subdivision_seq list]} +timesigBase = { + '2/2': [[1,2,2,2,2],1], + '3/2': [[1,3,2,2,2],1], + '4/2': [[1,2,2,2,2],1], + '2/4': [[1,2,2,2,2],1], + '3/4': [[1,3,2,2,2],1], + '4/4': [[1,2,2,2,2],2], + '5/4': [[1,5,2,2,2],1], + '7/4': [[1,7,2,2,2],1], + '3/8': [[1,3,2,2,2],1], + '5/8': [[1,5,2,2,2],1], + '6/8': [[1,2,3,2,2],1], + '9/8': [[1,3,3,2,2],1], + '12/8':[[1,2,2,3,2],2], +} + + +def addTimesig(timesig, subdivision_seq, beat_level): + if isTSValid(timesig,subdivision_seq,beat_level): + if timesig in timesigBase: + print 'This time-signature is existed already.' + else: + timesigBase[timesig] = [subdivision_seq, beat_level] + writeTimesig() + +def updateTimesig(timesig, subdivision_seq, beat_level): + if isTSValid(timesig,subdivision_seq,beat_level): + if timesig in timesigBase: + print 'Original settings for', timesig, ':',timesigBase[timesig] + timesigBase[timesig] = [subdivision_seq, beat_level] + print 'Changed into:',timesigBase[timesig] + writeTimesig() + +def isTSValid(timesig, subdivision_seq, beat_level): + isValid = False + if ('/' not in timesig) or (not timesig.split('/')[0].isdigit()) or (not timesig.split('/')[1].isdigit()): + print 'Error: invalid time-signature. Please indicate in the form of fraction, e.g. 4/4, 6/8 or 3/4.' + elif subdivision_seq != [s for s in subdivision_seq if isinstance(s,int)]: + print 'Error: invalid subdivision sequence. Please indicate in the form of list of numbers, e.g [1,2,2,2,2].' + elif beat_level >= len(subdivision_seq): + print 'Error: beat-level exceeds the range of subdivision sequence list.' + else: + isValid = True + return isValid + +def writeTimesig(): + import cPickle as pickle + timesigFile = open('TimeSignature.pkl', 'wb') + pickle.dump(timesigBase, timesigFile) + timesigFile.close() + +def readTimesig(): + import cPickle as pickle + timesigFile = open('TimeSignature.pkl','rb') + data = pickle.load(timesigFile) + return data + timesigFile.close() + +def viewTimesigBase(): + data = readTimesig() + for timesig, settings in data.items(): + print timesig, settings + +def set_L_max(number): + L_max = number + +def get_subdivision_seq(timesig): + if timesig in readTimesig(): + return timesigBase[timesig][0] + else: + print 'Error: the subdivision sequence for this time-signature is not defined.' + return None + +def get_beat_level(timesig): + if timesig in readTimesig(): + return timesigBase[timesig][1] + else: + print 'Error: the subdivision sequence for this time-signature is not defined.' + return None diff -r b2da092dc2e0 -r 031e2ccb1fb6 Syncopation models/ParameterSetter.pyc Binary file Syncopation models/ParameterSetter.pyc has changed diff -r b2da092dc2e0 -r 031e2ccb1fb6 Syncopation models/RhythmParser.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Syncopation models/RhythmParser.py Fri Mar 20 18:28:08 2015 +0000 @@ -0,0 +1,76 @@ +''' +Author: Chunyang Song +Institution: Centre for Digital Music, Queen Mary University of London +''' + +# Parse the rhythm file and return a list of Bar objects + +import ParameterSetter + +class Bar: + + def __init__(self, rhythm_seq, subdivision_seq, beat_level): + self.rhythm_seq = rhythm_seq + self.subdivision_seq = subdivision_seq + self.beat_level = beat_level + + def makeBar(self): + return [self.rhythm_seq, self.subdivision_seq, self.beat_level] + + +current_timesig = '' +Piece = [] + +def readRhythm(fileName): + try: + f = file(fileName) + + bar = f.readline() + + # While the current line has contents + while len(bar) > 0: + rhythm_seq = [] + + info = bar.split(';') + + if isInfoValid(info): + for i in info: + if i[0] == 't': + current_timesig = i[i.find('{')+1:i.find('}')] + elif i[0] == 'q': + rhythmString = i[i.find('{')+1:i.find('}')] + rhythm_seq = map(int,rhythmString.split(',')) + else: + print 'Error: %s is not recognisable. Please check this rhythm file: %s.' %(i[0], fileName) + + #Piece.append(Bar(rhythm_seq, subdivision_seq, beat_level).makeBar()) + else: + break + + bar = f.readline() + + return Piece + except: + print 'Unexpected error.'#, sys.exc_info()[0] + raise + +def isInfoValid(info): + # If two parts of information is not seperated by ; + # if 't' in info and 'q' in info: + # print 'Error: time-signature and rhythm sequence needs ";" to seperate. Please check this rhythm file: %s.' %fileName + # Piece = None + # break + # elif '{' not in info and '}' not in info: + # print 'Error: information needs to be enclosed by "{ }". Please check this rhythm file: %s.' %fileName + # Piece = None + # break + # else: + return True + +# To check whether the given time-signature is existed; if not then requires user to add in the new time-signature +#def checkTimesig(input): + + +# TESTING +print readRhythm("rhythmbase/clave.txt") + diff -r b2da092dc2e0 -r 031e2ccb1fb6 Syncopation models/SG.py --- a/Syncopation models/SG.py Sun Oct 05 21:52:41 2014 +0100 +++ b/Syncopation models/SG.py Fri Mar 20 18:28:08 2015 +0000 @@ -4,7 +4,7 @@ ''' -from basic_functions import get_H, get_min_timeSpan +from BasicFuncs import get_H, get_min_timeSpan def get_syncopation(seq, subdivision_seq, weight_seq, L_max, rhythm_category): syncopation = None diff -r b2da092dc2e0 -r 031e2ccb1fb6 Syncopation models/TMC.py --- a/Syncopation models/TMC.py Sun Oct 05 21:52:41 2014 +0100 +++ b/Syncopation models/TMC.py Fri Mar 20 18:28:08 2015 +0000 @@ -4,7 +4,7 @@ ''' -from basic_functions import get_H, ceiling, get_min_timeSpan +from BasicFuncs import get_H, ceiling, get_min_timeSpan # The get_metricity function calculates the metricity for a binary sequence with given sequence of metrical weights in a certain metrical level. def get_metricity(seq, H): diff -r b2da092dc2e0 -r 031e2ccb1fb6 Syncopation models/TMC.pyc Binary file Syncopation models/TMC.pyc has changed diff -r b2da092dc2e0 -r 031e2ccb1fb6 Syncopation models/TOB.py --- a/Syncopation models/TOB.py Sun Oct 05 21:52:41 2014 +0100 +++ b/Syncopation models/TOB.py Fri Mar 20 18:28:08 2015 +0000 @@ -4,7 +4,7 @@ ''' -from basic_functions import ceiling, find_divisor, get_min_timeSpan +from BasicFuncs import ceiling, find_divisor, get_min_timeSpan # This function calculates the syncopation value for TOB model. def get_syncopation(seq): diff -r b2da092dc2e0 -r 031e2ccb1fb6 Syncopation models/TimeSignature.pkl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Syncopation models/TimeSignature.pkl Fri Mar 20 18:28:08 2015 +0000 @@ -0,0 +1,132 @@ +(dp1 +S'2/4' +p2 +(lp3 +(lp4 +I1 +aI2 +aI2 +aI2 +aI2 +aaI1 +asS'3/2' +p5 +(lp6 +(lp7 +I1 +aI3 +aI2 +aI2 +aI2 +aaI1 +asS'3/4' +p8 +(lp9 +(lp10 +I1 +aI3 +aI2 +aI2 +aI2 +aaI1 +asS'12/8' +p11 +(lp12 +(lp13 +I1 +aI2 +aI2 +aI3 +aI2 +aaI2 +asS'3/8' +p14 +(lp15 +(lp16 +I1 +aI3 +aI2 +aI2 +aI2 +aaI1 +asS'2/2' +p17 +(lp18 +(lp19 +I1 +aI2 +aI2 +aI2 +aI2 +aaI1 +asS'6/8' +p20 +(lp21 +(lp22 +I1 +aI2 +aI3 +aI2 +aI2 +aaI1 +asS'5/4' +p23 +(lp24 +(lp25 +I1 +aI5 +aI2 +aI2 +aI2 +aaI1 +asS'4/2' +p26 +(lp27 +(lp28 +I1 +aI2 +aI2 +aI2 +aI2 +aaI1 +asS'7/4' +p29 +(lp30 +(lp31 +I1 +aI7 +aI2 +aI2 +aI2 +aaI1 +asS'5/8' +p32 +(lp33 +(lp34 +I1 +aI5 +aI2 +aI2 +aI2 +aaI1 +asS'4/4' +p35 +(lp36 +(lp37 +I1 +aI2 +aI2 +aI2 +aI2 +aaI2 +asS'9/8' +p38 +(lp39 +(lp40 +I1 +aI3 +aI3 +aI2 +aI2 +aaI1 +as. \ No newline at end of file diff -r b2da092dc2e0 -r 031e2ccb1fb6 Syncopation models/WNBD.py --- a/Syncopation models/WNBD.py Sun Oct 05 21:52:41 2014 +0100 +++ b/Syncopation models/WNBD.py Fri Mar 20 18:28:08 2015 +0000 @@ -3,8 +3,9 @@ Institution: Centre for Digital Music, Queen Mary University of London ''' -from basic_functions import repeat, get_note_indices +from BasicFuncs import repeat, get_note_indices +# To find the product of multiple numbers def cumu_multiply(numbers): product = 1 for n in numbers: @@ -15,6 +16,7 @@ syncopation = None num_beats = cumu_multiply(subdivision_seq[0:strong_beat_level+1]) # num_beats is the number of strong beats + if len(seq)%num_beats != 0: print 'Error: the length of sequence is not subdivable by the subdivision factor in subdivision_seq.' else: @@ -60,6 +62,6 @@ nextnote_index = note_indices[i+1] total += measure_pernote(note_indices[i],nextnote_index) - syncopation = float(total) / len(note_indices) + #syncopation = float(total) / len(note_indices) - return syncopation + return total diff -r b2da092dc2e0 -r 031e2ccb1fb6 Syncopation models/WNBD.pyc Binary file Syncopation models/WNBD.pyc has changed diff -r b2da092dc2e0 -r 031e2ccb1fb6 Syncopation models/clave.txt --- a/Syncopation models/clave.txt Sun Oct 05 21:52:41 2014 +0100 +++ b/Syncopation models/clave.txt Fri Mar 20 18:28:08 2015 +0000 @@ -1,1 +1,2 @@ -son; 1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0; 4/4; mono; 2 +|1,0,0,1,0,0,1,0,0,0,1,0,1,0,0,0;'4/4' +|1,0,0,1,0,0,1,0,0,0,1,0,1,0,0,0;'4/4' \ No newline at end of file diff -r b2da092dc2e0 -r 031e2ccb1fb6 Syncopation models/design/composition.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Syncopation models/design/composition.svg Fri Mar 20 18:28:08 2015 +0000 @@ -0,0 +1,606 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + Add Bar + Time-signature: + + 2/4 + + + or + + Subvision sequence: + + Tatum: 1/ + + 16 + + Duplicate + + Remove + Current Bar: + + + + Save as + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Select Bar: + + + + + Composition Panel + + + + diff -r b2da092dc2e0 -r 031e2ccb1fb6 Syncopation models/design/gui design.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Syncopation models/design/gui design.svg Fri Mar 20 18:28:08 2015 +0000 @@ -0,0 +1,432 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + Measure Syncopation + Model: + + LHL + + + Generate rhythm + or + + Syncopation Toolkit + + Save as + Measure + + + author, institution, copyright... + + Browse... + + + Explain + + + DisplayPanel + + + Compose + + Rhythm: + MIDI: + + Browse... + + + + + Parse + + diff -r b2da092dc2e0 -r 031e2ccb1fb6 Syncopation models/design/gui design2.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Syncopation models/design/gui design2.svg Fri Mar 20 18:28:08 2015 +0000 @@ -0,0 +1,587 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + Rhythm score + + + Syncopation Toolkit + + author, institution, copyright... + + + + Open + + + + <<Pre + + + + Next>> + + + Syncopation for the current bar: + + Bar: + + Duplicate + + Insert + + Remove + + + + + LHL + + + Model: + + Model tutorial + Binary sequence + Time-signature: + + Save rhythm as + Syncopation for the entire piece: + *.midi/.txt + give examples for both mode, and notification if input is invalid + + + + + + + / + Explain why this syncopation is none + + diff -r b2da092dc2e0 -r 031e2ccb1fb6 Syncopation models/main.py --- a/Syncopation models/main.py Sun Oct 05 21:52:41 2014 +0100 +++ b/Syncopation models/main.py Fri Mar 20 18:28:08 2015 +0000 @@ -1,5 +1,11 @@ +''' +Author: Chunyang Song +Institution: Centre for Digital Music, Queen Mary University of London -def syncopation_perbar(seq, model, timesig = None, subdivision_seq = None, weight_seq = None, L_max = 5, prebar_seq = None, postbar_seq = None, strong_beat_level = None): +''' + + +def sync_perbar_permodel(seq, model, timesig = None, subdivision_seq = None, weight_seq = None, L_max = 5, prebar_seq = None, postbar_seq = None, strong_beat_level = None): syncopation = None if seq == None or model == None: @@ -10,15 +16,18 @@ else: while subdivision_seq == None: - from basic_functions import get_subdivision_seq + from BasicFuncs import get_subdivision_seq subdivision_seq = get_subdivision_seq(timesig, L_max) - # polyrhythm detection: + # The get_rhythm_category function is used to detect rhythm category: monorhythm or polyrhythm. + # For monorhythms, all prime factors of the length of minimum time-span representation of this sequence are + # elements of its subdivision_seq, otherwise it is polyrhythm; + # e.g. prime_factors of polyrhythm 100100101010 in 4/4 is [2,3] but subdivision_seq = [1,2,2] for 4/4 def get_rhythm_category(): rhythm_category = 'mono' - from basic_functions import get_min_timeSpan, find_prime_factors + from BasicFuncs import get_min_timeSpan, find_prime_factors for f in find_prime_factors(len(get_min_timeSpan(seq))): - if not (f in subdivision_seq): # if one of the prime factors of this sequence is not in subdivision_seq + if not (f in subdivision_seq): rhythm_category = 'poly' break return rhythm_category @@ -50,36 +59,45 @@ import TOB syncopation = TOB.get_syncopation(seq) elif model == 'WNBD': - import WNBD # based on normalising per bar so far, should be normalising whole rhythm... + import WNBD if strong_beat_level == None: if timesig == '4/4': strong_beat_level = 2 else: strong_beat_level = 1 syncopation = WNBD.get_syncopation(seq, subdivision_seq, strong_beat_level, postbar_seq) + else: print 'Error: undefined syncopation model.' return syncopation +# def syncopation_all(rhythm, model, timesig, subdivision_seq = None, weight_seq = None, L_max = 5, strong_beat_level = None): +# syncopation = 0 +# # Chope rhythm into seq +# # ... -#def syncopation(rhythm, model, timesig, subdivision_seq = None, weight_seq = None, L_max = 5, strong_beat_level = None): +# for (seq_perbar in seq): +# sync_perbar = syncopation_perbar(seq_perbar,model, timesig, subdivision_seq, weight_seq, L_max, strong_beat_level) +# if sync_perbar != None: +# syncopation = syncopation + sync_perbar +# return syncopation ### TESTING -clave = [1,0,0,1,0,0,1,0,0,0,1,0,1,0,0,0] -bf = [0,0,0,1,0,0,0,0,0,0,1,0] -rhythm = [0,1,0,1,0,1,0,1] -classic1 = [1,0,1,1]*3 + [1,0,0,0] -classic2 = [1,0,0,1]*3 + [1,0,0,0] -shiko = [1,0,1,1,0,1,1,0] -rumba = [1,0,0,1,0,0,0,1,0,0,1,0,1,0,0,0] -soukous = [1,0,0,1,0,0,1,0,0,0,1,1,0,0,0,0] -gahu = [1,0,0,1,0,0,1,0,0,0,1,0,0,0,1,0] -bossanova = [1,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0] +# clave = [1,0,0,1,0,0,1,0,0,0,1,0,1,0,0,0] +# bf = [0,0,0,1,0,0,0,0,0,0,1,0] +# rhythm = [0,1,0,1,0,1,0,1] +# classic1 = [1,0,1,1]*3 + [1,0,0,0] +# classic2 = [1,0,0,1]*3 + [1,0,0,0] +# shiko = [1,0,1,1,0,1,1,0] +# rumba = [1,0,0,1,0,0,0,1,0,0,1,0,1,0,0,0] +# soukous = [1,0,0,1,0,0,1,0,0,0,1,1,0,0,0,0] +# gahu = [1,0,0,1,0,0,1,0,0,0,1,0,0,0,1,0] +# bossanova = [1,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0] -classic12 = [1,0,0,1,1,1,1,0,0,1,1,1] -soli = [1,0,1,0,1,0,1,0,1,1,0,1] +# classic12 = [1,0,0,1,1,1,1,0,0,1,1,1] +# soli = [1,0,1,0,1,0,1,0,1,1,0,1] -print syncopation_perbar(seq = clave, model = 'TMC', timesig = '4/4') +# print sync_perbar(seq = clave, model = 'WNBD', timesig = '4/4') diff -r b2da092dc2e0 -r 031e2ccb1fb6 Syncopation models/rhythmbase/clave.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Syncopation models/rhythmbase/clave.txt Fri Mar 20 18:28:08 2015 +0000 @@ -0,0 +1,3 @@ +t{4/4};q{1,0,0,1,0,0,1,0,0,0,1,0,1,0,0,0} +q{1,0,0,1,0,0,1,0,0,0,1,0,1,0,0,0} +t{3/4};q{1,1,1} \ No newline at end of file