Git Product home page Git Product logo

nfugue's Introduction

NFugue

Build status NuGet

.NET port of JFugue based on version 5.0.9.

NFugue allows you to create, play and experiment with music programatically. You can easily build music using elements like chords, chord progresssions and rhythms which will get transformed to MIDI for you. It also supports integration with some other musical formats like LilyPond or MusicXML.

The real-time music analysis and playback functionality available in JFugue is not yet implemented.

Download

NFugue is available on NuGet:

PM> Install-Package NFugue

Getting started

Musical "Hello World" i.e. playing the major scale:

using (var player = new Player())
{
    player.Play("C D E F G A B");
}

Music in NFugue is generally represented by patterns which can be transformed in various ways, for example to create some twelve-bar blues:

Pattern pattern = new ChordProgression("I IV V")
    .Distribute("7%6")
    .AllChordsAs("$0 $0 $0 $0 $1 $1 $0 $0 $2 $1 $0 $0")
    .EachChordAs("$0ia100 $1ia80 $2ia80 $3ia80 $4ia100 $3ia80 $2ia80 $1ia80")
    .GetPattern()
    .SetInstrument(Instrument.AcousticBass)
    .SetTempo(120);

For more examples and a description of the Staccato markup visit JFugue website. Most examples should work in NFugue with little or no modifications.

nfugue's People

Contributors

jiachen-zeng avatar mchudy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

nfugue's Issues

Parsing MusicXML error. `accidentalCount` is strange

This score

accidentalCount = 252
System.IndexOutOfRangeException
  HResult=0x80131508
  Message=索引超出了数组界限。
  Source=NFugue
  StackTrace:
   在 NFugue.Staccato.Subparsers.SignatureSubparser.ConvertAccidentalCountToKeyRootPositionInOctave(Int32 accidentalCount, Int32 scale) 在 D:\Data\编程\Projects\C#\NFugue\src\NFugue\Staccato\Subparsers\SignatureSubparser.cs 中: 第 121 行
   在 NFugue.Midi.MidiParser.KeySigParsed(MetaMessage meta) 在 D:\Data\编程\Projects\C#\NFugue\src\NFugue\Midi\MidiParser.cs 中: 第 227 行
   在 NFugue.Midi.MidiParser.ParseMetaMessage(MetaMessage message, MidiEvent event) 在 D:\Data\编程\Projects\C#\NFugue\src\NFugue\Midi\MidiParser.cs 中: 第 135 行
   在 NFugue.Midi.MidiParser.ParseEvent(MidiEvent event) 在 D:\Data\编程\Projects\C#\NFugue\src\NFugue\Midi\MidiParser.cs 中: 第 58 行
   在 NFugue.Midi.MidiParser.Parse(Sequence sequence) 在 D:\Data\编程\Projects\C#\NFugue\src\NFugue\Midi\MidiParser.cs 中: 第 28 行
   在 NFugue.Midi.Conversion.MidiFileConverter.LoadPatternFromMidi(String filePath) 在 D:\Data\编程\Projects\C#\NFugue\src\NFugue\Midi\Conversion\MidiFileConverter.cs 中: 第 37 行
   在 NFugue.ManualTests.Program.TestPlayMidi() 在 D:\Data\编程\Projects\C#\NFugue\tests\NFugue.ManualTests\Program.cs 中: 第 26 行
   在 NFugue.ManualTests.Program.Main(String[] args) 在 D:\Data\编程\Projects\C#\NFugue\tests\NFugue.ManualTests\Program.cs 中: 第 16 行

Using a non-US Culture may cause errors!

I'm Swedish and using Culture sv-SE, One of the things that this does is changing the decimal separator to a comma (,)

This leads to a lot of problem for all places that uses double.ToString or String Interpolation, e.g.

frequency = double.Parse(frequencyMatch.Groups[0].ToString());
qualifier =$"/{DefaultNoteSettings.DefaultDuration}"

They should (may) be changed to

frequency = double.Parse(frequencyMatch.Groups[0].ToString(), CultureInfo.InvariantCulture);
qualifier = FormattableString.Invariant($"/{DefaultNoteSettings.DefaultDuration}");

Chords are played independently in MusicXML conversion

In this score, the 2nd measure is converted to

L0 E4h. D4i C4i AMIN L4 A2w

AMIN and E4h. are not played at the same time. The correct one will be

L0 E4h.+AMIN D4i C4i L4 A2w

But even if the Staccato string is correct, the duration is wrong when playing. The duration of all notes in harmony will be the duration of the last one.

Chord Inversions Not Playing as Single Chord

If you try the following the first inversion and second inversion won't play all the notes of the chord at the same time.


            using (var player = new Player())
            {
                Pattern pattern = new ChordProgression("I I^ I^^").AllChordsAs("$0 $0 $0 $0i Ri $1 $1 $1 $1 $2 $2 $2 $2").GetPattern();
                player.Play(pattern);
            }

Interestingly, this happens (to a much more noticeable extent) in the original JFugue 5.0.9. I tried this port with the hope that it wouldn't happen...

Also I don't mind trying to fix it. I just need help figuring out where to look. Thanks!

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.