123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- ARR_NOTE=["C","C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"]
- ARR_NOTE_LATIN=["Do","Do#", "Ré", "Ré#", "Mi", "Fa", "Fa#", "Sol", "Sol#", "La", "La#", "Si"]
- NOTES={
- "C" : 0,
- "C#" : 1,
- "Db" : 1,
- "D" : 2,
- "D#" : 3,
- "Eb" : 3,
- "E" : 4,
- "F" : 5,
- "F#" : 6,
- "Gb" : 6,
- "G" : 7,
- "G#" : 8,
- "Ab" : 8,
- "A" : 9,
- "A#" : 10,
- "Bb" : 10,
- "B" : 11
- }
- NOTES_LATIN={
- "Do" : 0,
- "Do#" : 1,
- "Réb" : 1,
- "Ré" : 2,
- "Ré#" : 3,
- "Mib" : 3,
- "Mi" : 4,
- "Fa" : 5,
- "Fa#" : 6,
- "Solb" : 6,
- "Sol" : 7,
- "Sol#" : 8,
- "Lab" : 8,
- "La" : 9,
- "La#" : 10,
- "Sib" : 10,
- "Si" : 11
- }
- __C0_START=12
- class NoteAngloSaxon:
- C = 0
- Cd = 1
- Db = 1
- D = 2
- Dd = 3
- Eb = 3
- E = 4
- F = 5
- Fd = 6
- Gb = 6
- G = 7
- Gd = 8
- Ab = 8
- A = 9
- Ad = 10
- Bb = 10
- B = 11
- class Note:
- @staticmethod
- def _parse(s, system):
- octave=4
- note=""
- i=0
- l=len(s)
- while i<l and s[i] in ("abcdefgABCDEFG#"):
- note+=s[i]
- i+=1
- while i<l and not s[i] in ("0123456789"): i+=1
- octave=int(s[i])
- note=note[0].upper()+note[1:]
- return 12+12*octave+system[note]
- @staticmethod
- def parse_latin(s):
- return Note._parse(s, NOTES_LATIN)
- @staticmethod
- def parse(s):
- return Note._parse(s, NOTES)
- @staticmethod
- def to_str(n):
- n-=12
- return ARR_NOTE[n%12]+str(int(n/12))
- @staticmethod
- def to_str_latin(n):
- n-=12
- return ARR_NOTE_LATIN[n%12]+str(int(n/12))
- @staticmethod
- def get_octave(n):
- n-=12
- return int(n/12)
- @staticmethod
- def get_note_str(n):
- n-=12
- return ARR_NOTE[n%12]
- @staticmethod
- def get_note(n):
- n-=12
- return n%12
- class Gamme:
- def __init__(self, range, length=12):
- self.range=range
- self.length=length
- MAJEUR=Gamme([])
- GAMME_CHROMATIQUE=[0,1,2,3,4,5,6,7,8,9,10,11]
- GAMME_MAJEUR=[NoteAngloSaxon.C, NoteAngloSaxon.D, NoteAngloSaxon.E, NoteAngloSaxon.F, NoteAngloSaxon.G,
- NoteAngloSaxon.A, NoteAngloSaxon.B]
- GAMME_MINEUR_NATURELLE=[NoteAngloSaxon.C, NoteAngloSaxon.D, NoteAngloSaxon.Eb, NoteAngloSaxon.F, NoteAngloSaxon.G,
- NoteAngloSaxon.Ab, NoteAngloSaxon.Bb]
- GAMME_MINEUR_HARMONIQUE=[NoteAngloSaxon.C, NoteAngloSaxon.D, NoteAngloSaxon.Eb, NoteAngloSaxon.F, NoteAngloSaxon.G,
- NoteAngloSaxon.Ab, NoteAngloSaxon.B]
- GAMME_MINEUR_MELODIQUE=[NoteAngloSaxon.C, NoteAngloSaxon.D, NoteAngloSaxon.Eb, NoteAngloSaxon.F, NoteAngloSaxon.G,
- NoteAngloSaxon.Ab, NoteAngloSaxon.B]
|