Code Monkey home page Code Monkey logo

melopy's Introduction

Melopy

http://jdan.github.io/Melopy

A python library for playing with sound.
by Jordan Scales and friends

Install it

You may need to use sudo for this to work.

$ pip install melopy

Load it

$ 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.
>>> from melopy.scales import generateScale
>>> generateScale('major', 'c4')
['C4', 'D4', 'E4', 'F4', 'G4', 'A4', 'B4', 'C5']
>>>

Development

To install locally:

$ git clone git://github.com/jdan/Melopy
$ cd Melopy
$ python setup.py install

For examples, check out the examples directory:

$ python examples/canon.py
$ python examples/parser.py entertainer < examples/scores/entertainer.mlp

To run the tests:

$ python tests.py

Organization

Melopy is broken down into 3 subcategories - melopy, scales, and utility.

  • melopy.py contains the Melopy class
    • this is used for creating a Melopy and adding notes to it, rendering, etc
  • scales.py contains methods for generating scales
    • for instance, if you want to store the C major scale in an array
  • utility.py contains methods for finding frequencies of notes, etc

melopy.py

>>> from melopy import Melopy
>>> m = Melopy('mysong')
>>> m.add_quarter_note('A4')
>>> m.add_quarter_note('C#5')
>>> m.add_quarter_note('E5')
>>> m.render()
[==================================================] 100%
Done

scales.py

  • chromatic_scale
  • harmonic_minor_scale
  • major_pentatonic_scale
  • major_scale
  • minor_scale
  • major_triad
  • minor_triad
  • melodic_minor_scale
  • minor_pentatonic_scale
>>> from melopy.scales import *
>>> major_scale('C4')
['C4', 'D4', 'E4', 'F4', 'G4', 'A4', 'B4']
>>> major_scale('C4','dict')
{0: 'C4', 1: 'D4', 2: 'E4', 3: 'F4', 4: 'G4', 5: 'A4', 6: 'B4'}
>>> major_scale('C4','tuple')
('C4', 'D4', 'E4', 'F4', 'G4', 'A4', 'B4')
>>> minor_scale('D#5')  # has some bugs
['D#5', 'F5', 'F#5', 'G#5', 'A#5', 'B5', 'C#6']
>>> major_triad('A4')
['A4', 'C#5', 'E5']
>>> major_triad('A4', 'tuple')
('A4', 'C#5', 'E5')

utility.py

  • key_to_frequency
  • key_to_note
  • note_to_frequency
  • note_to_key
  • frequency_to_key
  • frequency_to_note
>>> from melopy.utility import *
>>> key_to_frequency(49)
440.0
>>> note_to_frequency('A4')
440.0
>>> note_to_frequency('C5')
523.2511306011972
>>> note_to_key('Bb5')
62
>>> key_to_note(65)
'C#6'
>>> key_to_note(304) # even something stupid
'C26'
>>> frequency_to_key(660)
56
>>> frequency_to_note(660)
'E5'

melopy's People

Contributors

jdan avatar b1naryth1ef avatar asteriskman7 avatar scubbo avatar parent5446 avatar caoilteguiry avatar gal-leib avatar kylepreston avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.