Giter Site home page Giter Site logo

milton's Introduction

Algorithmic Composition Utilities

The aim of the Milton package is to provide a higher level, musically more expressive and abstract set of routines. It is meant to make expressing algorithmic music more intuitive and easy, by taking care of low-level MIDI implementation so that the composer can focus on his composition rather than following midi messages. This package is a work-in-progress and in active development. Your feedback is very welcome! :-)

Install

Run the command pip install milton to install Milton from Pypi.

Quick Start

# import the module
>>> import milton

# First initialize the module,
>>> milton.realtime.init()

# create a single note,
>>> c4 = milton.make_note("c4")

# and put it in a list and send it to the processor to play it.
>>> milton.proc([c4])

# Let us now define a second note with the key number 72, and specify it's starting time (onset) to be 1 second after the processor starts.
>>> c5 = milton.make_note(pch=72, onset=1)
>>> milton.proc([c4, c5])

# You should have heared both notes, played after each other.

# The full signature of the note function has the parameters:
# pch: the name of the note (a string) or the midi key number
# onset: is the ongoing time expressed in seconds, with respect to the process start time 0 (default is 0, which means now)
# dur: the duration of the note
# chnl: the midi channel to play the note on
# vel: the dynamic of the note

# Now we want to create an A minor chord with a duration of 2 seconds, 
# and play it 1/2 second after the processor starts,
>>> a_min = milton.make_chord(pchs=(69, 72, 76), onset=.5, dur=2)

# and send it to the processor to play it.
>>> milton.proc([a_min])

# Let us now give the processor a list of notes/chords to play:
# the chromatic scale starting from the middle c upwards.
>>> voice1 = [milton.make_note(pch=60+i, onset=i, dur=0.5) for i in range(12)]
>>> milton.proc([voice1])

# Playing polyphony is as easy as passing multiple lists of note/chords
# to the processor:
>>> voice2 = [milton.make_note(pch=48+i, onset=i+0.5, dur=0.5) for i in range(12)]
>>> voice3 = [milton.make_chord(pchs=[60+i, 60+i+4, 60+i+7], onset=i+0.2, dur=0.5) for i in range(12)]
>>> milton.proc([voice1, voice2, voice3])

# If you want to write a midi file to the disk instead of playing it back
# pass a path string as the second argument to the processor
>>> milton.proc([voice1, voice2, voice3], "/tmp/milton.mid")

milton's People

Contributors

teymuri avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

milton's Issues

Error when snyth is closed

When I just want to write to disk, cu still wants a synth to be opened (e.g. qsynth). This should be turned off when only writing and not playing!

Generator-based

Make proc convert all args to generators, so working with infitinte itertools is possible

I also can't just play a note in a while loop, which is quite interesting!!!

Key Error: something with not enough channels!!!

cu.cfg.port_count = 8
cu.open_ports()
l=[]
x=(0,.25,.5,.75)
for i in range(50):
    kn=60+x[i%4]
    l.append(cu.note(kn, onset=i, dur=.1))

This produces even without processing the following:

Traceback (most recent call last):
File "/home/amirt/zeug/software/computil/_test.py", line 12, in
l.append(cu.note(kn, onset=i, dur=.1))
File "/home/amirt/venvs/compose/lib/python3.10/site-packages/computil/mid.py", line 182, in note
return ("n",) + _get_note_data(knum, chnl, vel) + (onset, dur)
File "/home/amirt/venvs/compose/lib/python3.10/site-packages/computil/mid.py", line 176, in get_note_data
non, nof, bend, bend_reset, chnl
= _get_msgs(knum, chnl, vel)
File "/home/amirt/venvs/compose/lib/python3.10/site-packages/computil/mid.py", line 141, in _get_msgs
midi_chnl = _verify_setup_chnl_for_eqtemp_ip(midi_chnl)
File "/home/amirt/venvs/compose/lib/python3.10/site-packages/computil/mid.py", line 127, in _verify_setup_chnl_for_eqtemp_ip
_chnls_pool[midi_chnl][0] += 1
KeyError: None

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.