예제 #1
0
파일: music.py 프로젝트: calebw3/Pitchr
    def minor_triad(note):
        """Get the minor triad of a Note

        :param note: Note
        :returns: Chord
        """
        mingus_chord = _MingusChord.minor_triad(note.letter)
        return Chord.mingusChord_to_chord(mingus_chord, note)
예제 #2
0
 def test_minor_triad(self):
     self.assertEqual(["C", "Eb", "G"], chords.minor_triad("C"))
     self.assertEqual(["E", "G", "B"], chords.minor_triad("E"))
     self.assertEqual(["B", "D", "F#"], chords.minor_triad("B"))
예제 #3
0
def generate_accompaniment(net_output_chords):
    generated_chords = []
    chords = []
    for chord in net_output_chords:
        root, key = (chord.split(":"))
        print(root, key)
        if key == 'maj':
            chords.append(ch.major_triad(root))
        if key == 'min':
            chords.append(ch.minor_triad(root))      

    print(chords)  

    key = chords[0][0]
    print('key', key)
    if not fluidsynth.init(SF2):
        print("Couldn't load soundfont", SF2)
        sys.exit(1)

    print(dir(fluidsynth.midi))
    # fluidsynth.midi.start_audio_output()
    fluidsynth.midi.start_recording()
    phrase = 0
    while phrase == 0:
        i = 0
        for chord in chords:
            print("chord", chord)
            c = NoteContainer(chords[i])
            generated_chords.append([{'note':cc.name.replace("B#","B").replace("E#","E").replace("##","#"), 'octave':cc.octave} for cc in c])
            l = Note(c[0].name)
            p = c[1]
            l.octave_down()
            print(ch.determine(chords[i])[0])

            # Play chord and lowered first note
            # fluidsynth.midi.MidiFileOut.write_NoteContainer("test.mid", c)
            print("NEW CHORD = ", c)

            if PLAY_ENABLED:

                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.50:
                    p = Note(c[1].name)
                    p.octave_down()
                    fluidsynth.play_Note(p)
                time.sleep(0.50)

                # 50% chance on a ninth

                if random() > 0.50:
                    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.50:
                    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)
        phrase = 1
        return generated_chords
예제 #4
0
파일: test_chords.py 프로젝트: anzev/mingus
	def test_minor_triad(self):
		self.assertEqual(["C", "Eb", "G"], chords.minor_triad("C"))
		self.assertEqual(["E", "G", "B"], chords.minor_triad("E"))
		self.assertEqual(["B", "D", "F#"] , chords.minor_triad("B"))
예제 #5
0
 def test_minor_triad(self):
     self.assertEqual(['C', 'Eb', 'G'], chords.minor_triad('C'))
     self.assertEqual(['E', 'G', 'B'], chords.minor_triad('E'))
     self.assertEqual(['B', 'D', 'F#'], chords.minor_triad('B'))
예제 #6
0
 def test_minor_triad(self):
     self.assertEqual(['C', 'Eb', 'G'], chords.minor_triad('C'))
     self.assertEqual(['E', 'G', 'B'], chords.minor_triad('E'))
     self.assertEqual(['B', 'D', 'F#'], chords.minor_triad('B'))