# Path: camp/core/note.py
# def note(st):
#     """
#     note('Db3') -> Note(name='Db', octave=3)
#     """
#     if type(st) == Note:
#         return st
#     match = NOTE_SHORTCUT_REGEX.match(st)
#     if not match:
#         raise Exception("cannot form note from: %s" % st)
#     name = match.group(1)
#     octave = match.group(2)
#     if octave == '' or octave is None:
#         octave = 4
#     octave = int(octave)
#     return Note(name=name, octave=octave)
# 
# Path: camp/core/chord.py
# def chord(input):
#     """
#     Shortcut: chord(['C5', 'E5', 'G5') -> Chord object
#     Shortcut: chord('C5 dim') -> Chord object
#     """
#     if type(input) == list:
#         notes = [ note(n) for n in input ]
#         return Chord(notes)
#     else:
#         tokens = input.split()
#         assert len(tokens) == 2, "invalid chord expression: %s" % input
#         return Chord(root=note(tokens[0]), typ=tokens[1])
# 
# Path: camp/core/scale.py
# class Scale(object):
# 
#     def __init__(self, root=None, typ=None):
# 
#         """
#         Constructs a scale:
# 
# 	scale = Scale(root='C4', typ='major')
#         """
# 
#         assert root is not None
#         assert typ is not None
#         if isinstance(root, str):
#             root = note(root)
#         self.root = root
#         self.typ = typ
# 
#     def generate(self, length=None):
#         """
#         Allows traversal of a scale in a forward direction.
#         Example:
#         for note in scale.generate(length=2):
#            print note
#         """
# 
# 
#         assert length is not None
# 
#         typ = SCALE_ALIASES.get(self.typ, self.typ)
#         scale_data = SCALE_TYPES[typ][:]
# 
#         octave_shift = 0
#         index = 0
#         while (length is None or length > 0):
# 
#             if index == len(scale_data):
#                index = 0
#                octave_shift = octave_shift + 1
#             result = self.root.transpose(degrees=scale_data[index], octaves=octave_shift)
#             yield(result)
#             index = index + 1
#             if length is not None:
#                 length = length - 1
# 
#     def __eq__(self, other):
#         """
#         Scales are equal if they are the ... same scale
#         """
#         if other is None:
#             return False
#         return self.root == other.root and self.typ == other.typ
# 
#     def short_name(self):
#         return "%s %s" % (self.root.short_name(), self.typ)
# 
#     def __repr__(self):
#         return "Scale<%s>" % self.short_name()
# 
# def scale(input):
#     """
#     Shortcut: scale(['C major') -> Scale object
#     """
#     (root, typ) = input.split()
#     return Scale(root=note(root), typ=typ)


from camp.core.note import note
from camp.core.chord import chord
from camp.core.scale import Scale, scale
http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""


class TestScale(object):

   def test_basics(self):

       scale1 = Scale(root=note('C4'), typ='major')
       scale2 = scale('C4 major')
       assert scale1 == scale2
       assert str(scale1) == 'Scale<C4 major>'

   def _scale_test(self, expression=None, expected=None, length=None):
       if isinstance(expected, str):
           expected = expected.split()
       assert length is not None
       scale1 = scale(expression)
       results = [ note for note in scale1.generate(length=length) ]
       print("generating: %s for %s" % (expression, length))
       assert chord(results) == chord(expected)

   def test_c_major(self):


# Path: camp/core/note.py
# def note(st):
#     """
#     note('Db3') -> Note(name='Db', octave=3)
#     """
#     if type(st) == Note:
#         return st
#     match = NOTE_SHORTCUT_REGEX.match(st)
#     if not match:
#         raise Exception("cannot form note from: %s" % st)
#     name = match.group(1)
#     octave = match.group(2)
#     if octave == '' or octave is None:
#         octave = 4
#     octave = int(octave)
#     return Note(name=name, octave=octave)
# 
# Path: camp/core/chord.py
# def chord(input):
#     """
#     Shortcut: chord(['C5', 'E5', 'G5') -> Chord object
#     Shortcut: chord('C5 dim') -> Chord object
#     """
#     if type(input) == list:
#         notes = [ note(n) for n in input ]
#         return Chord(notes)
#     else:
#         tokens = input.split()
#         assert len(tokens) == 2, "invalid chord expression: %s" % input
#         return Chord(root=note(tokens[0]), typ=tokens[1])
# 
# Path: camp/core/scale.py
# class Scale(object):
# 
#     def __init__(self, root=None, typ=None):
# 
#         """
#         Constructs a scale:
# 
# 	scale = Scale(root='C4', typ='major')
#         """
# 
#         assert root is not None
#         assert typ is not None
#         if isinstance(root, str):
#             root = note(root)
#         self.root = root
#         self.typ = typ
# 
#     def generate(self, length=None):
#         """
#         Allows traversal of a scale in a forward direction.
#         Example:
#         for note in scale.generate(length=2):
#            print note
#         """
# 
# 
#         assert length is not None
# 
#         typ = SCALE_ALIASES.get(self.typ, self.typ)
#         scale_data = SCALE_TYPES[typ][:]
# 
#         octave_shift = 0
#         index = 0
#         while (length is None or length > 0):
# 
#             if index == len(scale_data):
#                index = 0
#                octave_shift = octave_shift + 1
#             result = self.root.transpose(degrees=scale_data[index], octaves=octave_shift)
#             yield(result)
#             index = index + 1
#             if length is not None:
#                 length = length - 1
# 
#     def __eq__(self, other):
#         """
#         Scales are equal if they are the ... same scale
#         """
#         if other is None:
#             return False
#         return self.root == other.root and self.typ == other.typ
# 
#     def short_name(self):
#         return "%s %s" % (self.root.short_name(), self.typ)
# 
#     def __repr__(self):
#         return "Scale<%s>" % self.short_name()
# 
# def scale(input):
#     """
#     Shortcut: scale(['C major') -> Scale object
#     """
#     (root, typ) = input.split()
#     return Scale(root=note(root), typ=typ)


# Path: tests/scale.py
from camp.core.note import note
from camp.core.chord import chord
from camp.core.scale import Scale, scale

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""


class TestScale(object):

   def test_basics(self):

       scale1 = Scale(root=note('C4'), typ='major')
       scale2 = scale('C4 major')
       assert scale1 == scale2
       assert str(scale1) == 'Scale<C4 major>'

   def _scale_test(self, expression=None, expected=None, length=None):
       if isinstance(expected, str):
           expected = expected.split()
       assert length is not None
       scale1 = scale(expression)
       results = [ note for note in scale1.generate(length=length) ]
       print("generating: %s for %s" % (expression, length))
       assert chord(results) == chord(expected)

   def test_c_major(self):


       scale1 = scale('C4 major')