在Python Music 21中通过其颜色找到笔记21
在Python中使用Music21,我需要选择所有红色的注释,以便我可以将它们更改为黑色,但是我似乎找不到一种方法来选择笔记以其颜色选择……有人有想法吗?
Using music21 in python, I need to select all the notes that are red so I can change them to black but I cannot seem to find a way to select notes by their color... Does anyone have an idea ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没有直接的功能可以按颜色搜索笔记。但是,您可以编写a
这使用Music21 V7语法来调用
recurse()。getElementsByClass(Note.generalNote)
- 如果您不使用v7.3,请务必确保升级。 (如果您在Python中更高级,则可以将参数编写为添加filter作为lambda函数)。there is no direct function to search for notes by color. However, you could write a Custom Filter to do what you want:
This uses music21 v7 syntax for calling
recurse().getElementsByClass(note.GeneralNote)
-- if you're not on v7.3 be sure to upgrade. (if you're more advanced in Python, you could write the parameter to addFilter as a lambda function).