It's been a couple of weeks since I started reading the book "Making music with computers: creative programming in Python" and now i'm stucked while trying to play drum sounds with this library. I'm using Mit's music21 library, as the one proposed by the book didn't work for me (it's called simply "music"). This is a code example the book uses to play bass drum sound:
from music import *
drumPart = Part("Drums", 0, 9)
note = Note(ACOUSTIC_BASS_DRUM, QN) # a bass drum strike
drumPhrase = Phrase()
drumPhrase.addNote(note)
drumPart.addPhrase(drumPhrase)
Play.midi(drumPart)
I tried to do the same in music21 with a Hi Hat sound but no sound is played:
import music21
from music21 import note, stream, pitch, duration, instrument, tempo, chord
from music21.note import Note, Rest
from music21.chord import Chord
from music21 import midi
def createInstrument(instrument, midiChannel):
i = instrument
i.midiChannel = midiChannel
return i
n = Note("A2", type='quarter')
drumPart = stream.Part()
drumPart.insert(createInstrument(instrument.HiHatCymbal(), 9))
drumMeasure = stream.Measure()
drumMeasure.append(n)
drumPart.append(drumMeasure)
drumPart.show('midi')
Any advice would be really helpful, as there is practically no information on the web about this library except its webPage.
Thanks in advance, Julián!