Skip to main content

Generate MIDI file from Array of Array data.

Project description

This package generates a PrettyMIDI object from Array of Array. Here is a sample code.

import mdpw
a = ['s',['n',64,1,64,1],['n',68,1,64,1],['n',71,1,64,1],
   ['c',['n',64,1,64,1],['n',68,1,64,1],['n',71,1,64,1]]]
mdpw.compile(a, 120).write("hello.mid")

‘n’ means a note and followed values are pitch, duration, velocity and instrument. The instrument 129 means Drum. ‘s’ means to play sequentially and ‘c’ means to play simultaneously.

Here is anther sample code.

from mdpw import INSTRUMENTS as I
from mdpw import DRUMS as D
from mdpw import note, seq, chord, compile
dph = D['PedalHi-Hat']
i = I['Drum']
hh = ['s',['n',dph,1,127,i],['n',dph,1],['n',dph,1],['n',dph,1]]
b = seq(note(64,.5,0,I['ElectricBassPick']),note(64,1,127),note(64,1),note(64,1))
m = chord(seq(hh,hh,hh,hh),seq(b,b,b,b))
compile(m, 120).write("sample.mid")

In fact, the functions ‘note’, ‘seq’, ‘chord’ return arrays.

You can generate a round chant like this:

import mdpw
from mdpw import note as n
from mdpw import seq as s
from mdpw import chord as c
from mdpw import compile

m0 = s(n(64,1,64,17), n(66), n(68), n(69), n(68),n(66),n(64),n(0,1,0))
m01 = s(n(64,.5,64,17),n(64), n(66), n(66), n(68),n(68), n(69),n(69), n(68),n(68),n(66),n(66),n(64,1),n(0,1,0))
m1 = s(n(68,1,64,17), n(69), n(71), n(73), n(71),n(69),n(68),n(0,1,0))
m2 = s(n(64,2,125,17), n(64), n(64), n(64))
a = s(m0, m1, m2,m01)
r = n(0,8,0,1)
a =c(a, s(r, a), s(r, r, a))
mdpw.compile(a, 120).write("frog.mid")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mdpw-0.0.3.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

mdpw-0.0.3-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file mdpw-0.0.3.tar.gz.

File metadata

  • Download URL: mdpw-0.0.3.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.5.0.1 requests/2.25.1 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.2

File hashes

Hashes for mdpw-0.0.3.tar.gz
Algorithm Hash digest
SHA256 2603ac7fded04c7ba47a4e7fa985d9520686cc79d9c4bb02663464bd6bc28e7b
MD5 40f59bd4cc6c3090dd9cfa0b9e359425
BLAKE2b-256 a940862612ce80fe9dc13c9ac9858308092b9353c8bc45614fd84d179a3c11e5

See more details on using hashes here.

File details

Details for the file mdpw-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: mdpw-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.5.0.1 requests/2.25.1 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.2

File hashes

Hashes for mdpw-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5783e8410a2dd34e37136aac470ae2b63b07779e67213caf1f2bbd56ff16ef3a
MD5 3a7b252c719bb9a0d422399f13eabd8d
BLAKE2b-256 bb0abee4dc581ffc6009b22e0337af4abead794493f1cbbdef2bd13b824a6bd9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page