AquesTone2 で利用できる音素を、歌詞文字列から検索するクラス
示例#1
0
 public void testFind()
 {
     var matcher = new SyllableMatcher();
     Assert.AreEqual( "a", matcher.find( "a" ) );
     Assert.AreEqual( "a", matcher.find( "A" ) );
     Assert.AreEqual( "a", matcher.find( "あ" ) );
     Assert.AreEqual( "a", matcher.find( "ア" ) );
     Assert.AreEqual( "a", matcher.find( "ア" ) );
     Assert.AreEqual( "ga", matcher.find( "が"));
     Assert.AreEqual( "ga", matcher.find( "か゛" ) );
     Assert.AreEqual( "ga", matcher.find( "が" ) );
     Assert.AreEqual( "ga", matcher.find( "ガ" ) );
     Assert.AreEqual( "", matcher.find( "@" ) );
 }
示例#2
0
        /// <summary>
        /// Note On のための MIDI イベント列を作成する
        /// </summary>
        /// <param name="note">ノート番号</param>
        /// <param name="dynamics">Dynamics</param>
        /// <param name="phrase">歌詞</param>
        /// <returns>Note On のための MIDI イベント列</returns>
        public MidiEvent[] createNoteOnEvent(int note, int dynamics, String phrase)
        {
            var matcher  = new SyllableMatcher();
            var syllable = matcher.find(phrase);

            if (syllableMap.ContainsKey(syllable))
            {
                var position    = syllableMap[syllable];
                int lineIndex   = position.lineIndex;
                int columnIndex = position.columnIndex;

                var result = new List <MidiEvent>();

                {
                    MidiEvent moveLine = new MidiEvent();
                    moveLine.firstByte = 0xB0;
                    moveLine.data      = new[] { 0x31, lineIndex };
                    result.Add(moveLine);
                }
                for (int i = 1; i <= columnIndex; ++i)
                {
                    {
                        MidiEvent dummyNoteOn = new MidiEvent();
                        dummyNoteOn.firstByte = 0x90;
                        dummyNoteOn.data      = new int[] { note, 0x40 };
                        result.Add(dummyNoteOn);
                    }
                    {
                        MidiEvent dummyNoteOff = new MidiEvent();
                        dummyNoteOff.firstByte = 0x80;
                        dummyNoteOff.data      = new int[] { note, 0x40 };
                        result.Add(dummyNoteOff);
                    }
                }
                {
                    MidiEvent noteOn = new MidiEvent();
                    noteOn.firstByte = 0x90;
                    noteOn.data      = new int[] { note, dynamics };
                    result.Add(noteOn);
                }
                return(result.ToArray());
            }
            else
            {
                return(new MidiEvent[] { });
            }
        }
示例#3
0
        /// <summary>
        /// Note On のための MIDI イベント列を作成する
        /// </summary>
        /// <param name="note">ノート番号</param>
        /// <param name="dynamics">Dynamics</param>
        /// <param name="phrase">歌詞</param>
        /// <returns>Note On のための MIDI イベント列</returns>
        public MidiEvent[] createNoteOnEvent( int note, int dynamics, String phrase )
        {
            var matcher = new SyllableMatcher();
            var syllable = matcher.find( phrase );
            if ( syllableMap.ContainsKey( syllable ) ) {
                var position = syllableMap[syllable];
                int lineIndex = position.lineIndex;
                int columnIndex = position.columnIndex;

                var result = new List<MidiEvent>();

                {
                    MidiEvent moveLine = new MidiEvent();
                    moveLine.firstByte = 0xB0;
                    moveLine.data = new[] { 0x31, lineIndex };
                    result.Add( moveLine );
                }
                for ( int i = 1; i <= columnIndex; ++i ) {
                    {
                        MidiEvent dummyNoteOn = new MidiEvent();
                        dummyNoteOn.firstByte = 0x90;
                        dummyNoteOn.data = new int[] { note, 0x40 };
                        result.Add( dummyNoteOn );
                    }
                    {
                        MidiEvent dummyNoteOff = new MidiEvent();
                        dummyNoteOff.firstByte = 0x80;
                        dummyNoteOff.data = new int[] { note, 0x40 };
                        result.Add( dummyNoteOff );
                    }
                }
                {
                    MidiEvent noteOn = new MidiEvent();
                    noteOn.firstByte = 0x90;
                    noteOn.data = new int[] { note, dynamics };
                    result.Add( noteOn );
                }
                return result.ToArray();
            } else {
                return new MidiEvent[] { };
            }
        }