1.0.5 • Published 4 years ago

musik v1.0.5

Weekly downloads
1
License
ISC
Repository
github
Last release
4 years ago

Musik.js

A library to make complex music pieces easily in JavaScript

In progress - To be released!

(Check current progress sections for available features)

Goals

  • A developer with little/no music knowledge can easily create music programmatically. (ex. Simply copy-pasting song notes from the internet works)
  • Multiple music pieces that are played parallelly can be easily added to a part. (ex. Right hand and left hand parts of the piano)
  • It is trivial to control the tempo as well as instrument of any piece.
  • Chords, arpeggios, percussions, etc. can be auto generated.
  • And more TBA

Current Progress

makeMidi(notes, octave, outputFileName)

Converts simple sound notes and exports them as a MIDI file

Input notes format:

Takes a string with notes seperated by an empty space as input.

Can also take an array of notes as an input.

Optional inputs are octave (default = 4) and filename (default = musik.mid)

Specifying octaves

Each note that is of an octave that is not the octave specified in the second argument, must have an octave number with it. (Example: C#5)

You can also increment and decrement a note from the current octave using a + or - suffix to the note. (Example: C#- plays a C# note of 1 octave lower than the default octave)

Example:

Array of notes as input:

makeMidi(['F#', 'F#', 'F#', 'A#', 'D#5', 'D#5', 'D#5', 'C#5', 'A#', 'A#', 'A#', 'A#', 'F', 'F', 'F', 'D#'], 4)

Or

String of notes (with sharp notes) as input:

makeMidi("F# F# F# A# D#5 D#5 D#5 C#5 A# A# A# A# F F F D#", 4)

Or

String of notes (with flat notes) as input:

makeMidi("Gb Gb Gb Bb Eb5 Eb5 Eb5 Db5 Bb Bb Bb Bb F F F Eb", 4)

Or

String of notes (with + and - used for octaves) as input:

makeMidi("Gb Gb Gb Bb Eb+ Eb+ Eb+ Db+ Bb Bb Bb Bb F F F Eb", 4)

All of these automatically create a MIDI file (musik.mid) that plays Faded (by Alan Walker)'s intro on the 4th octave. Both sharp and flat notes are supported as demonstrated in the example above.

Use an underscore ( _ ) to denote a note break.

Capitalization does not matter.

Example:

makeMidi('c c g g a a g _ f f e e d d c', 5, 'twinkle')

This automatically creates a MIDI file (twinkle.mid) that plays the first line of the rhyme Twinkle twinke little stars on the 4th octave.

Notice the note break after the first star.

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.2-0

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago