Name | midigen JSON |
Version |
0.0.5
JSON |
| download |
home_page | |
Summary | |
upload_time | 2023-02-12 01:23:09 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.6 |
license | MIT License Copyright (c) 2023 Bryan Johnson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
midi
generative
audio
music
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# midigen
[![License](https://img.shields.io/github/license/dbjohnson/midigen.svg)]()
[![PyPi](https://img.shields.io/pypi/v/midigen.svg)](https://pypi.python.org/pypi/looptimer)
![GHA](https://github.com/dbjohnson/midigen/actions/workflows/tests.yml/badge.svg)
Python library for generating simple chord progression midi files
## Installation
```cmd
pip install midigen
```
## Example usage
### Command line
Play a `ii-V-I-vi` pattern in the key of `G`; loop it four times
```cmd
midigen --key G --chords ii V I vi --loop 4 --play
```
### Python
```python
import mido
from midigen.notes import Note
from midigen.keys import Key, Mode
from midigen.time import TimeSignature, Measure
from midigen.sequencer import Song, Track, play_notes
port = mido.open_output('midigen', virtual=True)
# C major scale
Key(Note.C, Mode.Major).to_track(tempo=200).play(port)
# A simple chord progression
key = Key(Note.C, Mode.Major)
time_signature = TimeSignature(4, 4)
tempo = 90
progression = [2, 5, 1, 6]
chords = Track.from_measures([
Measure.from_pattern(
pattern=[
key.relative_key(degree).chord(
[7],
# pick a voicing close to the root triad
match_voicing=key.triad()
)
] * time_signature.numerator,
time_signature=time_signature,
tempo=tempo,
velocity=90
)
for degree in progression
], name='chords')
chords.play(port)
# A simple melody
melody = Track.from_measures([
Measure.from_pattern(
pattern=[
[key.note(degree).value],
[key.note(degree + 2).value],
[key.note(degree + 5).value],
None
],
time_signature=time_signature,
tempo=tempo,
velocity=80
)
for degree in progression
], name='melody')
melody.play(port)
# Stack the melody and chords in a single track
chords.stack(melody).play(port)
# Or use the Song class to play multiple tracks
Song([chords, melody]).play(port)
# Write the song to a MIDI file
Song([chords, melody]).to_midi('example.mid')
```
Raw data
{
"_id": null,
"home_page": "",
"name": "midigen",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "midi,generative,audio,music",
"author": "",
"author_email": "Bryan Johnson <d.bryan.johnson@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/e6/a8/b027a3e7e9af8ba318242767b23960579e5c3499646a41607e4a80a7afb9/midigen-0.0.5.tar.gz",
"platform": null,
"description": "# midigen\n[![License](https://img.shields.io/github/license/dbjohnson/midigen.svg)]()\n[![PyPi](https://img.shields.io/pypi/v/midigen.svg)](https://pypi.python.org/pypi/looptimer)\n![GHA](https://github.com/dbjohnson/midigen/actions/workflows/tests.yml/badge.svg)\n\n\nPython library for generating simple chord progression midi files\n\n## Installation\n```cmd\npip install midigen\n```\n\n## Example usage\n### Command line\n\nPlay a `ii-V-I-vi` pattern in the key of `G`; loop it four times \n```cmd\nmidigen --key G --chords ii V I vi --loop 4 --play\n```\n\n### Python\n\n\n```python\nimport mido\nfrom midigen.notes import Note\nfrom midigen.keys import Key, Mode\nfrom midigen.time import TimeSignature, Measure\nfrom midigen.sequencer import Song, Track, play_notes\n\n\nport = mido.open_output('midigen', virtual=True)\n\n# C major scale\nKey(Note.C, Mode.Major).to_track(tempo=200).play(port)\n\n# A simple chord progression\nkey = Key(Note.C, Mode.Major)\ntime_signature = TimeSignature(4, 4)\ntempo = 90\nprogression = [2, 5, 1, 6]\n\nchords = Track.from_measures([\n Measure.from_pattern(\n pattern=[\n key.relative_key(degree).chord(\n [7],\n # pick a voicing close to the root triad\n match_voicing=key.triad()\n )\n ] * time_signature.numerator,\n time_signature=time_signature,\n tempo=tempo,\n velocity=90\n )\n for degree in progression\n], name='chords')\nchords.play(port)\n\n# A simple melody\nmelody = Track.from_measures([\n Measure.from_pattern(\n pattern=[\n [key.note(degree).value],\n [key.note(degree + 2).value],\n [key.note(degree + 5).value],\n None\n ],\n time_signature=time_signature,\n tempo=tempo,\n velocity=80\n )\n for degree in progression\n], name='melody')\nmelody.play(port)\n\n# Stack the melody and chords in a single track\nchords.stack(melody).play(port)\n\n# Or use the Song class to play multiple tracks\nSong([chords, melody]).play(port)\n\n# Write the song to a MIDI file\nSong([chords, melody]).to_midi('example.mid')\n```\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2023 Bryan Johnson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
"summary": "",
"version": "0.0.5",
"split_keywords": [
"midi",
"generative",
"audio",
"music"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "cc41adfa07827702dd4ff8730d37554f1958fb3862cf4c1d76a36b8516c33ceb",
"md5": "78b1c7a78c23b2bd5e4e8cdf38a4a7a5",
"sha256": "af7b2fc5e816af312b12ea0a0ca3f4ee78a80f2c767c7332a52afc49c8731aae"
},
"downloads": -1,
"filename": "midigen-0.0.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "78b1c7a78c23b2bd5e4e8cdf38a4a7a5",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 10906,
"upload_time": "2023-02-12T01:23:08",
"upload_time_iso_8601": "2023-02-12T01:23:08.432667Z",
"url": "https://files.pythonhosted.org/packages/cc/41/adfa07827702dd4ff8730d37554f1958fb3862cf4c1d76a36b8516c33ceb/midigen-0.0.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e6a8b027a3e7e9af8ba318242767b23960579e5c3499646a41607e4a80a7afb9",
"md5": "5fba0ab6e23e2f8a58180d858c239cc9",
"sha256": "70964a30707187f1ed7796b33ab51a9861ebe3331d6385b1eb2f80b63f37c71c"
},
"downloads": -1,
"filename": "midigen-0.0.5.tar.gz",
"has_sig": false,
"md5_digest": "5fba0ab6e23e2f8a58180d858c239cc9",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 10548,
"upload_time": "2023-02-12T01:23:09",
"upload_time_iso_8601": "2023-02-12T01:23:09.572329Z",
"url": "https://files.pythonhosted.org/packages/e6/a8/b027a3e7e9af8ba318242767b23960579e5c3499646a41607e4a80a7afb9/midigen-0.0.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-02-12 01:23:09",
"github": false,
"gitlab": false,
"bitbucket": false,
"lcname": "midigen"
}