Python Forum
mido MIDI-file; how to distinguis tracks?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
mido MIDI-file; how to distinguis tracks?
#1
I did already some code which prints all midi messages in a dict using mido. This is the result of a test midi-file:

{'type': 'time_signature', 'numerator': 4, 'denominator': 4, 'clocks_per_click': 24, 'notated_32nd_notes_per_beat': 8, 'time': 0}
{'type': 'set_tempo', 'tempo': 500000, 'time': 0}
{'type': 'track_name', 'name': 'Tempo Track', 'time': 0}
{'type': 'track_name', 'name': 'Right', 'time': 0}
{'type': 'note_on', 'time': 0, 'channel': 0, 'note': 60, 'velocity': 100}
{'type': 'track_name', 'name': 'Left', 'time': 0}
{'type': 'note_on', 'time': 0, 'channel': 1, 'note': 48, 'velocity': 100}
{'type': 'note_off', 'time': 0.5, 'channel': 0, 'note': 60, 'velocity': 0}
{'type': 'note_on', 'time': 0, 'channel': 0, 'note': 67, 'velocity': 100}
{'type': 'note_off', 'time': 0.25, 'channel': 0, 'note': 67, 'velocity': 0}
{'type': 'note_on', 'time': 0, 'channel': 0, 'note': 65, 'velocity': 100}
{'type': 'note_off', 'time': 0, 'channel': 1, 'note': 48, 'velocity': 0}
{'type': 'note_on', 'time': 0, 'channel': 1, 'note': 50, 'velocity': 100}
{'type': 'note_off', 'time': 0.25, 'channel': 0, 'note': 65, 'velocity': 0}
{'type': 'note_on', 'time': 0, 'channel': 0, 'note': 64, 'velocity': 100}
{'type': 'note_off', 'time': 0, 'channel': 1, 'note': 50, 'velocity': 0}
{'type': 'note_on', 'time': 0, 'channel': 1, 'note': 52, 'velocity': 100}
{'type': 'note_off', 'time': 0.5, 'channel': 0, 'note': 64, 'velocity': 0}
{'type': 'note_on', 'time': 0, 'channel': 0, 'note': 62, 'velocity': 100}
{'type': 'note_off', 'time': 0, 'channel': 1, 'note': 52, 'velocity': 0}
{'type': 'note_on', 'time': 0, 'channel': 1, 'note': 55, 'velocity': 100}
{'type': 'note_off', 'time': 0.25, 'channel': 0, 'note': 62, 'velocity': 0}
{'type': 'note_on', 'time': 0, 'channel': 0, 'note': 60, 'velocity': 100}
{'type': 'set_tempo', 'tempo': 600000, 'time': 0.25}
{'type': 'note_off', 'time': 0, 'channel': 0, 'note': 60, 'velocity': 0}
{'type': 'note_on', 'time': 0, 'channel': 0, 'note': 62, 'velocity': 100}
{'type': 'note_off', 'time': 0, 'channel': 1, 'note': 55, 'velocity': 0}
{'type': 'note_on', 'time': 0, 'channel': 1, 'note': 53, 'velocity': 100}
{'type': 'note_off', 'time': 0.6, 'channel': 0, 'note': 62, 'velocity': 0}
{'type': 'note_on', 'time': 0, 'channel': 0, 'note': 57, 'velocity': 100}
{'type': 'note_off', 'time': 0.6, 'channel': 1, 'note': 53, 'velocity': 0}
{'type': 'note_on', 'time': 0, 'channel': 1, 'note': 55, 'velocity': 100}
{'type': 'note_off', 'time': 0.6, 'channel': 1, 'note': 55, 'velocity': 0}
{'type': 'note_on', 'time': 0, 'channel': 1, 'note': 53, 'velocity': 100}
{'type': 'note_off', 'time': 0.3, 'channel': 1, 'note': 53, 'velocity': 0}
{'type': 'note_on', 'time': 0, 'channel': 1, 'note': 52, 'velocity': 100}
{'type': 'time_signature', 'numerator': 3, 'denominator': 8, 'clocks_per_click': 24, 'notated_32nd_notes_per_beat': 8, 'time': 0.3}
{'type': 'note_off', 'time': 0, 'channel': 0, 'note': 57, 'velocity': 0}
{'type': 'note_on', 'time': 0, 'channel': 0, 'note': 57, 'velocity': 100}
{'type': 'note_off', 'time': 0, 'channel': 1, 'note': 52, 'velocity': 0}
{'type': 'note_on', 'time': 0, 'channel': 1, 'note': 50, 'velocity': 100}
{'type': 'note_off', 'time': 0.3, 'channel': 0, 'note': 57, 'velocity': 0}
{'type': 'note_on', 'time': 0, 'channel': 0, 'note': 65, 'velocity': 100}
{'type': 'note_off', 'time': 0.3, 'channel': 0, 'note': 65, 'velocity': 0}
{'type': 'note_on', 'time': 0, 'channel': 0, 'note': 64, 'velocity': 100}
{'type': 'note_off', 'time': 0.3, 'channel': 0, 'note': 64, 'velocity': 0}
{'type': 'note_on', 'time': 0, 'channel': 0, 'note': 62, 'velocity': 100}
{'type': 'note_off', 'time': 0, 'channel': 1, 'note': 50, 'velocity': 0}
{'type': 'note_on', 'time': 0, 'channel': 1, 'note': 55, 'velocity': 100}
{'type': 'note_on', 'time': 0.3, 'channel': 0, 'note': 60, 'velocity': 100}
{'type': 'note_off', 'time': 0, 'channel': 0, 'note': 62, 'velocity': 0}
{'type': 'note_off', 'time': 0.3, 'channel': 0, 'note': 60, 'velocity': 0}
{'type': 'note_on', 'time': 0, 'channel': 0, 'note': 62, 'velocity': 100}
{'type': 'time_signature', 'numerator': 4, 'denominator': 4, 'clocks_per_click': 24, 'notated_32nd_notes_per_beat': 8, 'time': 0.3}
{'type': 'note_on', 'time': 0, 'channel': 0, 'note': 64, 'velocity': 100}
{'type': 'note_off', 'time': 0, 'channel': 0, 'note': 62, 'velocity': 0}
{'type': 'note_off', 'time': 0, 'channel': 1, 'note': 55, 'velocity': 0}
{'type': 'note_on', 'time': 0, 'channel': 1, 'note': 48, 'velocity': 100}
{'type': 'note_off', 'time': 2.4, 'channel': 0, 'note': 64, 'velocity': 0}
{'type': 'note_off', 'time': 0, 'channel': 1, 'note': 48, 'velocity': 0}
{'type': 'end_of_track', 'time': 0}

I made the file in midieditor and made two tracks:
  • Right
  • Left
Question: How do I know to which track the note_on or note_off belongs?

because the order of messages is in delta times and the note_on/note_off messages do not contain information about the track. In midieditor it can somehow read to which track the note belongs; I want to understand how this works. please give me a explenation Huh
Reply
#2
Type 0 or Type 1 midi file? Type 0 midi files are single track, type 1 is multi track with a track per channel.
Reply
#3
(Dec-10-2021, 05:01 PM)jefsummers Wrote: Type 0 or Type 1 midi file? Type 0 midi files are single track, type 1 is multi track with a track per channel.
It is type 1. But the strange thing is that midieditor can recognize even notes that are on the same channel and are on different tracks.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to execute tempo changes in Mido? NickShredScott 0 463 Nov-28-2023, 05:16 AM
Last Post: NickShredScott
  Adding MIDI Channels to each Input zach1234 6 1,215 Apr-20-2023, 11:51 AM
Last Post: jefsummers
  How to bind a midi signal to tkinter? philipbergwerf 1 1,617 Feb-09-2022, 05:17 PM
Last Post: Gribouillis
  How to open MIDI-file and get events in a list? philipbergwerf 7 5,022 May-29-2021, 08:24 AM
Last Post: j.crater
  Mido and virtual midi ports dore_m 2 4,636 Dec-27-2020, 06:02 AM
Last Post: dore_m
  MIDI FILES TEMPO - MIDO Tetsuo30 9 5,019 Sep-06-2020, 08:17 PM
Last Post: jefsummers
  Real time MIDI with python eythoralex 1 3,477 May-19-2020, 07:17 PM
Last Post: Larz60+
  Please help! Akai APC20 midi controller script versusliveact 0 2,144 Feb-14-2020, 05:37 AM
Last Post: versusliveact
  Using MIDI from Python on Windows 7 PythonAndMIDIUser 3 3,452 Jun-16-2018, 06:20 AM
Last Post: buran
  error getting tracks from albums ozzyk 7 4,572 Nov-22-2017, 07:33 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020