Is this supposed to play on my computer? I can't get the PMIDI module to work. I can write a code and it doesn't show and error, but I can't hear anything. I'm sure the codes are well written(mostly because I've used examples from other places) so does anyone know why this happens? I'm using Windows XP and yes, my speakers are on and they work.
# PMIDI is another excellent sound module by Peter Parente, author of pyTTS
# download (self-installer): PMIDI-1.1.win32-py2.4.exe
# free from: http://sourceforge.net/project/showfiles.php?group_id=65529
#
# named instruments and drums are in ..\PMIDI\Constants.py
# this test plays up and down the scales with optional drums and a sexy ending
# the notes in this example are given as a string then turned into a list
#
# tested with Python24 vegaseat 18nov2005
from PMIDI import *
from time import sleep
# setup ...
seq = Sequencer()
song = seq.NewSong()
t = song.NewVoice()
t.SetInstrumentByName('French Horn')
m = t.NewMeasure()
# contains note/octave pairs
str1 = "C4D4E4F4G4A4B4C5C5B4A4G4F4E4D4C4"
noteList = list(str1)
print noteList # test the list
# NewNote(beat,duration,note,octave) # pitch is note, octave
# NewMeasure() by default numbers itself each time it is called, starts with 0
dur = 6 # duration of that note in beats
beat = 0 # beat 0 to 63, can not exceed 64 beats per measure here
diff = 8 # use 1 to 9 (fast to slow)
k = 1
for val in noteList:
k += 1
# pick note and octave alternately
if k % 2 == 0:
note = val
# print note # test
else:
octave = int(val)
# print beat, dur, note, octave # test
m.NewNote(beat, dur, note, octave)
beat += diff
if beat > 63:
m = t.NewMeasure() # next measure
beat = 0
# optional, first part accompanied with drums ...
t = song.NewVoice(is_drum = True)
m = t.NewMeasure() # would start with drum measure 0
# NewHit(beat,duration,drum_type)
m.NewHit(0, 8, 'Bass Drum 1')
m.NewHit(8, 8, 'Pedal Hi-Hat')
m.NewHit(16, 8, 'Bass Drum 1')
m.NewHit(24, 8, 'Pedal Hi-Hat')
m.NewHit(32, 8, 'Bass Drum 1')
m.NewHit(40, 8, 'Pedal Hi-Hat')
m.NewHit(48, 8, 'Bass Drum 1')
m.NewHit(56, 8, 'Pedal Hi-Hat')
# optional closing sound at end of measure 1 ...
t = song.NewVoice()
t.SetInstrumentByName('Tinkle bell')
m = t.NewMeasure(1)
for k in range(8):
down = ['C', 'B', 'A#', 'A', 'G#', 'G', 'F#', 'F'] # go down the scale
m.NewNote(56 + k, 1, down[k], 8)
seq.Play()
sleep(7) # give it enough time to play out
seq.Close()
This is one of the codes I've tried to run. It is not mine, it's from vegaseat in the code snippets section. Any help on why it doesn't play would be apreciated.