Get variables from midi-events with the pyhton-midi library
up vote
0
down vote
favorite
I use the python-midi library to read a midi file into a list.
variable = midi.read_midifile(source)
The entries look like those:
midi.NoteOffEvent(tick=2, channel=10, data=[48, 98]),
midi.NoteOnEvent(tick=46, channel=10, data=[48, 100]),
midi.NoteOffEvent(tick=12, channel=10, data=[48, 100]),
midi.NoteOnEvent(tick=36, channel=10, data=[48, 91]),
midi.NoteOffEvent(tick=14, channel=10, data=[48, 91]),
midi.NoteOnEvent(tick=34, channel=10, data=[48, 122]),
Now I'd like to get the parameters of those Events but I don't know how to do that. I want to count all ticks, get all different channels and also read the data (so the note and the velocity). I looked into the Github-Repository but I did not find the answer to my question. link to repository: https://github.com/vishnubob/python-midi
Could it be that pyhton-midi is not really made for reading and manipulating midi-files?
python python-2.7 midi
add a comment |
up vote
0
down vote
favorite
I use the python-midi library to read a midi file into a list.
variable = midi.read_midifile(source)
The entries look like those:
midi.NoteOffEvent(tick=2, channel=10, data=[48, 98]),
midi.NoteOnEvent(tick=46, channel=10, data=[48, 100]),
midi.NoteOffEvent(tick=12, channel=10, data=[48, 100]),
midi.NoteOnEvent(tick=36, channel=10, data=[48, 91]),
midi.NoteOffEvent(tick=14, channel=10, data=[48, 91]),
midi.NoteOnEvent(tick=34, channel=10, data=[48, 122]),
Now I'd like to get the parameters of those Events but I don't know how to do that. I want to count all ticks, get all different channels and also read the data (so the note and the velocity). I looked into the Github-Repository but I did not find the answer to my question. link to repository: https://github.com/vishnubob/python-midi
Could it be that pyhton-midi is not really made for reading and manipulating midi-files?
python python-2.7 midi
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I use the python-midi library to read a midi file into a list.
variable = midi.read_midifile(source)
The entries look like those:
midi.NoteOffEvent(tick=2, channel=10, data=[48, 98]),
midi.NoteOnEvent(tick=46, channel=10, data=[48, 100]),
midi.NoteOffEvent(tick=12, channel=10, data=[48, 100]),
midi.NoteOnEvent(tick=36, channel=10, data=[48, 91]),
midi.NoteOffEvent(tick=14, channel=10, data=[48, 91]),
midi.NoteOnEvent(tick=34, channel=10, data=[48, 122]),
Now I'd like to get the parameters of those Events but I don't know how to do that. I want to count all ticks, get all different channels and also read the data (so the note and the velocity). I looked into the Github-Repository but I did not find the answer to my question. link to repository: https://github.com/vishnubob/python-midi
Could it be that pyhton-midi is not really made for reading and manipulating midi-files?
python python-2.7 midi
I use the python-midi library to read a midi file into a list.
variable = midi.read_midifile(source)
The entries look like those:
midi.NoteOffEvent(tick=2, channel=10, data=[48, 98]),
midi.NoteOnEvent(tick=46, channel=10, data=[48, 100]),
midi.NoteOffEvent(tick=12, channel=10, data=[48, 100]),
midi.NoteOnEvent(tick=36, channel=10, data=[48, 91]),
midi.NoteOffEvent(tick=14, channel=10, data=[48, 91]),
midi.NoteOnEvent(tick=34, channel=10, data=[48, 122]),
Now I'd like to get the parameters of those Events but I don't know how to do that. I want to count all ticks, get all different channels and also read the data (so the note and the velocity). I looked into the Github-Repository but I did not find the answer to my question. link to repository: https://github.com/vishnubob/python-midi
Could it be that pyhton-midi is not really made for reading and manipulating midi-files?
python python-2.7 midi
python python-2.7 midi
edited Nov 10 at 12:58
asked Nov 10 at 12:36
Stefan
118110
118110
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
I don't know anything about the python-midi library but I'm guessing from the source code that read_midifile()
method returns a Pattern object. The Pattern object contains a list of events.
Each event will contain a tick
, channel
and data
property.
I'm guessing you can slice a Pattern object like a list, so you should be able to do this:
pattern = midi.read_midifile(source)
print pattern[0].tick
This will select the first event in the Pattern and print its tick property.
You could then count the ticks by doing something like:
pattern = midi.read_midifile(source)
tick_count = 0
# a unique list
channels = set()
for event in pattern:
tick_count += event.tick
channels.add(event.channel)
If you ever need to know what's in an object, you can always use the dir()
function. E.g.
print dir(event)
Good luck with your learning. Keep aiming high!
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
I don't know anything about the python-midi library but I'm guessing from the source code that read_midifile()
method returns a Pattern object. The Pattern object contains a list of events.
Each event will contain a tick
, channel
and data
property.
I'm guessing you can slice a Pattern object like a list, so you should be able to do this:
pattern = midi.read_midifile(source)
print pattern[0].tick
This will select the first event in the Pattern and print its tick property.
You could then count the ticks by doing something like:
pattern = midi.read_midifile(source)
tick_count = 0
# a unique list
channels = set()
for event in pattern:
tick_count += event.tick
channels.add(event.channel)
If you ever need to know what's in an object, you can always use the dir()
function. E.g.
print dir(event)
Good luck with your learning. Keep aiming high!
add a comment |
up vote
1
down vote
accepted
I don't know anything about the python-midi library but I'm guessing from the source code that read_midifile()
method returns a Pattern object. The Pattern object contains a list of events.
Each event will contain a tick
, channel
and data
property.
I'm guessing you can slice a Pattern object like a list, so you should be able to do this:
pattern = midi.read_midifile(source)
print pattern[0].tick
This will select the first event in the Pattern and print its tick property.
You could then count the ticks by doing something like:
pattern = midi.read_midifile(source)
tick_count = 0
# a unique list
channels = set()
for event in pattern:
tick_count += event.tick
channels.add(event.channel)
If you ever need to know what's in an object, you can always use the dir()
function. E.g.
print dir(event)
Good luck with your learning. Keep aiming high!
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
I don't know anything about the python-midi library but I'm guessing from the source code that read_midifile()
method returns a Pattern object. The Pattern object contains a list of events.
Each event will contain a tick
, channel
and data
property.
I'm guessing you can slice a Pattern object like a list, so you should be able to do this:
pattern = midi.read_midifile(source)
print pattern[0].tick
This will select the first event in the Pattern and print its tick property.
You could then count the ticks by doing something like:
pattern = midi.read_midifile(source)
tick_count = 0
# a unique list
channels = set()
for event in pattern:
tick_count += event.tick
channels.add(event.channel)
If you ever need to know what's in an object, you can always use the dir()
function. E.g.
print dir(event)
Good luck with your learning. Keep aiming high!
I don't know anything about the python-midi library but I'm guessing from the source code that read_midifile()
method returns a Pattern object. The Pattern object contains a list of events.
Each event will contain a tick
, channel
and data
property.
I'm guessing you can slice a Pattern object like a list, so you should be able to do this:
pattern = midi.read_midifile(source)
print pattern[0].tick
This will select the first event in the Pattern and print its tick property.
You could then count the ticks by doing something like:
pattern = midi.read_midifile(source)
tick_count = 0
# a unique list
channels = set()
for event in pattern:
tick_count += event.tick
channels.add(event.channel)
If you ever need to know what's in an object, you can always use the dir()
function. E.g.
print dir(event)
Good luck with your learning. Keep aiming high!
edited Nov 10 at 13:16
answered Nov 10 at 13:10
Alastair McCormack
14.6k33859
14.6k33859
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53239018%2fget-variables-from-midi-events-with-the-pyhton-midi-library%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password