• Stars
    star
    237
  • Rank 169,885 (Top 4 %)
  • Language
    Python
  • License
    MIT License
  • Created over 13 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Python music library

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.
>>> import melopy
>>> melopy.major_scale('C5')
['C5', 'D5', 'E5', 'F5', 'G5', 'A5', 'B5']
>>>

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/melopy_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'

More Repositories

1

98.css

A design system for building faithful recreations of old UIs
CSS
9,080
star
2

tota11y

an accessibility (a11y) visualization toolkit
JavaScript
5,042
star
3

cleaver

30-second slideshows for hackers
JavaScript
3,990
star
4

isomer

Simple isometric graphics library for HTML5 canvas
JavaScript
2,879
star
5

dynamo.js

Cycles through bits of text in place
JavaScript
624
star
6

rubycards

Ruby playing cards library
Ruby
149
star
7

deepdive

deepdive
TypeScript
109
star
8

uptodate

Keep your timestamps up to date
JavaScript
88
star
9

ocaml-data-structures

Some data structures and algorithms written in OCaml
OCaml
68
star
10

notes

Static site generator from a Notion DB
JavaScript
64
star
11

tinman

A tiny static-ready blog engine based on the toto library
JavaScript
34
star
12

magic-editor

LLM-powered writing experiments
TypeScript
33
star
13

hashart

an experiment in turing SHA-256 hashes into pixels
JavaScript
28
star
14

alock

Arbitrary locking mechanism for asynchronous operations
JavaScript
28
star
15

compiler.lean

A formally verified compiler for a simple language with numbers and sums
Lean
25
star
16

ocaml-web-framework

An HTTP server and framework written from scratch in OCaml
OCaml
25
star
17

twitter

See whatโ€™s happening in the world right now
24
star
18

magic-hotline

A web server which generates its HTML using ChatGPT, using only the URL
JavaScript
22
star
19

programthis

Solutions for the discussions on http://programthis.net
C
21
star
20

98.css-badges

badges for 98.css
JavaScript
20
star
21

jordanscales.com

My homepage
HTML
17
star
22

scheme-to-js

a scheme->js compiler written in scheme
Scheme
17
star
23

lispjs

Let's compile Lisp into JavaScript using JavaScript
JavaScript
17
star
24

thatjdanisso.cool

My blog
JavaScript
15
star
25

reactme

a little server to share react components
JavaScript
15
star
26

oeis

On-Line Encyclopedia of Integer Sequences gem
Ruby
14
star
27

jscal.es

source code for my blog, jscal.es
Ruby
13
star
28

away-message

AOL Instant Messenger "Away Message" simulator
TypeScript
11
star
29

reactive-js

How to invent reactive JavaScript
JavaScript
11
star
30

topological-sort

An implementation of Kahn's algorithm for topological sorting
JavaScript
11
star
31

fizzbuzz-polyglot

An experiment in writing FizzBuzz in every language, each with its own Docker container
Lua
11
star
32

notion-automations

automating notion in various ways
JavaScript
10
star
33

notion-mailboxes

What if notion blocks had email?
JavaScript
9
star
34

wordle.ml

Cheating at the game Wordle with OCaml
OCaml
8
star
35

nodeschool

My solutions for nodeschool.io
JavaScript
7
star
36

chessnet

lichess games over telnet
JavaScript
7
star
37

j-by-example

Some programs to learn the J programming language
J
6
star
38

friend-ratings

My 2-hour personal jam project. Amazon ratings for your friends.
Ruby
6
star
39

tileswap

Processing code to rearrange images to draw other images
HTML
6
star
40

ilictronix

The new ilictronix.com
Ruby
6
star
41

cleaver-retro

A dark retro theme for cleaver
CSS
6
star
42

lambda

playing around with the lambda calculus
OCaml
6
star
43

haskell-basic

A TinyBASIC interpreter written in Haskell
Haskell
5
star
44

try-j

J
5
star
45

melodica

a fun way to interact with the WebAudio API
JavaScript
5
star
46

j

Some code examples for the J programming language
J
5
star
47

try-ocaml

OCaml
5
star
48

curta

Simulator for a Curta Type I mechanical calculator
JavaScript
5
star
49

bs-redux-example

An experiment in writing Redux reducers using OCaml
JavaScript
5
star
50

wikidata-family-tree

Ancestry on wikidata
JavaScript
4
star
51

notion-script-blocks

script blocks in notion
JavaScript
4
star
52

gameoflife-factory

a webapp to make game of life GIFs
JavaScript
4
star
53

parser.ml

"Functional Pearls" parsing in OCaml
OCaml
4
star
54

bismuth

An experimental Scheme
OCaml
4
star
55

code

This is my code.
Python
4
star
56

scheme-in-48-hours

My code for the "Write Yourself a Scheme in 48 Hours" eBook โ€“ http://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_Hours
Haskell
4
star
57

ocaml-micro

An experiment in running zeit/micro using ocaml + bucklescript
OCaml
4
star
58

artfile-web

ArtFile.bin extractor
TypeScript
4
star
59

Billiards.sb

Making a billiards game with Microsoft SmallBasic - http://smallbasic.com/
3
star
60

collatz.now.sh

generating SVGs from Collatz sequences
OCaml
3
star
61

notion-for-each-row

For each row in a Notion database, run a JavaScript function
JavaScript
3
star
62

board-next

Chess boards as a service using pgn-to-svg
TypeScript
3
star
63

ocaml-rationals

Rational numbers in OCaml
OCaml
3
star
64

32x32

JavaScript
3
star
65

murray

A chrome extension to make Bill Murray pop up in your Facebook threads (rarely)
JavaScript
3
star
66

stackjs

Playing around with function composition and stack-based languages
JavaScript
3
star
67

basic2020

BASIC 2020
JavaScript
3
star
68

gameoflife-3d

JavaScript
2
star
69

wordart

2
star
70

trackd

My entry for the 2014 Static Showdown
JavaScript
2
star
71

nim

The game of nim running over telnet
JavaScript
2
star
72

ocaml-calculator-game

Calculator: The Game solver
OCaml
2
star
73

tabindex

tab index visualization tool
JavaScript
2
star
74

word-by-word

Creating a story one word at a time.
JavaScript
2
star
75

bucklescript-vercel-example

OCaml (Bucklescript) + Vercel
Standard ML
2
star
76

99problems

I got 99 problems and haskell is a few of them.
Haskell
2
star
77

jupyter-notebooks

Jupyter Notebook
2
star
78

cs370-team-programming

CS370 Creative Problem Solving and Team Programming
C
2
star
79

adventofcode

Solutions for http://adventofcode.com/
Racket
2
star
80

ocaml-tictactoe

Playing around with some OCaml + Bucklescript + Express + Socket.io
OCaml
2
star
81

markov.rb

Simple Markov generator to produce realistic-looking names.
JavaScript
2
star
82

pgn-to-svg

Generates an SVG from PGN
TypeScript
1
star
83

factor-docker

Learning what this Docker thing is by way of a Factor web server
Factor
1
star
84

audio-graphing

Graph plotting questions without the graphs
JavaScript
1
star
85

picross

Interactive Picross element to experiment with React + Redux + redux-devtools
JavaScript
1
star
86

bismuth-ui

an experiment in structured editing
JavaScript
1
star
87

mockingbird.lean

Solutions to "To Mock a Mockingbird" using the Lean theorem prover
Lean
1
star
88

factor-work

Factor
1
star
89

notionml

OCaml
1
star
90

sabriel

Debrief tool
JavaScript
1
star
91

nodemorse

Real-time telegraph simulator written in node.js & coffeescript
CoffeeScript
1
star
92

notion-augment

Augment a Notion database on command
JavaScript
1
star
93

getxword

Fetches the NYTimes Crossword
Shell
1
star
94

combinatorial-games

An exploration of evaluating the results of games without chance (Nim, Tic-Tac-Toe) under perfect play.
OCaml
1
star
95

LightsOut

Lights Out! using JavaScript & HTML5 Canvas
JavaScript
1
star
96

rosalind.bqn

rosalind.info
1
star
97

99-ocaml-problems

https://ocaml.org/learn/tutorials/99problems.html
OCaml
1
star
98

recursion-lab

JavaScript
1
star
99

pixel

JavaScript
1
star
100

akari-editor

Akari puzzle editor to generate playable "Light Up" puzzles from Simon Tatham's collection
CSS
1
star