total_keys = list(get_total_keys(midi_list)) duration_keys = list(duration_keys)
时间: 2024-03-29 19:42:18 浏览: 9
这看起来像是 Python 代码。第一行代码中,`midi_list` 应该是一个列表,`get_total_keys` 是一个函数,它返回一个包含所有音乐键的列表。这个列表被传递给 `list()` 函数,以使其成为一个 Python 列表。第二行代码中,`duration_keys` 应该是另一个列表,其中包含一些持续时间键。这个列表也被传递给 `list()` 函数,以使其成为一个 Python 列表。
相关问题
def get_total_keys(_midi_list): _total_keys = set() for _press_time_dict in _midi_list: for step in _press_time_dict.values(): for item in step: _total_keys.add(item[0]) return _total_keys
这段代码的作用是计算midi文件中共使用了哪些按键。输入参数_midi_list是一个列表,列表中的每个元素都是一个按键按下的时间和时值的字典,每个字典的key为按键按下的时间,value为一个列表,其中每个元素为一个按键和对应的时值。函数使用嵌套的循环遍历每个字典中的所有按键,将这些按键存储在一个set集合_total_keys中,并返回该集合。
def get_total_keys(_midi_list):#遍历字典中的所有按键来看midi中用了哪些按键 _total_keys = set() for _press_time_dict in _midi_list: for step in _press_time_dict.values(): for item in step: _total_keys.add(item[0]) #将按键和对应的时值列表中的按键取出来,添加到_total_keys中 return _total_keys
这段代码定义了一个名为 `get_total_keys` 的函数,该函数接受一个 `_midi_list` 参数,该参数预计是一个包含多个 MIDI 文件信息的列表。函数使用 `_total_keys` 集合来存储所有在 MIDI 文件中出现的按键。然后,函数遍历 `_midi_list` 中的每个 MIDI 文件,并使用 `values()` 函数来获取每个文件中的所有按键。对于每个按键,函数将其添加到 `_total_keys` 集合中。最后,函数返回 `_total_keys` 集合,其中包含所有 MIDI 文件中出现过的按键。
相关推荐
![dat](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)