from

from scipy import interpolate

from

from operator import itemgetter

'c#'

'c'

NOTES = [ 'c' , 'c#' , 'd' , 'd#' , 'e' , 'f' , 'f#' , 'g' , 'g#' , 'a' , 'a#' , 'b' ]

self

def __init__ ( self , note , octave = 4 ) :

self

self . octave = octave

if

if isinstance ( note , int ) :

self

self . index = note

self

self . note = Note. NOTES [ note ]

self

self . note = note. strip ( ) . lower ( )

self

self

self . index = Note. NOTES . index ( self . note )

self

def transpose ( self , halfsteps ) :

self

octave_delta , note = divmod ( self . index + halfsteps , 12 )

self

return Note ( note , self . octave + octave_delta )

self

def frequency ( self ) :

self

base_frequency = 16.35159783128741 * 2.0 ** ( float ( self . index ) / 12.0 )

self

return base_frequency * ( 2.0 ** self . octave )

self

def __float__ ( self ) :

self

return self . frequency ( )

self

def __init__ ( self , root , intervals ) :

self

self . root = Note ( root. index , 0 )

self

self . intervals = intervals

self

def get ( self , index ) :

self

intervals = self . intervals

if

if index < 0 :

self

intervals = reversed ( self . intervals )

self

intervals = itertools . cycle ( self . intervals )

self

note = self . root

in

for

for i in xrange ( index ) :

next

note = note. transpose ( intervals. next ( ) )

self

def index ( self , note ) :

self

intervals = itertools . cycle ( self . intervals )

self

x = self . root

or

while

while x. octave != note. octave or x. note != note. note :

next

x = x. transpose ( intervals. next ( ) )

self

def transpose ( self , note , interval ) :