Skip to content

mxm, IT's mad science

Sections
Personal tools
You are here: Home » Products » Open Source » Python Midi Package » Notes !
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 !

Posted by Anonymous User at 2004-09-22 08:01 PM
Hello Nice work
how do i know wich note is note=0x41 ....
which note represents ,,,, there is any manual ou something so see all notes in Hex

thnx

It's defined in the midi standard

Posted by maxm at 2004-09-23 10:59 AM
I don't remember exactly, but afair middle c is 64. I believe I have it somewhere in the source.

Maybe this help you ...

Posted by Anonymous User at 2004-12-28 11:38 AM
I'm developing a program that uses the Midi module.
I've defined some helper functions for managing midi notes and hex numbers.
Try this:

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
elif n == 'db':
nh = 0x3D
elif n == 'd':
nh = 0x3E
elif n == 'd#':
nh = 0x3F
elif n == 'eb':
nh = 0x3F
elif n == 'e':
nh = 0x40
elif n == 'f':
nh = 0x41
elif n == 'f#':
nh = 0x42
elif n == 'gb':
nh = 0x42
elif n == 'g':
nh = 0x43
elif n == 'g#':
nh = 0x44
elif n == 'ab':
nh = 0x44
elif n == 'a':
nh = 0x45
elif n == 'a#':
nh = 0x46
elif n == 'bb':
nh = 0x46
elif n == 'b':
nh = 0x47
return nh + _note[1]*0x0C # 0x0C -> 12 Semitones

Another way to lookuo hex values for notes

Posted by Anonymous User at 2008-06-11 10:06 PM
def get(note, transpose=0):
"""
note is a string value (e.g. c#)
transpose is a signed integer that indicates
number of octaves to transpose up or down
"""
transpose = transpose * 0x0C
note = note.lower()
sharpMap = {
'db': 'c#',
'eb': 'd#',
'gb': 'f#',
'ab': 'g#',
'bb': 'g#'
}
noteMap = {
'c': 0x3C,
'c#': 0x3D,
'd': 0x3E,
'd#': 0x3F,
'e': 0x40,
'f': 0x41,
'f#': 0x42,
'g': 0x43,
'g#': 0x44,
'a': 0x45,
'a#': 0x46,
'b': 0x47
}

if note in noteMap.keys():
return noteMap[note] + transpose
elif note in sharpMap.keys():
return noteMap[sharpMap[note]] + transpose
else:
raise LookupError, "The note %s does not exist" % note

I think that this will help

Posted by Anonymous User at 2009-07-25 02:20 PM
Why not to set up some variables?
code:


# Some notes

c0 = 52
cis0= 53
d0 = 54
dis0= 55
e0 = 56
f0 = 57
fis0= 58
g0 = 59
gis0= 60
a0 = 61
ais0= 62
h0 = 63

c1 = 64
cis1= 65
d1 = 66
dis1= 67
e1 = 68
f1 = 69
fis1= 70
g1 = 71
gis1= 72
a1 = 73
ais1= 74
h1 = 75

c2 = 76
cis2= 77
d2 = 78
dis2= 79
e2 = 80
f2 = 81
fis2= 82
g2 = 83
gis2= 84
a2 = 85
ais2= 86
h2 = 87

c3 = 88
cis3= 89
d3 = 90
dis3= 91
e3 = 92
f3 = 93
fis3= 94
g3 = 95
gis3= 96
a3 = 97
ais3= 98
h3 = 99

c4 = 100
cis4= 101
d4 = 102
dis4= 103
e4 = 104
f4 = 105
fis4= 106
g4 = 107
gis4= 108
a4 = 109
ais4= 110
h4 = 111

{EOF}

And using this will look just like this:
midi.note_on(note=c1)
midi.note_on(note=e1)
midi.note_on(note=g1)

cheers