Exemplo n.º 1
0
def build_note_off(channel,note,velocity,time):
    m = Message("note_off")
    m.channel = channel
    m.note = note
    m.velocity = velocity
    m.time = time
    return m
Exemplo n.º 2
0
 def new_note_to_play():
     self.midi_notes[k] = note_off_time
     self.scored_notes[k] = self.music_time
     new_note_on = Message("note_on")
     new_note_on.note = k
     new_note_on.velocity = 100
     self.devices.output_messages.append(new_note_on)
Exemplo n.º 3
0
 def appendNote(self, note, velocity, time, seconds = False):
     msg = Message("note_on")
     msg.note = note
     msg.velocity = velocity
     ## time (s) * (ticks / beat) * (beats / min) * (1min / 60s)
     msg.time = time if seconds == False else int(round(time / self.seconds))
     self.appendMsg(msg)
Exemplo n.º 4
0
 def create_key_note(note_val: int, note_on: bool):
     if self.menu.is_menu_active(Menus.GAME):
         note_name = "note_on"
         if note_on == False:
             note_name = "note_off"
         new_note = Message(note_name)
         new_note.note = note_val
         new_note.velocity = 100
         self.devices.input_messages.append(new_note)
Exemplo n.º 5
0
def encoding_to_message(encoding, decodings, defaults=master_defaults):

    message = decodings[encoding]

    if message == "START_TRACK":
        #header defaults
        time_signature = MetaMessage("time_signature")
        time_signature.numerator = defaults["time_signature.numerator"]
        time_signature.denominator = defaults["time_signature.denominator"]
        time_signature.clocks_per_click = defaults[
            "time_signature.clocks_per_click"]
        time_signature.notated_32nd_notes_per_beat = defaults[
            "time_signature.notated_32nd_notes_per_beat"]

        key_signature = MetaMessage("key_signature")
        key_signature.key = defaults["key_signature.key"]

        set_tempo = MetaMessage("set_tempo")
        set_tempo.tempo = defaults["set_tempo.tempo"]

        return [time_signature, key_signature, set_tempo]

    if message == "END_TRACK":
        return [MetaMessage('end_of_track')]

    if message == "WAIT_A_BEAT":
        return [message]

    if message.startswith("note"):
        parts = message.split("-")
        res = Message(parts[0])
        res.note = int(parts[1])
        res.time = int(parts[2])
        # defaults
        res.channel = defaults["note.channel"]
        res.velocity = defaults["note.velocity"]
        return [res]

    return []