Найти - Пользователи
Полная версия: Убрать буквы из каждого элемента массива.
Начало » Python для новичков » Убрать буквы из каждого элемента массива.
1 2
Lainelir
 [/from mido import Message, MidiFile, MidiTrack
import re
import itertools
y = []
messages = []
mid = MidiFile('Kovet.mid')
for i, track in enumerate(mid.tracks):
    for msg in track:
        y.append(msg)
print(y)] 
>>>[<meta message midi_port port=0 time=0>, <message sysex data=(126,127,9,1) time=0>, <meta message midi_port port=0 time=0>, <meta message time_signature numerator=4 denominator=4 clocks_per_click=24 notated_32nd_notes_per_beat=8 time=0>,.... и т.д.]
FishHook
 for i, track in enumerate(mid.tracks):
    for msg in track:
        y.append(msg)
теперь объясните зачем enumerate и зачем нужно i если не используетрся
Lainelir
Суть в том что mido из миди файла создает уникальный массив он выглядит примерно так
Как в таком массиве убрать все кроме чисел?

 [/[<meta message midi_port port=0 time=0>, <message sysex data=(126,127,9,1) time=0>, <meta message midi_port port=0 time=0>, <meta message time_signature numerator=4 denominator=4 clocks_per_click=24 notated_32nd_notes_per_beat=8 time=0>, <meta message key_signature key='C' time=0>, <meta message set_tempo tempo=329670 time=0>, <meta message marker text=' 1'  channel=9 note=53 velocity=44 time=92>, <message note_on channel=9 note=53 velocity=0 time=28>, ... ... ... , <message note_on channel=13 note=84 velocity=100 time=45816>, <message note_on channel=13 note=84 velocity=0 time=239>, <message note_on channel=13 note=84 velocity=100 time=22081>, <message note_on channel=13 note=84 velocity=0 time=239>, <meta message end_of_track time=0>]
]
Vintets
Так это объекты, а не строки. Зачем же вводить в заблуждение.
Наверно по типу объекта определять где ноты и по полям доставать значения.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB