GithubHelp home page GithubHelp logo

muspl's Introduction

MusPl, a musical Prolog library

Build Status

This is a beginning project aiming at logical construction/analysis of musical pieces. It's written in SWI-Prolog (version 7, using dicts). So far the construction phase is being developed.

Simple example

Load and export Flies's Lullaby (included in the project) as a Lilypond file and a karaoke text file.

$ swipl
?- [muspl].
true.

?- loadData('examples/wiegenlied').
true.

?- exportLy('wiegenlied.ly').
maxCount:144
count:100
count:0
true.

?- exportUS('wiegenlied.txt', 'wiegenlied.ogg').
true.

?- halt.

Now run Lilypond to convert it to MIDI and PDF.

$ lilypond wiegenlied.ly

PDF screen

You can use TiMidity++ or some other MIDI renderer to convert the MIDI to OGG (or MP3, if you like).

$ timidity -Ov wiegenlied.midi -o wiegenlied.ogg

If you use UltraStar Deluxe as your karaoke program, just copy the TXT and OGG files to the program's songs folder and sing it!

Construction

Simple melody line:

extra scale{root:f, quality:major}.  % scale of a song

m melody{start:(1, 1, v),  % bar 1, beat 1, staff 'v' (e.g. voice)
	relative:(a, 1, 8),  % tone a, octave 1, duration 1/8
	pitch:[0, 1, 0, -1, -2, -1, -2],  % relative pitches from the scale
	len:[1, 1, 1, 1, 1, 1, 2]}.  % multiples of the relative duration

The same line with lengths described briefly:

m melody{start:(1, 1, v), relative:(a, 1, 8),
	pitch:[0, 1, 0, -1, -2, -1, -2], len:[1*6, 2]}.

Repeated pitch/length sequences can be reused by a name:

m [
	'6long' = [1*6, [4, 8, 4]],  % [4, 8, 4] = exact duration 1/4 + 1/8 + 1/4
	melody{start:(5, 1, v), relative:(g, 1, 8),
		pitch:[0, -1:1, 0, 0, -1:1, 0, 2], len:'6long'},
			% :1 = one semitone up, :(-1) would be one semitone down
	melody{start:(5, 1, g), relative:(e, 1, 8),
		pitch:[0, -1:1, 0, 0, -1:1, 0, 2], len:'6long'}
].

Bars can be copied, under a condition and transformed in a way:

m copyBars{from:6, to:10, count:2, cond:isStaff(f), action:pitchShift(5)}.

muspl's People

Contributors

garncarz avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

muspl's Issues

ASCII predicates/operators

and ♪= should be probably replaced by some ASCII notation, so they're easier to type and work also on Windows.

Notation as a dict

Actual format: notation((1, 2.5, v), (a, 1), 8)
Proposed format: notation{position:position{...}, tone:tone{...}, dur:duration{...}}
Maybe dur should be incorporated into tone.

Maybe there should exist "global" functions on notation, like those from data: allStaffs, allBeats... maybe even data should be a dict? (Similar to how notationDb works now, so it would be generally possible to work with several songs at the same time. The first "db" could be default.)

Construction: deduplicate pitch/length sequences

Actual:

♪ melody{start:(1, 1, g), relative:(a, 1, 8),
    pitch:[0, 1, 0, -1, -2, -1, -2],
    len:[1, 1, 1, 1, 1, 1, 2]}.

Could be ~:

♪db(pitchSeqA, [0, 1, 0, -1, -2, -1, -2]).
♪db(lenSeqA, [1, 1, 1, 1, 1, 1, 2]).
♪ melody{start:(1, 1, g), relative:(a, 1, 8), pitch:pitchSeqA, len:lenSeqA}.

MIDI import

Adjust to the new position/duration format and ensure it works by creating tests/song.midi which would be imported by a test.

Playback

play. and play(From, To). should be available to provide quick feedback of notation.

Unify construction predicates

extra title(...), extra composer(...), extra scale{...}, extra timeSignature(...) (maybe something else?) – all should go inside m.

Render tones right on time

So far, tones are rendered linearly, continuously, for the sake of demonstration. Their position should be respected, allowing multiple tones to sound at once.

Possibilities for storing both tones' and overall samples (hopefully it will be more saving than findall):

  1. assertz – global
  2. b_setval/nb_setval – global
  3. setarg/nb_setarg – local

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.