def drawDrum(self, midiTake, chord, currentPos, chordLength): channel = self.channel.get() self.sortBank() for i in range(8): arr = list(self.midiBank[i]) try: if not arr: pass else: seqStep = int(int(chordLength / len(arr)) / 8) rangeStep = 0 for n in range(32): for e, elem in enumerate(arr): try: if n == elem: RSMidi.addNote( midiTake, int(channel), 80, int(rangeStep), int(self.rc.generalMIDIMap[i][0]), 120, 0) else: rangeStep += int(seqStep) except: pass except: pass return currentPos
def drawGuitar(self, midiTake, chord, currentPos, chordLength): velocity = self.velocity.get() selectNote = self.highlight.get() channel = self.channel.get() drop = 1 RSMidi.addNote(midiTake, channel, int(velocity), int(currentPos), int(self.rc.ChordDict[chord][0]) - drop, int(chordLength), selectNote) return currentPos
def drawDrum(self, midiTake, chord, currentPos, chordLength): self.msg('drawDrum- Enter') #Reaper.ShowConsoleMsg(self.midiBank) channel = self.channel.get() self.midiBank[0] = [int(i) for i in self.midiBank[0]] self.midiBank[1] = [int(i) for i in self.midiBank[1]] self.midiBank[2] = [int(i) for i in self.midiBank[2]] self.midiBank[3] = [int(i) for i in self.midiBank[3]] self.midiBank[4] = [int(i) for i in self.midiBank[4]] self.midiBank[5] = [int(i) for i in self.midiBank[5]] self.midiBank[6] = [int(i) for i in self.midiBank[6]] self.midiBank[7] = [int(i) for i in self.midiBank[7]] self.midiBank[0].sort() self.midiBank[1].sort() self.midiBank[2].sort() self.midiBank[3].sort() self.midiBank[4].sort() self.midiBank[5].sort() self.midiBank[6].sort() self.midiBank[7].sort() for i in range(8): arr = list(self.midiBank[i]) try: if not arr: pass else: seqStep = int(int(chordLength / len(arr)) / 8) rangeStep = 0 for n in range(31): for e, elem in enumerate(arr): try: if n == elem: RSMidi.addNote( midiTake, int(channel), 80, int(rangeStep), int(self.rc.generalMIDIMap[i][0]), 120, 0) else: rangeStep += int(seqStep) except: pass except: pass self.msg('drawDrum- Exit') return currentPos
def drawBass(self,midiTake, chord, currentPos, chordLength): self.msg('drawBass - Enter') velocity = self.velocity.get() selectNote = self.highlight.get() channel = self.channel.get() drop = 24 RSMidi.addNote(midiTake, channel, int(velocity), int(currentPos),\ int(self.rc.ChordDict[chord][0])-drop, int(chordLength), selectNote) self.msg('drawBass - Exit') return currentPos
def drawMidi(self): Reaper.OnConnectExecute = "from sws_python import *" with Reaper: quartNoteLength = 960 self.msg('ReaChorder - drawMidi - Enter') p, bpm, bpi = Reaper.GetProjectTimeSignature2(0, 0, 0) bps = bpm/60 beatsInBar = bpi barsPerSection = 4 RSMidi.selAllNotes() RSMidi.deleteSelectedNotes() sectionLength = quartNoteLength * beatsInBar * barsPerSection take = RSMidi.getActTakeInEditor() if take == "(MediaItem_Take*)0x00000000" or take == "(MediaItem_Take*)0x0000000000000000": Reaper.ShowConsoleMsg("ReaChorder: Please open an item in the MIDI Editor first.\n") else: item = Item() # init Item class itemId = Reaper.GetMediaItemTake_Item(take) # get parent item songLength = sectionLength * len(self.song["Structure"]) # works (currently) :) item.setMidiItemLength(itemId, songLength, bps, quartNoteLength) item.setName(itemId, "ReaChorder Song") midiTake = RSMidi.allocateMIDITake(take) #go throught the sections, calling the draw() methods for obj in self.sections: self.msg("wtf3") p = obj.draw(midiTake, self.song, sectionLength) RSMidi.freeMIDITake(midiTake)
def drawDrum(self,midiTake, chord, currentPos, chordLength): self.msg('drawDrum- Enter') #Reaper.ShowConsoleMsg(self.midiBank) channel = self.channel.get() self.midiBank[0] = [int(i) for i in self.midiBank[0]] self.midiBank[1] = [int(i) for i in self.midiBank[1]] self.midiBank[2] = [int(i) for i in self.midiBank[2]] self.midiBank[3] = [int(i) for i in self.midiBank[3]] self.midiBank[4] = [int(i) for i in self.midiBank[4]] self.midiBank[5] = [int(i) for i in self.midiBank[5]] self.midiBank[6] = [int(i) for i in self.midiBank[6]] self.midiBank[7] = [int(i) for i in self.midiBank[7]] self.midiBank[0].sort() self.midiBank[1].sort() self.midiBank[2].sort() self.midiBank[3].sort() self.midiBank[4].sort() self.midiBank[5].sort() self.midiBank[6].sort() self.midiBank[7].sort() for i in range(8): arr = list(self.midiBank[i]) try: if not arr: pass else: seqStep = int(int(chordLength / len(arr)) / 8) rangeStep = 0 for n in range(31): for e,elem in enumerate(arr): try: if n == elem: RSMidi.addNote(midiTake, int(channel), 80, int(rangeStep), int(self.rc.generalMIDIMap[i][0]), 120, 0) else: rangeStep += int(seqStep) except: pass except: pass self.msg('drawDrum- Exit') return currentPos
def drawMidi(self): quartNoteLength = 960 self.msg('ReaChorder - drawMidi - Enter') p, bpm, bpi = RPR_GetProjectTimeSignature2(0, 0, 0) bps = bpm / 60 beatsInBar = bpi barsPerSection = 4 RSMidi.selAllNotes() RSMidi.deleteSelectedNotes() sectionLength = quartNoteLength * beatsInBar * barsPerSection take = RSMidi.getActTakeInEditor() if take == "(MediaItem_Take*)0x00000000" or take == "(MediaItem_Take*)0x0000000000000000": RPR_ShowConsoleMsg( "ReaChorder: Please open an item in the MIDI Editor first.\n") else: item = Item() # init Item class itemId = RPR_GetMediaItemTake_Item(take) # get parent item songLength = sectionLength * len( self.song["Structure"]) # works (currently) :) item.setMidiItemLength(itemId, songLength, bps, quartNoteLength) item.setName(itemId, "ReaChorder Song") midiTake = RSMidi.allocateMIDITake(take) #go throught the sections, calling the draw() methods for obj in self.sections: p = obj.draw(midiTake, self.song, sectionLength) RSMidi.freeMIDITake(midiTake)
def drawChord( self, midiTake, chord, currentPos, chordLength, chordIndex ): #velocity,x,position,startPosition,rd,chordattack,selectNote): debug.msg('drawChord - Enter') # alwaysRootPosition: # True = always draw chords in root position, False = randomize between root position and second inversion alwaysRootPosition = False ## if chordIndex == 0: # todo: "smooth chord progr." ## firstChord = chord if not alwaysRootPosition: randomChPosL = [ "rootPosition", "inversion2nd" ] # ["rootPosition", "inversion1st", "inversion2nd"] chordPos = choice(randomChPosL) else: chordPos = "rootPosition" velocity = self.velocity.get() chordattack = self.chordAttack.get() selectNote = self.highlight.get() step = 0 debug.msg(chordattack) if chordattack == 'Fast': step = 120 #fast elif chordattack == 'Slow': step = 480 #slow channel = self.settings["channel"] noteOffset = -12 # root position if chordPos == "rootPosition": note1Pitch = int(self.rc.ChordDict[chord][0]) + noteOffset note2Pitch = int(self.rc.ChordDict[chord][1]) + noteOffset note3Pitch = int(self.rc.ChordDict[chord][2]) + noteOffset # first inversion if chordPos == "inversion1st": note1Pitch = int(self.rc.ChordDict[chord][1]) + noteOffset - 12 note2Pitch = int(self.rc.ChordDict[chord][2]) + noteOffset - 12 note3Pitch = int(self.rc.ChordDict[chord][0]) + noteOffset # second inversion if chordPos == "inversion2nd": note1Pitch = int(self.rc.ChordDict[chord][2]) + noteOffset - 12 note2Pitch = int(self.rc.ChordDict[chord][0]) + noteOffset note3Pitch = int(self.rc.ChordDict[chord][1]) + noteOffset debug.msg("wtf2") RSMidi.addNote(midiTake, channel, int(velocity), int(currentPos),\ note1Pitch, int(chordLength), selectNote) RSMidi.addNote(midiTake, channel, int(velocity), int(currentPos+step),\ note2Pitch, int(chordLength)-step, selectNote) RSMidi.addNote(midiTake, channel, int(velocity), int(currentPos+(step*2)),\ note3Pitch, int(chordLength)-(step*2), selectNote) debug.msg('drawChord - Exit') return currentPos
def drawChord(self,midiTake, chord, currentPos, chordLength, chordIndex): #velocity,x,position,startPosition,rd,chordattack,selectNote): velocity = self.velocity.get() chordattack = self.chordAttack.get() chordinvert = self.chordInv.get() selectNote = self.highlight.get() if chordinvert == 'All (default)': randomChPosL = ["rootPosition", "inversion1st", "inversion2nd"] chordPos = choice(randomChPosL) elif chordinvert == '1st only': randomChPosL = ["inversion1st"] chordPos = choice(randomChPosL) elif chordinvert == '2nd only': randomChPosL = ["inversion2nd"] chordPos = choice(randomChPosL) elif chordinvert == 'Root + 1st': randomChPosL = ["rootPosition","inversion1st"] chordPos = choice(randomChPosL) elif chordinvert == 'Root + 2nd': randomChPosL = ["rootPosition", "inversion2nd"] chordPos = choice(randomChPosL) else: chordPos = "rootPosition" step = 0 if chordattack == 'Fast': step=120 #fast elif chordattack == 'Slow': step=480 #slow channel = self.settings["channel"] noteOffset = -12 # root position if chordPos == "rootPosition": note1Pitch = int(self.rc.ChordDict[chord][0]) + noteOffset note2Pitch = int(self.rc.ChordDict[chord][1]) + noteOffset note3Pitch = int(self.rc.ChordDict[chord][2]) + noteOffset # first inversion if chordPos == "inversion1st": note1Pitch = int(self.rc.ChordDict[chord][1]) + noteOffset - 12 note2Pitch = int(self.rc.ChordDict[chord][2]) + noteOffset - 12 note3Pitch = int(self.rc.ChordDict[chord][0]) + noteOffset # second inversion if chordPos == "inversion2nd": note1Pitch = int(self.rc.ChordDict[chord][2]) + noteOffset - 12 note2Pitch = int(self.rc.ChordDict[chord][0]) + noteOffset note3Pitch = int(self.rc.ChordDict[chord][1]) + noteOffset RSMidi.addNote(midiTake, channel, int(velocity), int(currentPos), note1Pitch, int(chordLength), selectNote) RSMidi.addNote(midiTake, channel, int(velocity), int(currentPos+step), note2Pitch, int(chordLength)-step, selectNote) RSMidi.addNote(midiTake, channel, int(velocity), int(currentPos+(step*2)), note3Pitch, int(chordLength)-(step*2), selectNote) return currentPos
def drawChord(self,midiTake, chord, currentPos, chordLength, chordIndex): #velocity,x,position,startPosition,rd,chordattack,selectNote): debug.msg('drawChord - Enter') # alwaysRootPosition: # True = always draw chords in root position, False = randomize between root position and second inversion alwaysRootPosition = False ## if chordIndex == 0: # todo: "smooth chord progr." ## firstChord = chord if not alwaysRootPosition: randomChPosL = ["rootPosition", "inversion2nd"] # ["rootPosition", "inversion1st", "inversion2nd"] chordPos = choice(randomChPosL) else: chordPos = "rootPosition" velocity = self.velocity.get() chordattack = self.chordAttack.get() selectNote = self.highlight.get() step = 0 debug.msg(chordattack) if chordattack == 'Fast': step=120 #fast elif chordattack == 'Slow': step=480 #slow channel = self.settings["channel"] noteOffset = -12 # root position if chordPos == "rootPosition": note1Pitch = int(self.rc.ChordDict[chord][0]) + noteOffset note2Pitch = int(self.rc.ChordDict[chord][1]) + noteOffset note3Pitch = int(self.rc.ChordDict[chord][2]) + noteOffset # first inversion if chordPos == "inversion1st": note1Pitch = int(self.rc.ChordDict[chord][1]) + noteOffset - 12 note2Pitch = int(self.rc.ChordDict[chord][2]) + noteOffset - 12 note3Pitch = int(self.rc.ChordDict[chord][0]) + noteOffset # second inversion if chordPos == "inversion2nd": note1Pitch = int(self.rc.ChordDict[chord][2]) + noteOffset - 12 note2Pitch = int(self.rc.ChordDict[chord][0]) + noteOffset note3Pitch = int(self.rc.ChordDict[chord][1]) + noteOffset debug.msg("wtf2") RSMidi.addNote(midiTake, channel, int(velocity), int(currentPos),\ note1Pitch, int(chordLength), selectNote) RSMidi.addNote(midiTake, channel, int(velocity), int(currentPos+step),\ note2Pitch, int(chordLength)-step, selectNote) RSMidi.addNote(midiTake, channel, int(velocity), int(currentPos+(step*2)),\ note3Pitch, int(chordLength)-(step*2), selectNote) debug.msg('drawChord - Exit') return currentPos
def drawBass(self, midiTake, chord, currentPos, chordLength): velocity = self.velocity.get() selectNote = self.highlight.get() channel = self.channel.get() bassTechnique = self.bassPick.get() bassOctaves = self.bassOct.get() alternateLength = chordLength / 2 if bassOctaves == 'One octave': drop = 24 elif bassOctaves == 'Two octaves': drop = 36 else: drop = 24 if bassTechnique == 'Whole': RSMidi.addNote(midiTake, channel, int(velocity), int(currentPos), int(self.rc.ChordDict[chord][0]) - drop, int(chordLength), selectNote) elif bassTechnique == 'Quarter': RSMidi.addNote(midiTake, channel, int(velocity), int(currentPos), int(self.rc.ChordDict[chord][0]) - drop, int(960), selectNote) RSMidi.addNote(midiTake, channel, int(velocity), int(currentPos) + 960, int(self.rc.ChordDict[chord][0]) - drop, int(960), selectNote) currentPos += 960 RSMidi.addNote(midiTake, channel, int(velocity), int(currentPos) + 960, int(self.rc.ChordDict[chord][0]) - drop, int(960), selectNote) currentPos += 960 RSMidi.addNote(midiTake, channel, int(velocity), int(currentPos) + 960, int(self.rc.ChordDict[chord][0]) - drop, int(960), selectNote) elif bassTechnique == 'Half': RSMidi.addNote(midiTake, channel, int(velocity), int(currentPos), int(self.rc.ChordDict[chord][0]) - drop, int(1920), selectNote) RSMidi.addNote(midiTake, channel, int(velocity), int(currentPos) + 1920, int(self.rc.ChordDict[chord][0]) - drop, int(1920), selectNote) currentPos += 1920 else: RSMidi.addNote(midiTake, channel, int(velocity), int(currentPos), int(self.rc.ChordDict[chord][0]) - drop, int(chordLength), selectNote) return currentPos
def drawMelody(self,midiTake, chord, currentPos, chordLength): self.msg('drawMelody - Enter') harmony1 = True # if True, add "harmony1" harmony2 = False # if True, add "harmony2" randNote = randint(2, 3) randPos = [0,480,960] randLength = [0.5, 1, 2] #here we now directly access the IntVars we created with the controls #to get the values. Everything in the dictionary passed to #the state manager is now is automatically stored when we close #ReaChorder. velocity = self.velocity.get() selectNote = self.highlight.get() self.msg("wtf") channel = self.channel.get() #get the list of notes in a chord by directing looking up ChordDict #with the name of the chord for j, vm in enumerate(self.rc.ChordDict[chord]): self.msg(str(j) + str(vm) + str(self.rc.ChordDict[chord])) ## Reaper.ShowConsoleMsg(str(vm) + "\n") # + str(self.rc.ChordDict[chord])) #if j == self.rc.pChordName or j == self.beatsInBar - 1 : break #don't parse chordname and do 3 notes per bar for 3/4 if j % randNote == 0: self.msg('--- draw note, random length 0.5, 1, 2') rpos = randPos[randint(0,2)] rlen = randLength[randint(0,2)] self.msg('--- rpos rlen set') # this is the original melody firstNotePosInChord = randint(0, 2) # harmony for "3 note chords" if firstNotePosInChord == 0: secondNotePosInChord = 1 thirdNotePosInChord = 2 elif firstNotePosInChord == 1: secondNotePosInChord = 2 thirdNotePosInChord = 0 else: secondNotePosInChord = 0 thirdNotePosInChord = 1 # add random extra note - set probability from the Melody tab r = randint(0, 100) if r < int(self.extraNoteProb.get()): randExtraNote = True else: randExtraNote = False # draw melody RSMidi.addNote(midiTake, int(channel), int(velocity), int(currentPos + rpos), int(self.rc.ChordDict[chord][firstNotePosInChord]),\ int(self.rc.quartNoteLength * rlen), selectNote) if harmony1: # "humanize" harmony1Pos = rpos + randint(-60, 60) if harmony1Pos < 0: harmony1Pos = 0 velocity1 = velocity * 0.8 # draw "harmony"1 RSMidi.addNote(midiTake, int(channel), int(velocity1), int(currentPos + harmony1Pos), int(self.rc.ChordDict[chord][secondNotePosInChord]),\ int(self.rc.quartNoteLength * rlen), selectNote) if harmony2: # "humanize" harmony2Pos = rpos + randint(-60, 60) if harmony2Pos < 0: harmony2Pos = 0 velocity2 = velocity * 0.8 # draw "harmony" 2 RSMidi.addNote(midiTake, int(channel), int(velocity2), int(currentPos + harmony2Pos), int(self.rc.ChordDict[chord][thirdNotePosInChord]),\ int(self.rc.quartNoteLength * rlen), selectNote) currentPos += rpos + (self.rc.quartNoteLength * rlen) if randExtraNote: RSMidi.addNote(midiTake, int(channel), int(velocity), int(currentPos + rpos), int(self.rc.ChordDict[chord][randint(0, 2)]),\ int(self.rc.quartNoteLength * rlen), selectNote) else: RSMidi.addNote(midiTake, int(channel), int(velocity), int(currentPos), int(vm), \ int(self.rc.quartNoteLength), selectNote) currentPos += self.rc.quartNoteLength self.msg('drawMelody - Exit') return currentPos
def drawMelody(self, midiTake, chord, currentPos, chordLength): self.msg('drawMelody - Enter') harmony1 = self.harmony.get() melodyType = self.MelodyTypeSel.current() harmony2 = False # if True, add "harmony2" randNote = randint(1, 3) randPos = [0, 480, 960] randLength = [0.5, 1, 2] velocity = self.velocity.get() selectNote = self.highlight.get() channel = self.channel.get() for j, vm in enumerate(self.rc.ChordDict[chord]): self.msg(str(j) + str(vm) + str(self.rc.ChordDict[chord])) if j % randNote == 0: rpos = randPos[randint(0, 2)] rlen = randLength[randint(0, 2)] # this is the original melody firstNotePosInChord = randint(0, 2) # harmony for "3 note chords" if firstNotePosInChord == 0: secondNotePosInChord = 1 thirdNotePosInChord = 2 elif firstNotePosInChord == 1: secondNotePosInChord = 2 thirdNotePosInChord = 0 else: secondNotePosInChord = 1 thirdNotePosInChord = 2 r = randint(0, 100) if r < int(self.extraNoteProb.get()): randExtraNote = False else: randExtraNote = False # draw melody # melodyType = int(self.MelodyTypeSel.current()) melodyType = 0 # Circle of fifths if melodyType == 0: RSMidi.addNote( midiTake, int(channel), int(velocity), int(currentPos + rpos), int(self.rc.ChordDict[chord][firstNotePosInChord]), int(self.rc.quartNoteLength * rlen), selectNote) currentPos += rpos + (self.rc.quartNoteLength * rlen) # Markov if melodyType == 1: chain = self.rc.ChordDictMnamed[chord][randint(1, 11)] RSMidi.addNote( midiTake, int(channel), int(velocity), int(currentPos + rpos), int(self.rc.ChordDict[chord][firstNotePosInChord]), int(self.rc.quartNoteLength * rlen), selectNote) currentPos += rpos + (self.rc.quartNoteLength * rlen) # Primes if melodyType == 2: primenote = self.rc.PrimeChain[0][randint(1, 11)] RSMidi.addNote( midiTake, int(channel), int(velocity), int(currentPos), int(self.rc.ChordDict[chord][firstNotePosInChord]), int(self.rc.quartNoteLength * rlen), selectNote) currentPos += rpos + (self.rc.quartNoteLength * rlen) if harmony1 == 1: # "humanize" harmony1Pos = rpos + randint(-60, 60) if harmony1Pos < 0: harmony1Pos = 0 velocity1 = velocity * 0.8 # draw "harmony"1 RSMidi.addNote(midiTake, int(channel), int(velocity1), int(currentPos + harmony1Pos), int(self.rc.ChordDict[chord][secondNotePosInChord]),\ int(self.rc.quartNoteLength * rlen), selectNote) if harmony2 == 1: # "humanize" harmony2Pos = rpos + randint(-60, 60) if harmony2Pos < 0: harmony2Pos = 0 velocity2 = velocity * 0.8 # draw "harmony" 2 RSMidi.addNote(midiTake, int(channel), int(velocity2), int(currentPos + harmony2Pos), int(self.rc.ChordDict[chord][thirdNotePosInChord]),\ int(self.rc.quartNoteLength * rlen), selectNote) if randExtraNote: RSMidi.addNote( midiTake, int(channel), int(velocity), int(currentPos + rpos), int(self.rc.ChordDict[chord][randint(0, 2)]), int(self.rc.quartNoteLength * rlen), selectNote) else: RSMidi.addNote(midiTake, int(channel), int(velocity), int(currentPos), int(vm), int(self.rc.quartNoteLength), selectNote) currentPos += self.rc.quartNoteLength return currentPos