コード例 #1
0
 private static string getNoteString(int note)
 {
     string[] jp      = new string[] { "ハ", "嬰ハ", "ニ", "変ホ", "ホ", "ヘ", "嬰へ", "ト", "嬰ト", "イ", "変ロ", "ロ" };
     string[] jpfixed = new string[] { "ド", "ド#", "レ", "ミb", "ミ", "ファ", "ファ#", "ソ", "ソ#", "ラ", "シb", "シ", };
     string[] de      = { "C", "Cis", "D", "Es", "E", "F", "Fis", "G", "Gis", "A", "Hes", "H" };
     if (AppManager.editorConfig != null)
     {
         int odd   = note % 12;
         int order = (note - odd) / 12 - 2;
         NoteNumberExpressionType exp_type = AppManager.editorConfig.PropertyWindowStatus.LastUsedNoteNumberExpression;
         if (exp_type == NoteNumberExpressionType.Numeric)
         {
             return(note + "");
         }
         else if (exp_type == NoteNumberExpressionType.International)
         {
             return(VsqNote.getNoteString(note));
         }
         else if (exp_type == NoteNumberExpressionType.Japanese)
         {
             return(jp[odd] + order);
         }
         else if (exp_type == NoteNumberExpressionType.JapaneseFixedDo)
         {
             return(jpfixed[odd] + order);
         }
         else if (exp_type == NoteNumberExpressionType.Deutsche)
         {
             return(de[odd] + order);
         }
     }
     else
     {
         return(VsqNote.getNoteString(note));
     }
     return("");
 }
コード例 #2
0
            private void Init(TimesigVector timesig_table, TempoVector tempo_table, int clock_start, int length, int note_number, bool create_rest)
            {
                clock_  = clock_start;
                length_ = length;

                // 着目している範囲内のテンポのみを取り出す
                var small_tempo_table = new TempoVector();

                small_tempo_table.AddRange(
                    tempo_table
                    .Where((tempo) => clock_start <= tempo.Clock && tempo.Clock < clock_start + length)
                    .Select((tempo) => (TempoTableEntry)tempo.Clone()));

                // <pitch> エレメントのテンプレートを作成
                MusicXML.pitch pitch = null;
                if (!create_rest)
                {
                    pitch = new pitch();
                    int  octave = VsqNote.getNoteOctave(note_number) + 1;
                    step step;
                    if (Enum.TryParse <step>(VsqNote.getNoteStringBase(note_number), out step))
                    {
                        pitch.step = step;
                    }
                    pitch.octave = octave.ToString();
                    int alter = VsqNote.getNoteAlter(note_number);
                    if (alter != 0)
                    {
                        pitch.alter          = alter;
                        pitch.alterSpecified = true;
                    }
                }

                int clock_end     = clock_start + length;
                int current_clock = clock_start;

                while (current_clock < clock_start + length)
                {
                    int next_bar_clock    = timesig_table.getClockFromBarCount(timesig_table.getBarCountFromClock(current_clock) + 1);
                    int next_tempo_change = clock_end;
                    if (small_tempo_table.Count > 0)
                    {
                        try {
                            next_tempo_change =
                                small_tempo_table
                                .First((tempo) => {
                                return(current_clock < tempo.Clock && tempo.Clock < clock_end);
                            })
                                .Clock;
                        } catch (InvalidOperationException) { }
                    }

                    int next_separation_point = Math.Min(Math.Min(clock_end, next_bar_clock), next_tempo_change);

                    int remain   = next_separation_point - current_clock;
                    var template =
                        templates_
                        .OrderByDescending((note) => note.duration.First)
                        .FirstOrDefault((note) => note.duration.First <= remain);
                    if (template == null)
                    {
                        break;
                    }
                    else
                    {
                        var note = template.Clone();
                        if (create_rest)
                        {
                            note.rest.Add(new rest());
                        }
                        else
                        {
                            note.pitch.Add(pitch.Clone());
                            note.stem       = new stem();
                            note.stem.Value = stemvalue.up;
                        }
                        notes_.Add(note);
                        current_clock += (int)note.duration.First;
                    }
                }

                // connect note with tie
                if (!create_rest && notes_.Count >= 2)
                {
                    for (int i = 0; i < notes_.Count; ++i)
                    {
                        var note      = notes_[i];
                        var tied_list = new List <tied>();
                        if (i < notes_.Count - 1)
                        {
                            var start_tie = new tie();
                            start_tie.type = startstop.start;
                            note.tie.Add(start_tie);

                            var tied = new tied();
                            tied.type = startstopcontinue.start;
                            tied_list.Add(tied);
                        }
                        if (0 < i)
                        {
                            var stop_tie = new tie();
                            stop_tie.type = startstop.stop;
                            note.tie.Add(stop_tie);

                            var tied = new tied();
                            tied.type = startstopcontinue.stop;
                            tied_list.Add(tied);
                        }
                        var notations = new notations();
                        notations.Items = tied_list.ToArray();
                        note.notations  = new MusicXML.notations[] { notations };
                    }
                }
            }