Beispiel #1
0
	def test_playnotecontainer(self):
		self.assert_(fluidsynth.play_NoteContainer(NoteContainer(["C", "E", "G"]), 0))
		time.sleep(0.25)
		fluidsynth.stop_NoteContainer(NoteContainer(["C", "E", "G"]), 0)


		self.assert_(fluidsynth.play_NoteContainer(NoteContainer(["E", "G", Note("C", 6)]), 0))
		time.sleep(0.25)
		fluidsynth.stop_NoteContainer(NoteContainer(["E", "G", Note("C", 6)]), 0)
Beispiel #2
0
	def stop_playing_notes(self):
		playing = []
		for x in self.playing:
			if x[1] <= 1:
				if not self.no_fluidsynth:
					fluidsynth.stop_NoteContainer(x[0], self.last_chan)
			else:
				playing.append([x[0], x[1] - 1])

		self.playing = playing
 def test_playnotecontainer(self):
     self.assert_(fluidsynth.play_NoteContainer(NoteContainer(['C', 'E', 'G'
                  ]), 0))
     time.sleep(0.25)
     fluidsynth.stop_NoteContainer(NoteContainer(['C', 'E', 'G']), 0)
     self.assert_(fluidsynth.play_NoteContainer(NoteContainer(['E', 'G',
                  Note('C', 6)]), 0))
     time.sleep(0.25)
     fluidsynth.stop_NoteContainer(NoteContainer(['E', 'G', Note('C', 6)]),
                                   0)
def play_offset(off, sleep_s=0.2, song=sonata, repeats=5, down_octaves=1, instrument=None):
        song = song * repeats
        if instrument is not None:
                for i in range(off):
                        fluidsynth.set_instrument(i+1, instrument)
        for i in range(len(song)+off):
                to_stop = i - off
                if to_stop >= 0:
                        fluidsynth.stop_NoteContainer(NoteContainer([a + "-" + str(int(b)-down_octaves) for (a, b) in song[to_stop].split()]), channel=(to_stop%off)+1)
                if i < len(song):
                        fluidsynth.play_NoteContainer(NoteContainer([a + "-" + str(int(b)-down_octaves) for (a, b) in song[i].split()]), channel=(i%off)+1, velocity=127)
                time.sleep(sleep_s)
Beispiel #5
0
def playProgression():
    progression = ["I", "vi", "ii", "iii7", "I7", "viidom7", "iii7", "V7"]
    key = "C"

    chords = progressions.to_chords(progression, key)

    if not fluidsynth.init(SF2):
        print "Couldn't load soundfont", SF2
        sys.exit(1)

    while 1:
        i = 0
        for chord in chords:
            c = NoteContainer(chords[i])
            l = Note(c[0].name)
            p = c[1]
            l.octave_down()
            print ch.determine(chords[i])[0]

            # Play chord and lowered first note
            fluidsynth.play_NoteContainer(c)
            fluidsynth.play_Note(l)
            time.sleep(1.0)

            # Play highest note in chord
            fluidsynth.play_Note(c[-1])

            # 50% chance on a bass note
            if random() > 0.5:
                p = Note(c[1].name)
                p.octave_down()
                fluidsynth.play_Note(p)
            time.sleep(0.50)

            # 50% chance on a ninth
            if random() > 0.5:
                l = Note(intervals.second(c[0].name, key))
                l.octave_up()
                fluidsynth.play_Note(l)
            time.sleep(0.25)

            # 50% chance on the second highest note
            if random() > 0.5:
                fluidsynth.play_Note(c[-2])
            time.sleep(0.25)

            fluidsynth.stop_NoteContainer(c)
            fluidsynth.stop_Note(l)
            fluidsynth.stop_Note(p)
            i += 1
        print "-" * 20
Beispiel #6
0
def play_smart_solo_over_chords(chord_list):
	fluidsynth.set_instrument(13, 45)
	fluidsynth.set_instrument(10, 108)

	fluidsynth.main_volume(13, 75)
	fluidsynth.main_volume(10, 100)
	
	solo = Track()

	bars = generate_solo(chord_list)
	for i in range(len(bars)):
		chord = NoteContainer(chords.from_shorthand(chord_list[i]))
		bar = bars[i]
		fluidsynth.play_NoteContainer(chord, 13)
		fluidsynth.play_Bar(bar, 10)
		fluidsynth.stop_NoteContainer(chord, 13)
		solo.add_bar(bar)
	return solo
Beispiel #7
0
                if swing:
                    if random() > 0.9:
                        fluidsynth.play_Note(Note('A#', 2), 9, randrange(50,
                                100))  # hihat open
                    elif random() > 0.6:
                        fluidsynth.play_Note(Note('G#', 2), 9, randrange(100,
                                120))  # hihat closed
                    if random() > 0.95:
                        fluidsynth.play_Note(Note('E', 2), 9, 100)  # snare
                elif t % 2 == 0:
                    fluidsynth.play_Note(Note('A#', 2), 9, 100)  # hihat open
                else:
                    if random() > 0.9:
                        fluidsynth.play_Note(Note('E', 2), 9, 100)  # snare
            if swing:
                if t % 2 == 0:
                    time.sleep((bar_length / (len(beats) * 3)) * 4)
                else:
                    time.sleep((bar_length / (len(beats) * 3)) * 2)
            else:
                time.sleep(bar_length / len(beats))
            t += 1
        fluidsynth.stop_NoteContainer(c, chord_channel)
        fluidsynth.stop_NoteContainer(c, chord_channel2)
        fluidsynth.stop_NoteContainer(c, chord_channel3)
        fluidsynth.stop_Note(l, bass_channel)
        fluidsynth.stop_Note(n, solo_channel)
        i += 1
    print '-' * 20
    loop += 1
Beispiel #8
0
def play_solo_bar_with_chord(chord_name):
	chord = NoteContainer(chords.from_shorthand(chord_name))
	solo = solo_bar(chord_name)
	fluidsynth.play_NoteContainer(chord, 13)
	fluidsynth.play_Bar(solo, 10)
	fluidsynth.stop_NoteContainer(chord, 13)
Beispiel #9
0
		fluidsynth.play_Note(l)
		time.sleep(1.0)

		# Play highest note in chord
		fluidsynth.play_Note(c[-1])

		# 50% chance on a bass note
		if random() > 0.5:
			p = Note(c[1].name)
			p.octave_down()
			fluidsynth.play_Note(p)
		time.sleep(0.50)
		
		# 50% chance on a ninth
		if random() > 0.5:
			l = Note(intervals.second(c[0].name, key))
			l.octave_up()
			fluidsynth.play_Note(l)
		time.sleep(0.25)

		# 50% chance on the second highest note
		if random() > 0.5:
			fluidsynth.play_Note(c[-2])
		time.sleep(0.25)

		fluidsynth.stop_NoteContainer(c)
		fluidsynth.stop_Note(l)
		fluidsynth.stop_Note(p)
		i += 1
	print "-" * 20
 def stop_note(self):
     fluidsynth.stop_NoteContainer(self._current_note, 0)
Beispiel #11
0
def play_stop_NoteContainer(noteContainer, duration):
    fluidsynth.play_NoteContainer(noteContainer)
    sleep(duration)
    fluidsynth.stop_NoteContainer(noteContainer)