User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Python section within the Software Development category of DaniWeb, a massive community of 423,435 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,733 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Python advertiser: Programming Forums
Views: 296 | Replies: 2
Reply
Join Date: Jun 2008
Posts: 4
Reputation: caribedude is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
caribedude caribedude is offline Offline
Newbie Poster

Can't hear PMIDI

  #1  
Jun 2nd, 2008
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.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2006
Posts: 562
Reputation: jrcagle is on a distinguished road 
Rep Power: 4
Solved Threads: 72
jrcagle jrcagle is offline Offline
Posting Pro

Re: Can't hear PMIDI

  #2  
Jun 3rd, 2008
Is there a chance that the sound is playing on the wrong sound device? I have two sound cards (built in and recording equipment), and sometimes my software gets confused.

Jeff
Reply With Quote  
Join Date: Oct 2004
Location: Mojave Desert
Posts: 2,466
Reputation: vegaseat will become famous soon enough vegaseat will become famous soon enough 
Rep Power: 10
Solved Threads: 176
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
Kickbutt Moderator

Re: Can't hear PMIDI

  #3  
Jun 8th, 2008
Just installed PMIDI-1.1.win32-py2.5.exe on my XP machine running under Python25 and it works just fine with the sample code given.
May 'the Google' be with you!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Python Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the Python Forum

All times are GMT -4. The time now is 2:20 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC