Exemplo n.º 1
0
def simpleToFinaleCmd(d):
    import music_util
    hmatoms = {
        8: '8',
        4: '7',
        2: '6',
        1: '5',
        0.5: '4',
        0.25: '3',
        0.125: '2',
        0.0625: 1
    }
    atoms = {}
    for key in hmatoms:
        atoms[int(key * baseDivisions)] = hmatoms[key]
    part = d.trscore.trparts[0]
    sout = ''

    for measure in part.trmeasures:
        for notegroup in measure.trlayers[0].trnotegroups:
            duration = notegroup.endTime - notegroup.startTime
            ndur = atoms[duration]
            print(notegroup.pitches)
            assert len(notegroup.pitches) == 1
            if notegroup.tied: print('warning:tied note')
            if notegroup.pitches[0] == 0: nname = 'r'
            else:
                nname = ''.join(
                    map(str, music_util.noteToName(notegroup.pitches[0])))
            sout += ndur + nname + '; '
    print(sout)
def createMingusComposition(intermed, timesig, bIsTreble, bSharps):
    comp = Composition()
    comp.set_title('Trilled Results')
    comp.set_author('Author')
    if bIsTreble: ins = TrebleInstrument('')
    else: ins = BassInstrument('')

    track = Track(ins)
    track.name = 'Part 1'
    comp.add_track(track)

    assert len(timesig) == 2 and isinstance(timesig[0], int) and isinstance(
        timesig[1], int)
    firstbar = Bar(meter=timesig)
    track.add_bar(firstbar)

    mapDurs = {
        int(intermed.baseDivisions * 4): 1.0,  #whole note,
        int(intermed.baseDivisions * 2): 2.0,  #half note
        int(intermed.baseDivisions * 1): 4.0,  #qtr note, and so on
        int(intermed.baseDivisions * 0.5): 8.0,
        int(intermed.baseDivisions * 0.25): 16.0,
        int(intermed.baseDivisions * 0.125): 32.0,
        int(intermed.baseDivisions * 0.0625): 64.0,
    }

    for note in intermed.noteList:
        if note.pitch == 0 or note.pitch == (0, ):  # a rest
            thepitches = tuple()
        else:  # a note
            thepitches = []
            for pitch in note.pitch:
                pname, poctave = music_util.noteToName(pitch, bSharps)
                thepitches.append(pname + '-' + str(poctave))

        dur = note.end - note.start
        if dur not in mapDurs:
            raise NotesinterpretException('Unknown duration:' + str(dur))
        notecontainer = NoteContainer(thepitches)
        notecontainer.tied = note.isTied
        bFit = track.add_notes(notecontainer, mapDurs[dur])
        assert bFit

        #note that, naturally, will enforce having correct measure lines, since going across barline throughs exception

    return comp
def createMingusComposition(intermed, timesig, bIsTreble, bSharps):
	comp = Composition()
	comp.set_title('Trilled Results')
	comp.set_author('Author')
	if bIsTreble: ins = TrebleInstrument('')
	else: ins=BassInstrument('')
	
	track = Track(ins)
	track.name = 'Part 1'
	comp.add_track(track)

	assert len(timesig)==2 and isinstance(timesig[0],int) and isinstance(timesig[1],int)
	firstbar = Bar(meter=timesig)
	track.add_bar(firstbar)
	
	mapDurs={ 
		int(intermed.baseDivisions*4): 1.0, #whole note,
		int(intermed.baseDivisions*2): 2.0, #half note
		int(intermed.baseDivisions*1): 4.0, #qtr note, and so on
		int(intermed.baseDivisions*0.5): 8.0,
		int(intermed.baseDivisions*0.25): 16.0,
		int(intermed.baseDivisions*0.125): 32.0,
		int(intermed.baseDivisions*0.0625): 64.0,
			}
	
	for note in intermed.noteList:
		if note.pitch==0 or note.pitch==(0,): # a rest
			thepitches = tuple()
		else: # a note
			thepitches = []
			for pitch in note.pitch:
				pname, poctave = music_util.noteToName(pitch,bSharps)
				thepitches.append(pname+'-'+str(poctave))
		
		dur = note.end - note.start
		if dur not in mapDurs: raise NotesinterpretException('Unknown duration:' + str(dur))
		notecontainer = NoteContainer(thepitches)
		notecontainer.tied =  note.isTied
		bFit = track.add_notes(notecontainer, mapDurs[dur])
		assert bFit
	
		#note that, naturally, will enforce having correct measure lines, since going across barline throughs exception
	
	return comp
Exemplo n.º 4
0
def simpleToFinaleCmd(d):
	import music_util
	hmatoms={8:'8',4:'7',2:'6',1:'5',0.5:'4',0.25:'3',0.125:'2',0.0625:1}
	atoms={}
	for key in hmatoms: atoms[int(key*baseDivisions)]=hmatoms[key]
	part = d.trscore.trparts[0]
	sout=''
	
	for measure in part.trmeasures:
		for notegroup in measure.trlayers[0].trnotegroups:
			duration=notegroup.endTime-notegroup.startTime
			ndur=atoms[duration]
			print notegroup.pitches
			assert len(notegroup.pitches)==1 
			if notegroup.tied: print 'warning:tied note'
			if notegroup.pitches[0]==0:nname='r'
			else: nname = ''.join(map(str,music_util.noteToName(notegroup.pitches[0])))
			sout += ndur+nname+'; '
	print sout
Exemplo n.º 5
0
    def changeTransposition(self, amount):
        newtrans = self.objNotesRealtime.setTranspose(amount)

        s = 'Transposition: %d   (lowest note is %s)' % (
            newtrans - 60, ''.join(map(str, music_util.noteToName(newtrans))))
        self.lblTransposition.config(text=s)
Exemplo n.º 6
0
	def changeTransposition(self, amount):
		newtrans = self.objNotesRealtime.setTranspose(amount)
		
		s='Transposition: %d   (lowest note is %s)'%(newtrans-60, ''.join(map(str,music_util.noteToName(newtrans))))
		self.lblTransposition.config(text=s)