From 1fa2f8722ad13aaf50df4ba84e7bc0481d044cc2 Mon Sep 17 00:00:00 2001 From: bclark66 Date: Sun, 8 Jul 2018 16:02:52 -0400 Subject: [PATCH 1/6] Add a new feature to create only one midi file per layer The new feature has a new command line option "-l" which bypasses creating one midi file per section per layer and instead creates only one midi file per layer --- src/Arranging/ArrangeSections.py | 38 +++++++++++++++++++----- src/Arranging/CreateMidiEventsForBass.py | 7 +++-- src/Skeleton/Skeleton.py | 16 ++++++---- 3 files changed, 45 insertions(+), 16 deletions(-) mode change 100644 => 100755 src/Arranging/ArrangeSections.py mode change 100644 => 100755 src/Arranging/CreateMidiEventsForBass.py mode change 100644 => 100755 src/Skeleton/Skeleton.py diff --git a/src/Arranging/ArrangeSections.py b/src/Arranging/ArrangeSections.py old mode 100644 new mode 100755 index ac031d1..cc8a3ff --- a/src/Arranging/ArrangeSections.py +++ b/src/Arranging/ArrangeSections.py @@ -7,11 +7,11 @@ class ArrangeSections : - def __init__ ( self, id, movement, outdir ) : + def __init__ ( self, id, movement, outdir , oneMidiPerLayer) : self.id = id self.movement = movement self.outdir = outdir - + self.oneMidiPerLayer = oneMidiPerLayer def arrange ( self ) : @@ -40,7 +40,7 @@ def arrange ( self ) : self.midiEventsForSectionLayers = collections.OrderedDict() - + sectionsObj = self.movement['SectionsObj'].mood for secId in sectionsObj.sections : @@ -193,12 +193,18 @@ def arrange ( self ) : self.midiEventsForSectionLayers[secId][layer] += CreateMidiEventsForBass.CreateMidiEventsForStrings ( layer, uniqCPId, secId, phId, repCount, numChordsInSection, sectionsObj.sections[secId]['phrases'][phId], self.movement['layers'][uniqCPId][layer] ) - + self.midiEventsForLayers = collections.OrderedDict() + for secId in self.midiEventsForSectionLayers : + for layer in self.midiEventsForSectionLayers[secId] : + #print("Layer: ",layer,"len: ",len(self.midiEventsForLayers)) + if (self.midiEventsForLayers.get(layer,"0") == "0" ) : + #print(layer) + self.midiEventsForLayers[layer] = [] + for secId in self.midiEventsForSectionLayers : for layer in self.midiEventsForSectionLayers[secId] : - - CreateMidiEventsForBass.CreateMidiFileForBass ( self.id, secId, layer, self.midiEventsForSectionLayers[secId][layer], self.outdir ) - + self.midiEventsForLayers[layer].extend(self.midiEventsForSectionLayers[secId][layer]) + #if ( layer == 'bass1' or layer == 'bass2' or layer == 'mel5' or layer == 'piano1' or layer == 'rhythmChords' ) : # CreateMidiEventsForBass.CreateMidiFileForBass ( self.id, secId, layer, self.midiEventsForSectionLayers[secId][layer] ) @@ -207,5 +213,23 @@ def arrange ( self ) : for ev in self.midiEventsForSectionLayers[secId][layer] : print ( ev ) print() + if self.oneMidiPerLayer: + for layer in self.midiEventsForLayers : + CreateMidiEventsForBass.CreateMidiFileForBass ( self.id, 1, layer, self.midiEventsForLayers[layer], self.outdir ) + else: + for secId in self.midiEventsForSectionLayers : + for layer in self.midiEventsForSectionLayers[secId] : + + CreateMidiEventsForBass.CreateMidiFileForBass ( self.id, secId, layer, self.midiEventsForSectionLayers[secId][layer], self.outdir ) + + #if ( layer == 'bass1' or layer == 'bass2' or layer == 'mel5' or layer == 'piano1' or layer == 'rhythmChords' ) : + # CreateMidiEventsForBass.CreateMidiFileForBass ( self.id, secId, layer, self.midiEventsForSectionLayers[secId][layer] ) + + if ( 0 and layer.startswith('mel5High') ) : + print ( "Section: ", secId, "Layer: ", layer ) + for ev in self.midiEventsForSectionLayers[secId][layer] : + print ( ev ) + print() + diff --git a/src/Arranging/CreateMidiEventsForBass.py b/src/Arranging/CreateMidiEventsForBass.py old mode 100644 new mode 100755 index 6bb59f2..460acf6 --- a/src/Arranging/CreateMidiEventsForBass.py +++ b/src/Arranging/CreateMidiEventsForBass.py @@ -402,6 +402,7 @@ def CreateMidiFileForBass ( mvNum, secId, layer, midiEvents, outdir ) : foutName = outdir + "WB_Mvmt" + str(mvNum) + "_Sec" + str(secId) + "_" + layer fout = open ( foutName + ".py", mode='w' ) + print("ouput " + foutName) WriteInitialMidiFileSequence ( fout ) @@ -449,11 +450,11 @@ def WriteFinalMidiFileSequence ( fout, foutName ) : fout.write ( "\nmidi.write_midifile(\"%s\", pattern)" %(foutMidiName) ) ; fout.close() ; - #print ( "\nOutput midi file: %s\n" %(foutMidiName) ) ; + print ( "\nOutput midi file: %s\n" %(foutMidiName) ) ; call = "python " + foutName + ".py" ; os.system ( call ) ; - call = "rm " + foutName + ".py" ; - os.system ( call ) ; + #call = "rm " + foutName + ".py" ; + #os.system ( call ) ; def WriteInitialMidiFileSequence ( fout ) : diff --git a/src/Skeleton/Skeleton.py b/src/Skeleton/Skeleton.py old mode 100644 new mode 100755 index e7e5e6a..2b10f14 --- a/src/Skeleton/Skeleton.py +++ b/src/Skeleton/Skeleton.py @@ -19,12 +19,13 @@ class Template : - def __init__ ( self, iniFname, midiFilePath, outDir ) : + def __init__ ( self, iniFname, midiFilePath, outDir,oneMidiPerLayer) : self.tempo = None self.midiFilePath = midiFilePath self.outDir = outDir self.ReadIniFile ( iniFname ) + self.oneMidiPerLayer = oneMidiPerLayer #Initialize mood and sections for mvNum in self.movements : @@ -374,7 +375,7 @@ def populateSections ( self ) : self.movements[mvNum]['layers'][uniqCPId] = section.run () - arrangeSections = ArrangeSections ( mvNum, self.movements[mvNum], self.outDir ) + arrangeSections = ArrangeSections ( mvNum, self.movements[mvNum], self.outDir ,self.oneMidiPerLayer) arrangeSections.arrange() @@ -454,7 +455,7 @@ def usage() : def run () : - + print("in skeleton") parser = argparse.ArgumentParser() parser.add_argument('-i', action='store', @@ -472,11 +473,13 @@ def run () : default='./output/', help='Output File Path') + parser.add_argument('-l', action='store_true', + dest='oneMidiPerLayer', + help="One midi per layer" ) parser.add_argument('-u', action='store_true', dest='usage', - help="usage" ) - + help="usage" ) results = parser.parse_args() @@ -499,6 +502,7 @@ def run () : print('iniFile = {!r}'.format(results.iniFile )) print('midiFile = {!r}'.format(results.midiFilePath )) print('outputDir = {!r}'.format(results.outputFilePath )) + print('layerpermidi = {!r}'.format(results.oneMidiPerLayer )) rmCmd = "rm -rf {}/WB*.mid {}/WB*.py".format( results.outputFilePath, results.outputFilePath ) @@ -506,7 +510,7 @@ def run () : #random.seed ( 10 ) - skeleton = Template( results.iniFile, results.midiFilePath, results.outputFilePath ) + skeleton = Template( results.iniFile, results.midiFilePath, results.outputFilePath,results.oneMidiPerLayer) From ec9640ee7244fdd4b201ae3607173c8353f3c02a Mon Sep 17 00:00:00 2001 From: Jose Date: Sat, 15 May 2021 01:16:03 -0700 Subject: [PATCH 2/6] Create .DS_Store --- .DS_Store | Bin 0 -> 6148 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..772bc7adc9724edaef703c6c33988bd169d9d373 GIT binary patch literal 6148 zcmeHK-EPw`6h3AJGA2YXkOo3Rxk2n=n%aTT5JKv@?qU)kL?(6ts7so%MWk_PQ@X7b z zK{k99L7pJJT-0lokk#!O4?KmKCBK=){iHfWO`kcWH)wg;4zczsv! z>R@IPzYyNaX31WP`t$S%W3N+-?kgXqaS5m3p-O$k@e*-Fs?KWoOhmi`*P%Eel{F5{r(fKJ@m8v zz?8S8jE~EH@Hpy@+SQ92GRgcX>GqXz6n3HVbSFweIcmyb5)RZjp6-}uX;&|g$E&Ng z`m%fL_GH-|*Ke-Xmff|r8&RZJx))vdXHQSIS|)N_Gx^fn>z~$(z2R?q)BVDzS8|yB@b}8=C$UWS(89BGX&YW$Y7!Z|~*J>gpbGOa}$9JuZw2Q>Tdbvhr lg3MgUs=!zAB_t*2bGZO)7|b=I1!DgQC>m^L8ThLVd Date: Sat, 15 May 2021 01:16:09 -0700 Subject: [PATCH 3/6] Create .DS_Store --- src/.DS_Store | Bin 0 -> 10244 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/.DS_Store diff --git a/src/.DS_Store b/src/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..d1c1cc10cef0533f07fed63eabf88ff63a61ee31 GIT binary patch literal 10244 zcmeHM&uGKS1A`nbH|{r|C&8nc2*|W#@Y{^S+N+W(ELYnNBGQ-~d1b zGui1gSOg@hr|e51`D76-Lw|reY(SODoa;l|2bKZLfMvikU>UFs{0|J^Z#Jb!Ojui5 z1}p=XfguC*esD08O-nlvmcKf%;9CH+6Zn`XyvKb2_i?06OFIyjyJDMS_rRnplUocX z+_ByvING$d17U?bFyRhN_RQoCh4J3e&*5-jX<=1^alzT$QB?LxcL$`qQ9 z=+jD}T`9`@d!FYG?+eBI)pB=rdgi8AZx^cda+5n(OJ#&Seo(EKyl%$p)JrYiPF_?* zDXmUl?DdkVg}Aej?8lv6av_z7JE_#Qem@$Sy_{Uit<|=k^`7^)-|=98$#)8z6Q76W z``}RBjbwh^t2G2}=S488=4G>z5PUZcoVQm#Et`;~VKj-~ zkwqa3W!Qu~mQA!+=3GtQkBHLc^?7J9pT3X|ZdZ>PUcWhr+1FmpQ)4~~sl^LRg|pmlk5w& zp^6)WK(BF?&k(LAC2K!Kk_Vf#>L48tmM&YDnhw(@Z6vo_c6R(d7Y*Q>|%4GpAq&W zxS)87Q_scRrb(wO!PksC%9_!KS5z6R6{9auO`ucXejuSfj4sx2wHSa?rDbavR50n5N~7+@3G zd^UqfIxPxHbk^=*Uc*d@a06kv3l{u19xXqP#}BkEoWo4m1X)UWpO$tYEIz^X*Z&L% eSl%$Z|L0mj;3=rGJJ(jTcK?4O4zUCF(|-U|57JQp literal 0 HcmV?d00001 From cf6ad8921babf1728520bf5a030c43081d5c92a6 Mon Sep 17 00:00:00 2001 From: Jose Date: Sat, 15 May 2021 01:30:16 -0700 Subject: [PATCH 4/6] Update .DS_Store --- src/.DS_Store | Bin 10244 -> 10244 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/src/.DS_Store b/src/.DS_Store index d1c1cc10cef0533f07fed63eabf88ff63a61ee31..875c1e02b36761448bc8b1ba991b16b4406e4df9 100644 GIT binary patch delta 478 zcmZn(XbG6$&uFzVU^hRb)ntD`vB^pTwv4AICkQm~NL5!G8CqECC>R=;PW~V&$2fa3 zznDDZ9I!Hb!7n^X<;4X_Ir&Kp3=9Nx$OkQW(Ks{)C6SnCKd(&o2ZJH delta 323 zcmZn(XbG6$&uF$WU^hRb+2lY$vB^pTwu~nyI|?;$NmN%GTA1i4m>5nzD2++Q82RvIcxGQNtMahrBC438z3XHxn8z|X=8%`(`I&sUo4Z2MueNh E056PadH?_b From fc476b6bc3bb4caafb5f3a5e8b2457e6306ae458 Mon Sep 17 00:00:00 2001 From: Jose Date: Sat, 15 May 2021 01:30:21 -0700 Subject: [PATCH 5/6] Update .DS_Store --- .DS_Store | Bin 6148 -> 6148 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/.DS_Store b/.DS_Store index 772bc7adc9724edaef703c6c33988bd169d9d373..a9e1a249c1ae2887d6bc0161ccb652fa0b38e584 100644 GIT binary patch delta 73 zcmZoMXffC@pOx|So#QV*0Q#&GX8-^I delta 72 zcmZoMXffC@pOx{{+JRMn(pPItpf%lXckS7-voPW|Nni&A`CG%uviw#E_hm bZWx@LpIZPFVPFtf*xbU_%($72;~zf&=W`P$ From 5f71630eb8cf388e66be756bdbe3012f40babb4e Mon Sep 17 00:00:00 2001 From: Jose Date: Thu, 20 May 2021 16:36:16 -0700 Subject: [PATCH 6/6] Update .DS_Store --- .DS_Store | Bin 6148 -> 8196 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/.DS_Store b/.DS_Store index a9e1a249c1ae2887d6bc0161ccb652fa0b38e584..838f8a3d1dea5eabd83326a592fff17bbd38da36 100644 GIT binary patch delta 883 zcma)5O>YuG7=EYFW%*E+k7B7>+K?)T+R*mY7$ag$LwbNnH8g&Z-DRK~mz{NYp&|!3 z)RQN&i6(NfsXsu&!J{U|ix=-E`WLJxJvy_1wmld(*?FFw_jBicW-q;$nFauqZB&*4 z80G29Q1JI2#(GQhp%}B%Z%}K?MVZv~L5PpJ2XlPSb>QLoUf11WE^b(Y8Yp0m-RK^` zxod3wW2=+(bx9=>-D7py{nQ8MaKv8ur(NF}wm@S55(TyjAlqU0l?5NIj=_RUpwljN z+KmpaoJ!x7#Z#YpaWMt84ZmH;Z1_n_QyPrzu@vf&sE3 zH}zpKdLrqnVp{3+H#FgLPjVjK>+=Uroem12U^p0wM5kiWXuK>$BvF1)Ge|?LTqi0q zvT6h0sToS8sEe|q)k+qAWEGXixGaQExZcE-`;yohhi|oX>J&ZUv|(VZISKRCs)?=A z5x#xb+#$O;3)gd6mCyoB1@Go{OCg$h8yhCYZP749t%kF$d#Wg5HLqofWs!PW2s*Jc z>1YK5v%r!f6ODD6yn4uv86cV29Fx?L2#_2S0Iz_yG@@azH<@w9LJd4Dz-8Egf-{$= z@Ei`{HGG86@D;wpFNBZ}MbH$QMF}*IE})Aj1-G1p6I5@`Gc&>wAga;vbdJgFeEscT z%W;u)jeg4B=gztqzT@H($@lgbZYDAsa?`X_i=H)We(-~fp*P)EDC8Ozoc2?^!R`Xp f{7;u1jOOfofahs@Ouk^31J68^IW_((_dfa!SNYaU delta 237 zcmZp1XfcprU|?W$DortDU=RQ@Ie-{Mvv5sJ6q~50D9R6#2aDx1Nzabpx7gL55*)a(-?BP?mu~x?!?{ ysMO{FQDMf#>>M0|%wSOl0d64e3Ucwr#P7_L`DHvo?q^_v_yy!WhRyLjbC>~4hA=b$