diff --git a/README.md b/README.md index 8a6c596..4859d60 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,9 @@ $ python Python 2.7.2 (default, Jun 20 2012, 16:23:33) [GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin Type "help", "copyright", "credits" or "license" for more information. ->>> import melopy ->>> melopy.major_scale('C5') -['C5', 'D5', 'E5', 'F5', 'G5', 'A5', 'B5'] +>>> from melopy.scales import generateScale +>>> generateScale('major', 'c4') +['C4', 'D4', 'E4', 'F4', 'G4', 'A4', 'B4', 'C5'] >>> ``` @@ -39,7 +39,7 @@ For examples, check out the `examples` directory: To run the tests: - $ python tests/melopy_tests.py + $ python tests.py ### Organization diff --git a/README.txt b/README.txt index 69cbe61..54e7bfd 100644 --- a/README.txt +++ b/README.txt @@ -24,8 +24,8 @@ Load it Python 2.7.2 (default, Jun 20 2012, 16:23:33) [GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin Type "help", "copyright", "credits" or "license" for more information. - >>> import melopy - >>> melopy.major_scale('C5') + >>> from melopy.scales import generateScale + >>> generateScale('major', 'C5') ['C5', 'D5', 'E5', 'F5', 'G5', 'A5', 'B5'] >>> @@ -51,7 +51,7 @@ To run the tests: :: - $ python tests/melopy_tests.py + $ python tests.py Organization ============ diff --git a/melopy/chords.py b/melopy/chords.py index ff5b2f7..032ec94 100644 --- a/melopy/chords.py +++ b/melopy/chords.py @@ -1,8 +1,9 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -from utility import note_to_key, key_to_note, iterate -from exceptions import MelopyGenericError +from __future__ import absolute_import, division +from melopy.utility import note_to_key, key_to_note, iterate +from melopy.exceptions import MelopyGenericError CHORD_INTERVALS = { 'maj': [4,3], diff --git a/melopy/melopy.py b/melopy/melopy.py index 77020db..63c8e5d 100644 --- a/melopy/melopy.py +++ b/melopy/melopy.py @@ -1,11 +1,13 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- +from __future__ import division, absolute_import + import wave, struct, random, math import os, sys -from utility import * -from scales import * +from melopy.utility import * +from melopy.scales import * # same included wave functions # a function of frequency and tick diff --git a/melopy/scales.py b/melopy/scales.py index c18c11f..2a4cf09 100644 --- a/melopy/scales.py +++ b/melopy/scales.py @@ -1,8 +1,9 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -from utility import note_to_key, key_to_note, iterate -from exceptions import MelopyGenericError +from __future__ import absolute_import, division +from melopy.utility import note_to_key, key_to_note, iterate +from melopy.exceptions import MelopyGenericError SCALE_STEPS = { "major":[2,2,1,2,2,2,1], diff --git a/melopy/utility.py b/melopy/utility.py index e92e17b..2e43c73 100644 --- a/melopy/utility.py +++ b/melopy/utility.py @@ -1,8 +1,9 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- +from __future__ import division, absolute_import from math import log -from exceptions import MelopyGenericError, MelopyValueError +from melopy.exceptions import MelopyGenericError, MelopyValueError def key_to_frequency(key): """Returns the frequency of the note (key) keys from A0""" @@ -11,7 +12,7 @@ def key_to_frequency(key): def key_to_note(key, octaves=True): """Returns a string representing a note which is (key) keys from A0""" notes = ['a','a#','b','c','c#','d','d#','e','f','f#','g','g#'] - octave = (key + 8) / 12 + octave = (key + 8) // 12 note = notes[(key - 1) % 12] if octaves: diff --git a/tests/melopy_tests.py b/tests.py similarity index 98% rename from tests/melopy_tests.py rename to tests.py index bf6f1da..0477f25 100644 --- a/tests/melopy_tests.py +++ b/tests.py @@ -1,5 +1,6 @@ #!/usr/bin/env # -*- coding: utf-8 -*- +from __future__ import absolute_import, division, nested_scopes import unittest diff --git a/tests/__init__.py b/tests/__init__.py deleted file mode 100644 index 8e637f0..0000000 --- a/tests/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -# Licensed under The MIT License (MIT) -# See LICENSE file for more \ No newline at end of file