def test(): from music21 import instrument as j sc1 = stream.Score() # instruments = [Piccolo(), Glockenspiel(), 72, 69, 41, 27, 47, 1, 1, 1, 1, 34] instrument = [ j.Piccolo(), j.Xylophone(), j.Clarinet(), j.Oboe(), j.Violin(), j.ElectricGuitar(), j.Harp(), j.Piano(), j.Piano(), j.Piano(), j.Piano(), j.ElectricBass() ] instrumentOctave = [3, 2, 2, 2, 1, 1, 1, 2, 1, 0, -1, -2] for i in range(12): inst = instrument[i] if i < 9: inst.midiChannel = i else: inst.midiChannel = i + 1 part = addPart(instrument=inst) if instrumentOctave[i] != 0: part.transpose(12 * instrumentOctave[i], inPlace=True) sc1.insert(0, part) sc1.show()
def testFromSoundingPitch(self): ''' A score with mixed sounding and written parts. ''' m = stream.Measure([instrument.Clarinet(), note.Note('C')]) p1 = stream.Part(m) p1.atSoundingPitch = True p2 = stream.Part(stream.Measure([instrument.Bassoon(), note.Note()])) s = stream.Score([p1, p2]) self.assertEqual(s.atSoundingPitch, 'unknown') gex = GeneralObjectExporter(s) root = et_fromstring(gex.parse().decode('utf-8')) self.assertEqual(len(root.findall('.//transpose')), 1) self.assertEqual(root.find('.//step').text, 'D') s.atSoundingPitch = True gex = GeneralObjectExporter(s) root = et_fromstring(gex.parse().decode('utf-8')) self.assertEqual(len(root.findall('.//transpose')), 1) self.assertEqual(root.find('.//step').text, 'D')