3

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. 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?

VR_1312
  • 151
  • 1
  • 13

1 Answers1

2

If you want to add additional pitches into existing notes, use the stream.Stream.insertIntoNoteOrChord method:

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.

A third option is to use different stream.Voice() objects for the different layers.

  • Thanks. Finally I did something like the third option: used a Score instead of a Stream, and made one stream for the melody and another for the chords. insertNoteIntoNoteorChord would be useful for those who want to insert notes. But I wanted to insert chords in a melody and not vice versa. Anyway is a good option. – VR_1312 Apr 10 '16 at 00:35