コード例 #1
0
 protected RandomIntervalsMelodicTrail()
 {
     MinPitch = Pitch.FromMidiPitch(0, Pitch.MidiPitchTranslationMode.Auto);
     MaxPitch = Pitch.FromMidiPitch(int.MaxValue, Pitch.MidiPitchTranslationMode.Auto);
     MinNotes = 2;
     MaxNotes = 10;
 }
コード例 #2
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var pitches = new List <Pitch>();

            while (reader.TokenType != JsonToken.EndArray)
            {
                var midiPitch = reader.ReadAsInt32();
                if (!midiPitch.HasValue)
                {
                    continue;
                }
                pitches.Add(Pitch.FromMidiPitch(midiPitch.Value, Pitch.MidiPitchTranslationMode.Auto));
            }
            return(pitches.ToArray());
        }
コード例 #3
0
        internal void UpdateDisplay(NoteTrainerViewModel trainerViewModel)
        {
            ClearMusicScore();

            var translationMode = Pitch.MidiPitchTranslationMode.Auto;

            if (gameConfiguration.Flats && !gameConfiguration.Sharps)
            {
                translationMode = Pitch.MidiPitchTranslationMode.Flats;
            }
            else if (gameConfiguration.Sharps && !gameConfiguration.Flats)
            {
                translationMode = Pitch.MidiPitchTranslationMode.Sharps;
            }

            foreach (var displayNote in trainerViewModel.DisplayNotes)
            {
                var staff = (displayNote.MidiPitch >= Midi.Pitch.C4) ? musicScore.FirstStaff : musicScore.SecondStaff;

                var scoreNote = new Note(Pitch.FromMidiPitch((int)displayNote.MidiPitch, translationMode), RhythmicDuration.Quarter)
                {
                    IsUpperMemberOfChord = (staff.Elements.Count > 2)
                };
                switch (displayNote.State)
                {
                case DisplayNoteState.Correct:
                    scoreNote.CustomColor = new Color(0, 255, 0, 255);
                    break;

                case DisplayNoteState.Incorrect:
                    scoreNote.CustomColor = Color.Red;
                    break;
                }
                staff.Add(scoreNote);
            }

            if (musicScore.FirstStaff.Elements.Count == 2)
            {
                musicScore.FirstStaff.Elements.Add(new Rest(RhythmicDuration.Quarter));
            }
            if (musicScore.SecondStaff.Elements.Count == 2)
            {
                musicScore.SecondStaff.Elements.Add(new Rest(RhythmicDuration.Quarter));
            }
        }
コード例 #4
0
        public void LoadTestData(HookDirectionAlgorithm hookDirectionAlgorithm)
        {
            var mScore = Score.CreateOneStaffScore(Clef.Treble, Music.Model.MajorAndMinor.MajorScale.G);

            mScore.FirstStaff.AddTimeSignature(TimeSignatureType.Numbers, 4, 4);
            mScore.FirstStaff.AddNote(Pitch.G4, RhythmicDuration.Half);
            mScore.FirstStaff.Add(new Rest(RhythmicDuration.Quarter));
            mScore.FirstStaff.AddNote(Pitch.FromMidiPitch(60, Pitch.MidiPitchTranslationMode.Auto), RhythmicDuration.Half);
            mScore.FirstStaff.AddBarline(BarlineStyle.Regular);
            mScore.FirstStaff.AddNote(Pitch.G4, RhythmicDuration.Quarter);

            mScore.FirstStaff.AddNote(Pitch.FromMidiPitch(61, Pitch.MidiPitchTranslationMode.Auto), RhythmicDuration.Quarter);
            mScore.FirstStaff.AddRange(new Note[] {
                Note.FromMidiPitch(63, RhythmicDuration.Quarter),
                Note.FromMidiPitch(67, RhythmicDuration.Quarter)
            }.MakeChord());
            mScore.FirstStaff.AddBarline(BarlineStyle.Regular);
            mScore.FirstStaff.AddRange(StaffBuilder.FromPitches(
                                           Pitch.C4,
                                           Pitch.E4,
                                           Pitch.G4,
                                           Pitch.A4,
                                           Pitch.C4,
                                           Pitch.E4,
                                           Pitch.G4,
                                           Pitch.A4).AddUniformRhythm(RhythmicDuration.Sixteenth).ApplyStemDirection(VerticalDirection.Up).Rebeam());

            Note n1 = new Note();

            n1.ApplyMidiPitch(63);
            n1.Duration             = RhythmicDuration.Quarter;
            n1.Tuplet               = TupletType.Start;
            n1.TupletWeightOverride = 1;
            mScore.FirstStaff.Add(n1);

            n1 = new Note();
            n1.ApplyMidiPitch(66);

            n1.Duration             = RhythmicDuration.Quarter;
            n1.TupletWeightOverride = 1;

            mScore.FirstStaff.Add(n1);

            n1 = new Note();
            n1.ApplyMidiPitch(66);
            n1.Duration             = RhythmicDuration.Quarter;
            n1.TupletWeightOverride = 1;

            n1.Tuplet = TupletType.Stop;
            mScore.FirstStaff.Add(n1);

            mScore.FirstStaff.AddBarline(BarlineStyle.Regular);
            PrintSuggestion ps = new PrintSuggestion
            {
                IsSystemBreak = true
            };

            mScore.FirstStaff.Add(ps);

            mScore.FirstStaff.AddRange(StaffBuilder.FromPitches(Pitch.G4, Pitch.B4, Pitch.D5, Pitch.C4, Pitch.E4, Pitch.G4, Pitch.D4, Pitch.DSharp4, Pitch.A4)
                                       .AddRhythm("8 8 8 8 4 4 4 4 4"));
            mScore.FirstStaff.AddBarline(BarlineStyle.Regular);

            mScore.FirstStaff.AddRange(StaffBuilder.FromPitches(Pitch.G4, Pitch.B4, Pitch.D5, Pitch.C4, Pitch.E4, Pitch.G4, Pitch.D4, Pitch.DSharp4, Pitch.A4)
                                       .AddRhythm("8 8 8 8 4 4 4 4 4"));

            mScore.FirstStaff.Elements.Add(new Barline());

            mScore.FirstStaff.Add(new PrintSuggestion()
            {
                IsSystemBreak = true
            });

            mScore.FirstStaff.AddBarline(BarlineStyle.LightHeavy);

            mScore.FirstStaff.Elements.Add(new TimeSignature(TimeSignatureType.Numbers, 3, 4));
            mScore.FirstStaff.Elements.Add(new Note(Pitch.C4, RhythmicDuration.Half.AddDots(1))
            {
                TieType = NoteTieType.Start
            });

            mScore.FirstStaff.Elements.Add(new Barline());
            mScore.FirstStaff.Elements.Add(new Note(Pitch.C4, RhythmicDuration.Half.AddDots(1))
            {
                TieType = NoteTieType.Stop
            });
            mScore.FirstStaff.Elements.Add(new Barline());
            mScore.FirstStaff.Elements.Add(new Note(Pitch.C4, RhythmicDuration.Half.AddDots(1)));
            mScore.FirstStaff.Elements.Add(new Barline(BarlineStyle.LightHeavy));

            Data = mScore;
        }
コード例 #5
0
 protected MajorOrMinorScale(int midiPitch, MajorAndMinorScaleFlags flags)
     : base(GetMode(flags.IsMinor), midiPitch, flags.IsFlat ? Pitch.MidiPitchTranslationMode.Flats : Pitch.MidiPitchTranslationMode.Sharps)
 {
     Tonic  = Pitch.FromMidiPitch(midiPitch, MidiPitchTranslationMode);
     Fifths = CircleOfFifths.CalculateFifths(Tonic, flags);
 }
コード例 #6
0
 /// <summary>
 /// Changes pitch of the note to the specific midi pitch.
 /// </summary>
 /// <param name="midiPitch">Midi pitch</param>
 public void ApplyMidiPitch(int midiPitch)
 {
     Pitch = Pitch.FromMidiPitch(midiPitch, Pitch.MidiPitchTranslationMode.Auto);
 }
コード例 #7
0
        public Form1()
        {
            InitializeComponent();
            //noteViewer1.Settings.IsMusicPaperMode = true;

            var fontPath     = Path.Combine(Application.StartupPath, "Assets", "Bravura.otf");
            var metaPath     = Path.Combine(Application.StartupPath, "Assets", "bravura_metadata.json");
            var smuflProfile = SMuFLMusicFont.CreateFromJsonString(File.ReadAllText(metaPath));

            noteViewer1.SetFontFromPath(fontPath, smuflProfile);

            var mScore = Score.CreateOneStaffScore(Clef.Treble, Music.Model.MajorAndMinor.MajorScale.G);

            mScore.FirstStaff.AddTimeSignature(TimeSignatureType.Numbers, 4, 4);
            mScore.FirstStaff.AddNote(Pitch.G4, RhythmicDuration.Half);
            mScore.FirstStaff.Add(new Rest(RhythmicDuration.Quarter));
            mScore.FirstStaff.AddNote(Pitch.FromMidiPitch(60, Pitch.MidiPitchTranslationMode.Auto), RhythmicDuration.Half);
            mScore.FirstStaff.AddBarline(BarlineStyle.Regular);
            mScore.FirstStaff.AddNote(Pitch.G4, RhythmicDuration.Quarter);

            mScore.FirstStaff.AddNote(Pitch.FromMidiPitch(61, Pitch.MidiPitchTranslationMode.Auto), RhythmicDuration.Quarter);
            mScore.FirstStaff.AddRange(new Note[] {
                Note.FromMidiPitch(63, RhythmicDuration.Quarter),
                Note.FromMidiPitch(67, RhythmicDuration.Quarter)
            }.MakeChord());
            mScore.FirstStaff.AddBarline(BarlineStyle.Regular);
            mScore.FirstStaff.AddRange(StaffBuilder.FromPitches(
                                           Pitch.C4,
                                           Pitch.E4,
                                           Pitch.G4,
                                           Pitch.A4,
                                           Pitch.C4,
                                           Pitch.E4,
                                           Pitch.G4,
                                           Pitch.A4).AddUniformRhythm(RhythmicDuration.Sixteenth).ApplyStemDirection(VerticalDirection.Up).Rebeam());

            Note n1 = new Note();

            n1.ApplyMidiPitch(63);
            n1.Duration             = RhythmicDuration.Quarter;
            n1.Tuplet               = TupletType.Start;
            n1.TupletWeightOverride = 1;
            mScore.FirstStaff.Add(n1);

            n1 = new Note();
            n1.ApplyMidiPitch(66);

            n1.Duration             = RhythmicDuration.Quarter;
            n1.TupletWeightOverride = 1;

            mScore.FirstStaff.Add(n1);

            n1 = new Note();
            n1.ApplyMidiPitch(66);
            n1.Duration             = RhythmicDuration.Quarter;
            n1.TupletWeightOverride = 1;

            n1.Tuplet = TupletType.Stop;
            mScore.FirstStaff.Add(n1);

            mScore.FirstStaff.AddBarline(BarlineStyle.Regular);
            PrintSuggestion ps = new PrintSuggestion
            {
                IsSystemBreak = true
            };

            mScore.FirstStaff.Add(ps);

            mScore.FirstStaff.AddRange(StaffBuilder.FromPitches(Pitch.G4, Pitch.B4, Pitch.D5, Pitch.C4, Pitch.E4, Pitch.G4, Pitch.D4, Pitch.DSharp4, Pitch.A4)
                                       .AddRhythm("8 8 8 8 4 4 4 4 4"));
            mScore.FirstStaff.AddBarline(BarlineStyle.Regular);

            mScore.FirstStaff.AddRange(StaffBuilder.FromPitches(Pitch.G4, Pitch.B4, Pitch.D5, Pitch.C4, Pitch.E4, Pitch.G4, Pitch.D4, Pitch.DSharp4, Pitch.A4)
                                       .AddRhythm("8 8 8 8 4 4 4 4 4"));

            mScore.FirstStaff.Elements.Add(new Barline());

            mScore.FirstStaff.Add(new PrintSuggestion()
            {
                IsSystemBreak = true
            });

            mScore.FirstStaff.AddBarline(BarlineStyle.LightHeavy);

            mScore.FirstStaff.Elements.Add(new TimeSignature(TimeSignatureType.Numbers, 3, 4));
            mScore.FirstStaff.Elements.Add(new Note(Pitch.C4, RhythmicDuration.Half.AddDots(1))
            {
                TieType = NoteTieType.Start
            });

            mScore.FirstStaff.Elements.Add(new Barline());
            mScore.FirstStaff.Elements.Add(new Note(Pitch.C4, RhythmicDuration.Half.AddDots(1))
            {
                TieType = NoteTieType.Stop
            });
            mScore.FirstStaff.Elements.Add(new Barline());
            mScore.FirstStaff.Elements.Add(new Note(Pitch.C4, RhythmicDuration.Half.AddDots(1)));
            mScore.FirstStaff.Elements.Add(new Barline(BarlineStyle.LightHeavy));

            noteViewer1.DataSource = mScore;
            noteViewer1.Refresh();
        }