Ejemplo n.º 1
0
def add_chords_bar(bar):
    global sp_midi, chord_count, bass_count, melody_count, drums_count

    chord_count += 1

    track = mixer.channels["chords"]
    channel = track
    volume = mixer.get_volume("chords")

    sequence = list(bar)
    beat_ref = chord_count * performer.timing

    for i in xrange(len(sequence)):
        chord = sequence[i]
        if chord != "." and chord.startswith("r") == False:
            chordnotes = tools.get_chord(chord)

            if len(chord) == 5:
                pitch = chord[:2]
            else:
                pitch = chord[:1]

            length = tools.lengths[str(chord[-2:])]
            time = beat_ref + float(float(i) / float(performer.timing))

            for note in chordnotes:
                sp_midi.addNote(track, channel, note, time, length, volume)
Ejemplo n.º 2
0
def add_bass_bar(bar):
    global sp_midi, chord_count, bass_count, melody_count, drums_count

    bass_count += 1

    track = mixer.channels["bass"]
    channel = track
    volume = mixer.get_volume("bass")

    sequence = list(bar)
    beat_ref = bass_count * performer.timing

    for i in xrange(len(sequence)):
        note = sequence[i]
        if note != "." and note.startswith("r") == False:
            if len(note) == 5:
                pitch = note[:2]
            else:
                pitch = note[:1]

            octave = int(note[-3:-2])
            length = tools.lengths[str(note[-2:])]
            pitch = tools.letter_to_midi(pitch, octave)
            time = beat_ref + float(float(i) / float(performer.timing))
            sp_midi.addNote(track, channel, pitch, time, length, volume)
Ejemplo n.º 3
0
def add_melody_bar(bar):
    global sp_midi, chord_count, bass_count, melody_count, drums_count

    melody_count += 1

    track = mixer.channels["melody"]
    channel = track
    volume = mixer.get_volume("melody")

    sequence = list(bar)
    beat_ref = melody_count * performer.timing

    for i in xrange(len(sequence)):
        note = sequence[i]
        if note != "." and note.startswith("r") == False:
            if len(note) == 5:
                pitch = note[:2]
            else:
                pitch = note[:1]

            octave = int(note[-3:-2])
            length = tools.lengths[str(note[-2:])]
            pitch = tools.letter_to_midi(pitch, octave)
            time = beat_ref + float(float(i)/float(performer.timing))
            sp_midi.addNote(track, channel, pitch, time, length, volume)
Ejemplo n.º 4
0
def play_notes(chan, chord, delay, length, chordsize):
    chord = chord[:chord[chordsize]]
    velo = mixer.get_volume("chords")
    for note in chord:
        midiout.send_message([chan, note, velo])
        threading.Timer(tempo_in_time * length, midiout.send_message,
                        [[chan - 16, note, 0]]).start()
Ejemplo n.º 5
0
def add_chords_bar(bar):
    global sp_midi, chord_count, bass_count, melody_count, drums_count

    chord_count += 1

    track = mixer.channels["chords"]
    channel = track
    volume = mixer.get_volume("chords")

    sequence = list(bar)
    beat_ref = chord_count * performer.timing

    for i in xrange(len(sequence)):
        chord = sequence[i]
        if chord != "." and chord.startswith("r") == False:
            chordnotes = tools.get_chord(chord)

            if len(chord) == 5:
                pitch = chord[:2]
            else:
                pitch = chord[:1]

            length = tools.lengths[str(chord[-2:])]
            time = beat_ref + float(float(i)/float(performer.timing))

            for note in chordnotes:    
                sp_midi.addNote(track, channel, note, time, length, volume)
Ejemplo n.º 6
0
def play_note(chan, note, length):
    velo = mixer.get_volume(mixer.get_channelname(chan))
    # midiout.send_message([chan, note, velo])
    # time.sleep(tempo_in_time * length)
    threading.Thread(target=midiout.send_message, args=[[chan, note,
                                                         velo]]).start()
    threading.Timer(tempo_in_time * length, midiout.send_message,
                    [[chan, note, 0]]).start()
Ejemplo n.º 7
0
def add_drums_bar(bar):
    global sp_midi, chord_count, bass_count, melody_count, drums_count

    drums_count += 1

    track = mixer.channels["drums"]
    channel = 10
    volume = mixer.get_volume("drums")

    beat_ref = drums_count * performer.timing

    for i in xrange(len(bar[0])):
        hat = bar[0][i]
        snare = bar[1][i]
        kick = bar[2][i]

        time = beat_ref + float(float(i) / float(performer.timing))

        if hat != ".":
            sp_midi.addNote(track, channel, 42, time, 0.01, volume)
        if snare != ".":
            sp_midi.addNote(track, channel, 40, time, 0.01, volume)
        if kick != ".":
            sp_midi.addNote(track, channel, 36, time, 0.01, volume)
Ejemplo n.º 8
0
def add_drums_bar(bar):
    global sp_midi, chord_count, bass_count, melody_count, drums_count

    drums_count += 1

    track = mixer.channels["drums"]
    channel = 10
    volume = mixer.get_volume("drums")

    beat_ref = drums_count * performer.timing

    for i in xrange(len(bar[0])):
        hat = bar[0][i]
        snare = bar[1][i]
        kick = bar[2][i]

        time = beat_ref + float(float(i)/float(performer.timing))
        
        if hat != ".":
            sp_midi.addNote(track, channel, 42, time, 0.01, volume)
        if snare != ".":
            sp_midi.addNote(track, channel, 40, time, 0.01, volume)
        if kick != ".":
            sp_midi.addNote(track, channel, 36, time, 0.01, volume)
Ejemplo n.º 9
0
def play_notes(chan, chord, delay, length, chordsize):
    chord = chord[:chord[chordsize]]
    velo = mixer.get_volume("chords")
    for note in chord:
        midiout.send_message([chan, note, velo])
        threading.Timer(tempo_in_time * length, midiout.send_message, [[chan - 16, note, 0]]).start()
Ejemplo n.º 10
0
def play_note(chan, note, length):
    velo = mixer.get_volume(mixer.get_channelname(chan))
    # midiout.send_message([chan, note, velo])
    # time.sleep(tempo_in_time * length)
    threading.Thread(target = midiout.send_message, args = [[chan, note, velo]]).start()
    threading.Timer(tempo_in_time * length, midiout.send_message, [[chan, note, 0]]).start()
Ejemplo n.º 11
0
    def open_mixer(self):
        print "Opening mixer."

        mix_w = 400
        row_w = mix_w / 4
        row_h = 30
        mix_h = row_h * 10

        firstcolx = 0
        secondcolx = row_w
        thirdcolx = row_w * 2

        title_slot = 0
        stitle_slot = 1
        header_slot = 2
        drums_slot = 3
        bass_slot = 4
        chords_slot = 5
        melody_slot = 6
        stabs_slot = 7
        metro_slot = 8
        info_slot = 9

        self.mix = QtGui.QWidget()

        self.mix.resize(mix_w, mix_h)
        self.mix.setWindowTitle('SeePlay Mixer')
        self.center()

        mixbg = QtGui.QLabel(self.mix)
        mixbg.resize(mix_w, mix_h)
        mixbg.move(0, 0)
        mixbg.setStyleSheet("QLabel { background-color: #333333; color: #EEEEEE; }")

        mixtitle = QtGui.QLabel(self.mix)
        mixtitle.resize(mix_w, row_h)
        mixtitle.move(0, row_h * title_slot)
        mixtitle.setText('SeePlay Mixer')
        mixtitle.setStyleSheet("QLabel { padding: 5px; font-size: 18px; text-align: center; background-color: rgba(100, 100, 100, 100); color: #FFFFFF; }")

        mixstitle = QtGui.QLabel(self.mix)
        mixstitle.resize(mix_w, row_h)
        mixstitle.move(0, row_h * stitle_slot)
        mixstitle.setText('Assign the instrument channels for MIDI output (0-15).')
        mixstitle.setStyleSheet("QLabel { padding: 5px; font-size: 10px; text-align: center; background-color: rgba(200, 200, 200, 150); color: #333333; }")

        self.mix.inst = QtGui.QLabel("Instrument:", self.mix)
        self.mix.inst.resize(row_w, row_h)
        self.mix.inst.move(firstcolx, row_h * header_slot)
        self.mix.inst.setStyleSheet("QLabel { padding: 5px; font-size: 16px; text-align: center; color: #FFFFFF; }")

        self.mix.chan = QtGui.QLabel("Channel:", self.mix)
        self.mix.chan.resize(row_w, row_h)
        self.mix.chan.move(secondcolx, row_h * header_slot)
        self.mix.chan.setStyleSheet("QLabel { padding: 5px; font-size: 16px; text-align: center; color: #FFFFFF; }")

        self.mix.vol = QtGui.QLabel("Volume (auto):", self.mix)
        self.mix.vol.resize(row_w * 2, row_h)
        self.mix.vol.move(thirdcolx, row_h * header_slot)
        self.mix.vol.setStyleSheet("QLabel { padding: 5px; font-size: 16px; text-align: center; color: #FFFFFF; }")

        self.mix.drums = QtGui.QLabel("Drums:", self.mix)
        self.mix.drums.resize(row_w, row_h)
        self.mix.drums.move(firstcolx, row_h * drums_slot)
        self.mix.drums.setStyleSheet("QLabel { padding: 5px; font-size: 14px; font-weight: bold; text-align: center; color: #FFFFFF; }")

        self.mix.drumbox = QtGui.QComboBox(self.mix)
        self.mix.drumbox.resize(row_w, row_h)
        self.mix.drumbox.move(secondcolx,row_h * drums_slot)
        for i in xrange(16):
            self.mix.drumbox.addItem(str(i))
        self.mix.drumbox.addItem("Off")
        self.mix.drumbox.setCurrentIndex(mixer.get_stdchannel("drums"))
        self.mix.drumbox.activated[str].connect(lambda: mixer.set_channel("drums", self.mix.drumbox.currentText()))

        self.mix.drumvol = QtGui.QSlider(QtCore.Qt.Horizontal, self.mix)
        self.mix.drumvol.setFocusPolicy(QtCore.Qt.NoFocus)
        self.mix.drumvol.resize(row_w * 2, row_h)
        self.mix.drumvol.move(thirdcolx, row_h * drums_slot)
        self.mix.drumvol.setMinimum(0)
        self.mix.drumvol.setMaximum(127)
        self.mix.drumvol.setValue(mixer.get_volume("drums"))
        self.mix.drumvol.valueChanged[int].connect(lambda: mixer.set_volume(self, "drums", self.mix.drumvol.value()))

        self.mix.bass = QtGui.QLabel("Bass:", self.mix)
        self.mix.bass.resize(secondcolx, row_h)
        self.mix.bass.move(firstcolx, row_h * bass_slot)
        self.mix.bass.setStyleSheet("QLabel { padding: 5px; font-size: 14px; font-weight: bold; text-align: center; color: #FFFFFF; }")

        self.mix.bassbox = QtGui.QComboBox(self.mix)
        self.mix.bassbox.resize(row_w, row_h)
        self.mix.bassbox.move(secondcolx,row_h * bass_slot)
        for i in xrange(16):
            self.mix.bassbox.addItem(str(i))
        self.mix.bassbox.addItem("Off")
        self.mix.bassbox.setCurrentIndex(mixer.get_stdchannel("bass"))
        self.mix.bassbox.activated[str].connect(lambda: mixer.set_channel("bass", self.mix.bassbox.currentText()))

        self.mix.bassvol = QtGui.QSlider(QtCore.Qt.Horizontal, self.mix)
        self.mix.bassvol.setFocusPolicy(QtCore.Qt.NoFocus)
        self.mix.bassvol.resize(row_w * 2, row_h)
        self.mix.bassvol.move(thirdcolx, row_h * bass_slot)
        self.mix.bassvol.setMinimum(0)
        self.mix.bassvol.setMaximum(127)
        self.mix.bassvol.setValue(mixer.get_volume("bass"))
        self.mix.bassvol.valueChanged[int].connect(lambda: mixer.set_volume(self, "bass", self.mix.bassvol.value()))

        self.mix.chords = QtGui.QLabel("Chords:", self.mix)
        self.mix.chords.resize(row_w, row_h)
        self.mix.chords.move(firstcolx, row_h * chords_slot)
        self.mix.chords.setStyleSheet("QLabel { padding: 5px; font-size: 14px; font-weight: bold; text-align: center; color: #FFFFFF; }")

        self.mix.chordsbox = QtGui.QComboBox(self.mix)
        self.mix.chordsbox.resize(row_w, row_h)
        self.mix.chordsbox.move(secondcolx,row_h * chords_slot)
        for i in xrange(16):
            self.mix.chordsbox.addItem(str(i))
        self.mix.chordsbox.addItem("Off")
        self.mix.chordsbox.setCurrentIndex(mixer.get_stdchannel("chords"))
        self.mix.chordsbox.activated[str].connect(lambda: mixer.set_channel("chords", self.mix.chordsbox.currentText()))

        self.mix.chordsvol = QtGui.QSlider(QtCore.Qt.Horizontal, self.mix)
        self.mix.chordsvol.setFocusPolicy(QtCore.Qt.NoFocus)
        self.mix.chordsvol.resize(row_w * 2, row_h)
        self.mix.chordsvol.move(thirdcolx, row_h * chords_slot)
        self.mix.chordsvol.setMinimum(0)
        self.mix.chordsvol.setMaximum(127)
        self.mix.chordsvol.setValue(100)
        self.mix.chordsvol.valueChanged[int].connect(lambda: mixer.set_volume(self, "chords", self.mix.chordsvol.value()))

        self.mix.melody = QtGui.QLabel("Melody:", self.mix)
        self.mix.melody.resize(row_w, row_h)
        self.mix.melody.move(firstcolx, row_h * melody_slot)
        self.mix.melody.setStyleSheet("QLabel { padding: 5px; font-size: 14px; font-weight: bold; text-align: center; color: #FFFFFF; }")

        self.mix.melodybox = QtGui.QComboBox(self.mix)
        self.mix.melodybox.resize(row_w, row_h)
        self.mix.melodybox.move(secondcolx,row_h * melody_slot)
        for i in xrange(16):
            self.mix.melodybox.addItem(str(i))
        self.mix.melodybox.addItem("Off")
        self.mix.melodybox.setCurrentIndex(mixer.get_stdchannel("melody"))
        self.mix.melodybox.activated[str].connect(lambda: mixer.set_channel("melody", self.mix.melodybox.currentText()))

        self.mix.melodyvol = QtGui.QSlider(QtCore.Qt.Horizontal, self.mix)
        self.mix.melodyvol.setFocusPolicy(QtCore.Qt.NoFocus)
        self.mix.melodyvol.resize(row_w * 2, row_h)
        self.mix.melodyvol.move(thirdcolx, row_h * melody_slot)
        self.mix.melodyvol.setMinimum(0)
        self.mix.melodyvol.setMaximum(127)
        self.mix.melodyvol.setValue(100)
        self.mix.melodyvol.valueChanged[int].connect(lambda: mixer.set_volume(self, "melody", self.mix.melodyvol.value()))

        self.mix.stabs = QtGui.QLabel("Stabs:", self.mix)
        self.mix.stabs.resize(row_w, row_h)
        self.mix.stabs.move(firstcolx, row_h * stabs_slot)
        self.mix.stabs.setStyleSheet("QLabel { padding: 5px; font-size: 14px; font-weight: bold; text-align: center; color: #FFFFFF; }")

        self.mix.stabsbox = QtGui.QComboBox(self.mix)
        self.mix.stabsbox.resize(row_w, row_h)
        self.mix.stabsbox.move(secondcolx,row_h * stabs_slot)
        for i in xrange(16):
            self.mix.stabsbox.addItem(str(i))
        self.mix.stabsbox.addItem("Off")
        self.mix.stabsbox.setCurrentIndex(mixer.get_stdchannel("stabs"))
        self.mix.stabsbox.activated[str].connect(lambda: mixer.set_channel("stabs", self.mix.stabsbox.currentText()))

        self.mix.stabsvol = QtGui.QSlider(QtCore.Qt.Horizontal, self.mix)
        self.mix.stabsvol.setFocusPolicy(QtCore.Qt.NoFocus)
        self.mix.stabsvol.resize(row_w * 2, row_h)
        self.mix.stabsvol.move(thirdcolx, row_h * stabs_slot)
        self.mix.stabsvol.setMinimum(0)
        self.mix.stabsvol.setMaximum(127)
        self.mix.stabsvol.setValue(100)
        self.mix.stabsvol.valueChanged[int].connect(lambda: mixer.set_volume(self, "stabs", self.mix.stabsvol.value()))

        self.mix.metro = QtGui.QLabel("Metronome:", self.mix)
        self.mix.metro.resize(row_w, row_h)
        self.mix.metro.move(firstcolx, row_h * metro_slot)
        self.mix.metro.setStyleSheet("QLabel { padding: 5px; font-size: 14px; font-weight: bold; text-align: center; color: #FFFFFF; }")

        self.mix.metrobox = QtGui.QComboBox(self.mix)
        self.mix.metrobox.resize(row_w, row_h)
        self.mix.metrobox.move(secondcolx,row_h * metro_slot)
        for i in xrange(16):
            self.mix.metrobox.addItem(str(i))
        self.mix.metrobox.addItem("Off")
        self.mix.metrobox.setCurrentIndex(mixer.get_stdchannel("metronome"))
        self.mix.metrobox.activated[str].connect(lambda: mixer.set_channel("metronome", self.mix.metrobox.currentText()))

        self.mix.metrovol = QtGui.QSlider(QtCore.Qt.Horizontal, self.mix)
        self.mix.metrovol.setFocusPolicy(QtCore.Qt.NoFocus)
        self.mix.metrovol.resize(row_w * 2, row_h)
        self.mix.metrovol.move(thirdcolx, row_h * metro_slot)
        self.mix.metrovol.setMinimum(0)
        self.mix.metrovol.setMaximum(127)
        self.mix.metrovol.setValue(100)
        self.mix.metrovol.valueChanged[int].connect(lambda: mixer.set_volume(self, "metronome", self.mix.metrovol.value()))

        self.mix.info = QtGui.QLabel("Please use your connected DAW to control master volume.", self.mix)
        self.mix.info.resize(mix_w, row_h)
        self.mix.info.move(firstcolx, row_h * info_slot)
        self.mix.info.setStyleSheet("QLabel { padding: 5px; font-style: italic; font-size: 10px; text-align: center; color: #FFFFFF; }")

        self.mix.show()