public void it_parses()
        {
            var musicSheetParser = new MusicSheetParser(new ChordParser(new NoteParser()));

            var musicSheet = musicSheetParser.Parse(
                Melodies.FinalFantasyXiii2.AWish.Melody,
                Melodies.FinalFantasyXiii2.AWish.Tempo,
                Melodies.FinalFantasyXiii2.AWish.Nominator,
                Melodies.FinalFantasyXiii2.AWish.Denominator);

            Assert.That(musicSheet.MetronomeMark.Metronome, Is.EqualTo(75));
            Assert.That(musicSheet.MetronomeMark.WholeNoteLength, Is.EqualTo(TimeSpan.FromMilliseconds(400)));

            var melody = musicSheet.Melody.ToArray();

            AssertChord(melody[0], Note.Keys.F, Note.Octaves.Middle, 0.0m, new Fraction(1, 5));
            AssertChord(melody[1], Note.Keys.A, Note.Octaves.Middle, 0.2m, new Fraction(1, 5));
            AssertChord(melody[2], Note.Keys.C, Note.Octaves.High, 0.4m, new Fraction(1, 5));
            AssertChord(melody[3], Note.Keys.E, Note.Octaves.High, 0.6m, new Fraction(1, 5));
            AssertChord(melody[4], Note.Keys.F, Note.Octaves.High, 0.8m, new Fraction(1, 5));
            AssertChord(melody[5], Note.Keys.A, Note.Octaves.High, 1.0m, new Fraction(5, 1));
            AssertChord(melody[6], Note.Keys.D, Note.Octaves.Middle, 6.0m, new Fraction(1, 5));
            AssertChord(melody[7], Note.Keys.F, Note.Octaves.Middle, 6.2m, new Fraction(1, 5));
            AssertChord(melody[8], Note.Keys.A, Note.Octaves.Middle, 6.4m, new Fraction(1, 5));
            AssertChord(melody[9], Note.Keys.C, Note.Octaves.High, 6.6m, new Fraction(1, 5));
            AssertChord(melody[10], Note.Keys.D, Note.Octaves.High, 6.8m, new Fraction(1, 5));
            AssertChord(melody[11], Note.Keys.F, Note.Octaves.High, 7.0m, new Fraction(5, 1));
        }
Beispiel #2
0
        private static MusicPlayer MusicBoxNotationMusicPlayerFactory(RawMusicSheet rawMusicSheet, KeyboardType type)
        {
            var musicSheet = new MusicSheetParser(new ChordParser(new NoteParser(), rawMusicSheet.Instrument)).Parse(
                rawMusicSheet.Melody,
                int.Parse(rawMusicSheet.Tempo),
                int.Parse(rawMusicSheet.Meter.Split('/')[0]),
                int.Parse(rawMusicSheet.Meter.Split('/')[1]));


            var algorithm = rawMusicSheet.Algorithm == "favor notes"
                ? new FavorNotesAlgorithm() : (IPlayAlgorithm) new FavorChordsAlgorithm();

            return(new MusicPlayer(
                       musicSheet,
                       GetInstrument(rawMusicSheet.Instrument, type),
                       algorithm));
        }
Beispiel #3
0
        private static MusicPlayer MusicBoxNotationMusicPlayerFactory(ApplicationOptions filePath)
        {
            var rawMusicSheet = new XmlMusicSheetReader().LoadFromFile(filePath.File);

            var musicSheet = new MusicSheetParser(new ChordParser(new NoteParser())).Parse(
                rawMusicSheet.Melody,
                int.Parse(rawMusicSheet.Tempo),
                int.Parse(rawMusicSheet.Meter.Split('/')[0]),
                int.Parse(rawMusicSheet.Meter.Split('/')[1]));

            var algorithm = rawMusicSheet.Algorithm == "favor notes"
                ? new FavorNotesAlgorithm() : (IPlayAlgorithm) new FavorChordsAlgorithm();

            return(new MusicPlayer(
                       musicSheet,
                       new Harp(GetKeyboard(filePath)),
                       algorithm));
        }
Beispiel #4
0
        private static MusicPlayer MusicBoxNotationMusicPlayerFactory(RawMusicSheet rawMusicSheet, KeyboardType type)
        {
            var musicSheet = new MusicSheetParser(new ChordParser(new NoteParser(), rawMusicSheet.Instrument)).Parse(
                rawMusicSheet.Melody,
                int.Parse(rawMusicSheet.Tempo),
                int.Parse(rawMusicSheet.Meter.Split('/')[0]),
                int.Parse(rawMusicSheet.Meter.Split('/')[1]));


            var algorithm = rawMusicSheet.Algorithm == "favor notes"
                ? new FavorNotesAlgorithm() : (IPlayAlgorithm) new FavorChordsAlgorithm();

            Instrument instrument = InstrumentRepository[rawMusicSheet.Instrument];

            switch (type)
            {
            case KeyboardType.Preview:
                MusicianModule.ModuleInstance.Conveyor.Visible = false;
                instrument.Keyboard = instrument.PreviewKeyboard;
                break;

            case KeyboardType.Practice:
                MusicianModule.ModuleInstance.Conveyor.Visible = true;
                instrument.Keyboard = PracticeKeyboard;
                break;

            case KeyboardType.Emulated:
                MusicianModule.ModuleInstance.Conveyor.Visible = false;
                instrument.Keyboard = EmulatedKeyboard;
                break;

            default:
                throw new NotSupportedException();
            }
            return(new MusicPlayer(
                       musicSheet,
                       instrument,
                       algorithm));
        }
Beispiel #5
0
        private static MusicPlayer MusicBoxNotationMusicPlayerFactory(RawMusicSheet rawMusicSheet, InstrumentMode mode)
        {
            var musicSheet = new MusicSheetParser(new ChordParser(new NoteParser(), rawMusicSheet.Instrument)).Parse(
                rawMusicSheet.Melody,
                int.Parse(rawMusicSheet.Tempo),
                int.Parse(rawMusicSheet.Meter.Split('/')[0]),
                int.Parse(rawMusicSheet.Meter.Split('/')[1]));


            var algorithm = rawMusicSheet.Algorithm == "favor notes"
                ? new FavorNotesAlgorithm() : (IPlayAlgorithm) new FavorChordsAlgorithm();

            Instrument instrument = InstrumentRepository[rawMusicSheet.Instrument];

            instrument.Mode = mode;
            MusicianModule.ModuleInstance.Conveyor.Visible = mode == InstrumentMode.Practice;

            return(new MusicPlayer(
                       musicSheet,
                       instrument,
                       algorithm));
        }