示例#1
0
def createChord(freqList = [], volList = []):
	chord = NoteContainer()
	for i in range(0,len(freqList)):
		sel_freq = freqList[i]
		#scale the volumes of present frequencies
		if(sel_freq > 27 and sel_freq < 4186):
			new_Note = Note().from_hertz(sel_freq,440)
			if(sel_freq < 220 or sel_freq > 2500):
			 	if(sel_freq < 100 or sel_freq > 3000):
			 		volList[i] /= 1.4
			 	else:
			 		volList[i] /= 1.2
			new_Note.velocity = volList[i]
			if(len(BAR) > 0):
				#don't play repeat notes as quickly
				if not new_Note in (BAR[-1]):
					chord.add_note(new_Note)
	BAR.append(chord)
示例#2
0
    3.25, 3.5, 3.75, 4.0
]
possiblenote = ["C", "D", "E", "F", "G", "A", "B"]
initialized = False
uiplayer = FluidSynthSequencer()
fluidsynth.init('goodtry.sf2', uiplayer)
cymbal = Note()
cymbal.from_int(37)
snare = Note()
snare.from_int(26)
highhat = Note()
highhat.from_int(30)
base = NoteContainer()
basenote = Note()
basenote.from_int(23)
base.add_note(basenote)
soundtrack = Track()
starttrack = Track()
starttrack.add_notes(highhat, 1)
starttrack.add_notes(highhat, 1)
starttrack.add_notes(highhat, 1)
starttrack.add_notes(highhat, 1)

for i in range(0, 32):
    if math.floor(i / 4.0) == i / 4.0:
        soundtrack.add_notes([basenote, cymbal], 1.0)
    else:
        soundtrack.add_notes(base, 1.0)
finalist2 = []
durationlist = []
downbeatlist = []
示例#3
0
        note_name = arr[0]
        x_offset = arr[1]
        y_offset = arr[2]
        sum = 0
        for x in range(40):
            for y in range(40):
                sum += M[(x_offset + x) * ratio, (y_offset + y) * ratio]

        if sum < min_volume:
            min_volume = sum
        if sum > max_volume:
            max_volume = sum
        note = Note(note_name)
        note.velocity = sum
        note.channel = 1
        n.add_note(note)
        note.channel = 2
        n_2.add_note(note)

    precision = (max_volume / 1600) / 127
    scale = 1600 * precision

    for x in range(len(n)):
        n[x].velocity = ((n[x].velocity - min_volume) /
                         (max_volume - min_volume)) * 127
        if n[x].velocity < 129 and n[x].velocity > 127:
            n[x].velocity = 127

    ### secondary instrument
    max_volume = 0
    min_volume = cmath.inf
示例#4
0
                       			 note_type = int(args.note[0],10)
				if note != "" and  notes.is_valid_note(note) == False:
					print ERROR + "invalid note"
				else:
					if note == "":
						break;
					n = Note()
					if note == "k":
						n.set_Note('B')
					else:
						if note_type == 0:
							n.set_note(note)
						else:
							n.set_note(note,note_type)
					print ACTION + "playing Note : " + note
					fluidsynth.play_Note(n)
					#saving the play
					if args.save:
						nc.add_note(n)
			
				if event.unicode == 's':
					print ACTION + "saving file .."	
		else:
			if keyPressed(K_SPACE) == True or keyPressed(K_w) or keyPressed(K_a) or keyPressed(K_b) or keyPressed(K_c) or keyPressed(K_d) or keyPressed(K_e):
				play()
				print "playing"
			else:
				pause()
				print "not playing"
print ERROR + "closing .."
示例#5
0
                    print ERROR + "invalid note"
                else:
                    if note == "":
                        break
                    n = Note()
                    if note == "k":
                        n.set_Note('B')
                    else:
                        if note_type == 0:
                            n.set_note(note)
                        else:
                            n.set_note(note, note_type)
                    print ACTION + "playing Note : " + note
                    fluidsynth.play_Note(n)
                    #saving the play
                    if args.save:
                        nc.add_note(n)

                if event.unicode == 's':
                    print ACTION + "saving file .."
        else:
            if keyPressed(K_SPACE) == True or keyPressed(K_w) or keyPressed(
                    K_a) or keyPressed(K_b) or keyPressed(K_c) or keyPressed(
                        K_d) or keyPressed(K_e):
                play()
                print "playing"
            else:
                pause()
                print "not playing"
print ERROR + "closing .."