Skip to content

mxm, IT's mad science

Sections
Personal tools
You are here: Home » Products » Open Source » Python Midi Package » Ops ...
Downloads
You can download mxm products here.

Due to it's technical and international nature, this section is in english.

Max M Has a blog too.

og er glad for mad

 

Comment

Above in this comment thread: Python Midi Package » Notes ! » Maybe this help you ...

Ops ...

Posted by Anonymous User at 2004-12-28 11:41 AM
Sorry, the indetation is missing ...
I'll try a 'pre' tag ...
<pre>
def note2hex(note):
"""'note': is a string: 'f#' or a tuple or list: ('f#', -1),
the number indicates the octave (0 -> middle 'C')
If there is not number ('note' is a string), we assume
middle C"""
_note = ()
if type(note) == types.StringType:
_note = (note, 0)
else:
_note = note
n = _note[0].lower()
if n == 'c':
nh = 0x3C
elif n == 'c#':
nh = 0x3D
# ... more elif ....
return nh + _note[1]*0x0C # 0x0C -> 12 Semitones
</pre>

Dodgy Source

Posted by Anonymous User at 2006-02-11 05:51 AM
All those elif statements look bad.
Does Python support Switch?