简体   繁体   English

music21:如何同时将和弦附加到流中?

[英]music21: How to append a chord to a stream simultaneously?

I have a stream object with notes (pitch and duration).我有一个带有音符(音高和持续时间)的流对象。 I want to add chords to -for example - the first note of each 4 times.我想将和弦添加到 - 例如 - 每 4 次的第一个音符。 But I want them to sound at the same time.但我希望它们同时发声。

The problem is that the only related stuff I found was how to append a chord to a stream but sequentially.问题是我发现的唯一相关内容是如何将和弦附加到流中,但按顺序。

So... Any suggestions?所以......有什么建议吗?

If you want to add additional pitches into existing notes, use the stream.Stream.insertIntoNoteOrChord method:如果您想在现有音符中添加额外的音高,请使用stream.Stream.insertIntoNoteOrChord方法:

http://web.mit.edu/music21/doc/moduleReference/moduleStream.html#music21.stream.Stream.insertIntoNoteOrChord http://web.mit.edu/music21/doc/moduleReference/moduleStream.html#music21.stream.Stream.insertIntoNoteOrChord

For instance:例如:

s = stream.Stream()
n = note.Note('C4') # qtr note default
s.append(n)

c = chord.Chord('E4 G4') # qtr
s.insertIntoNoteOrChord(0.0, c)
s.show('t')
{0.0} <music21.chord.Chord C4 E4 G4>

If you need to do something more complex, then I suggest just inserting all of the notes and chords to wherever you want them to be, and then running .chordify() on the Stream to make everything work.如果您需要做一些更复杂的事情,那么我建议您将所有音符和和弦插入到您想要的任何位置,然后在 Stream 上运行.chordify()以使一切正常。

A third option is to use different stream.Voice() objects for the different layers.第三种选择是为不同的层使用不同的stream.Voice()对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM