Logo Search packages:      
Sourcecode: cadencii version File versions  Download package

void org::kbinani::cadencii::FormMain::executeLyricChangeCommand (  ) [inline]

現在のAppManager.mInputTextBoxの状態を元に、歌詞の変更を反映させるコマンドを実行します

Definition at line 3219 of file FormMain.cs.

References org::kbinani::cadencii::AppManager::applyUtauParameter(), org::kbinani::vsq::SymbolTable::attatch(), org::kbinani::vsq::VsqEvent::clone(), org::kbinani::cadencii::AppManager::editHistory, org::kbinani::cadencii::AppManager::editorConfig, org::kbinani::cadencii::LyricTextBox::getBufferText(), org::kbinani::vsq::SymbolTable::getMaxDivisions(), org::kbinani::vsq::Lyric::getPhoneticSymbol(), org::kbinani::vsq::SymbolTableEntry::getRawSymbol(), org::kbinani::cadencii::AppManager::getSelected(), org::kbinani::vsq::SymbolTableEntry::getSymbol(), org::kbinani::cadencii::AppManager::getVsqFile(), org::kbinani::vsq::VsqTrack::indexIterator(), org::kbinani::vsq::VsqEvent::InternalID, org::kbinani::vsq::VsqPhoneticSymbol::isConsonant(), org::kbinani::cadencii::LyricTextBox::isPhoneticSymbolEditMode(), org::kbinani::vsq::VsqPhoneticSymbol::isValidSymbol(), org::kbinani::cadencii::AppManager::itemSelection, org::kbinani::cadencii::AppManager::mInputTextBox, org::kbinani::cadencii::SelectedEventEntry::original, org::kbinani::vsq::Lyric::Phrase, org::kbinani::cadencii::EditHistoryModel::register(), org::kbinani::cadencii::EditorConfig::SelfDeRomanization, org::kbinani::vsq::Lyric::setConsonantAdjustmentList(), org::kbinani::vsq::Lyric::setPhoneticSymbol(), org::kbinani::vsq::VsqFile::Track, and org::kbinani::vsq::SymbolTableEntry::Word.

        {
#if JAVA
            if ( !AppManager.mInputTextBox.isVisible() ) {
#else
            if ( !AppManager.mInputTextBox.Enabled ) {
#endif
                return;
            }
#if !JAVA
            if ( AppManager.mInputTextBox.IsDisposed ) {
                return;
            }
#endif
            SelectedEventEntry last_selected_event = AppManager.itemSelection.getLastEvent();
            boolean phonetic_symbol_edit_mode = AppManager.mInputTextBox.isPhoneticSymbolEditMode();

            int selected = AppManager.getSelected();
            VsqFileEx vsq = AppManager.getVsqFile();
            VsqTrack vsq_track = vsq.Track.get( selected );

            // 後続に、連続している音符が何個あるか検査
            int maxcount = SymbolTable.getMaxDivisions(); // 音節の分割によって,高々maxcount個までにしか分割されない
            boolean check_started = false;
            int endclock = 0;  // 直前の音符の終了クロック
            int count = 0;     // 後続音符の連続個数
            int start_index = -1;
            int indx = -1;
            for ( Iterator<Integer> itr = vsq_track.indexIterator( IndexIteratorKind.NOTE ); itr.hasNext(); ) {
                indx = itr.next();
                VsqEvent itemi = vsq_track.getEvent( indx );
                if ( itemi.InternalID == last_selected_event.original.InternalID ) {
                    check_started = true;
                    endclock = itemi.Clock + itemi.ID.getLength();
                    count = 1;
                    start_index = indx;
                    continue;
                }
                if ( check_started ) {
                    if ( count + 1 > maxcount ) {
                        break;
                    }
                    if ( itemi.Clock <= endclock ) {
                        count++;
                        endclock = itemi.Clock + itemi.ID.getLength();
                    } else {
                        break;
                    }
                }
            }

            // 後続の音符をリストアップ
            VsqEvent[] items = new VsqEvent[count];
            String[] original_symbol = new String[count];
            String[] original_phrase = new String[count];
            boolean[] symbol_protected = new boolean[count];
            indx = -1;
            for ( Iterator<Integer> itr = vsq_track.indexIterator( IndexIteratorKind.NOTE ); itr.hasNext(); ) {
                int index = itr.next();
                if ( index < start_index ) {
                    continue;
                }
                indx++;
                if ( count <= indx ) {
                    break;
                }
                VsqEvent ve = vsq_track.getEvent( index );
                items[indx] = (VsqEvent)ve.clone();
                original_symbol[indx] = ve.ID.LyricHandle.L0.getPhoneticSymbol();
                original_phrase[indx] = ve.ID.LyricHandle.L0.Phrase;
                symbol_protected[indx] = ve.ID.LyricHandle.L0.PhoneticSymbolProtected;
            }

#if DEBUG
            AppManager.debugWriteLine( "    original_phase,symbol=" + original_phrase + "," + original_symbol[0] );
            AppManager.debugWriteLine( "    phonetic_symbol_edit_mode=" + phonetic_symbol_edit_mode );
            AppManager.debugWriteLine( "    AppManager.mInputTextBox.setText(=" + AppManager.mInputTextBox.getText() );
#endif
            String[] phrase = new String[count];
            String[] phonetic_symbol = new String[count];
            for ( int i = 0; i < count; i++ ) {
                phrase[i] = original_phrase[i];
                phonetic_symbol[i] = original_symbol[i];
            }
            String txt = AppManager.mInputTextBox.getText();
            int txtlen = PortUtil.getStringLength( txt );
            if ( txtlen > 0 ) {
                // 1文字目は,UTAUの連続音入力のハイフンの可能性があるので,無駄に置換されるのを回避
                phrase[0] = str.sub( txt, 0, 1 ) + ((txtlen > 1) ? str.sub( txt, 1 ).Replace( "-", "" ) : "");
            } else {
                phrase[0] = "";
            }
            if ( !phonetic_symbol_edit_mode ) {
                // 歌詞を編集するモードで、
                if ( AppManager.editorConfig.SelfDeRomanization ) {
                    // かつローマ字の入力を自動でひらがなに展開する設定だった場合。
                    // ローマ字をひらがなに展開
                    phrase[0] = KanaDeRomanization.Attach( phrase[0] );
                }
            }

            // 発音記号または歌詞が変更された場合の処理
            if ( (phonetic_symbol_edit_mode && !str.compare( AppManager.mInputTextBox.getText(), original_symbol[0] )) ||
                 (!phonetic_symbol_edit_mode && !str.compare( phrase[0], original_phrase[0] )) ) {
                if ( phonetic_symbol_edit_mode ) {
                    // 発音記号を編集するモード
                    phrase[0] = AppManager.mInputTextBox.getBufferText();
                    phonetic_symbol[0] = AppManager.mInputTextBox.getText();

                    // 入力された発音記号のうち、有効なものだけをピックアップ
                    String[] spl = PortUtil.splitString( phonetic_symbol[0], new char[] { ' ' }, true );
                    Vector<String> list = new Vector<String>();
                    for ( int i = 0; i < spl.Length; i++ ) {
                        String s = spl[i];
                        if ( VsqPhoneticSymbol.isValidSymbol( s ) ) {
                            list.add( s );
                        }
                    }

                    // ピックアップした発音記号をスペース区切りで結合
                    phonetic_symbol[0] = "";
                    boolean first = true;
                    for ( Iterator<String> itr = list.iterator(); itr.hasNext(); ) {
                        String s = itr.next();
                        if ( first ) {
                            phonetic_symbol[0] += s;
                            first = false;
                        } else {
                            phonetic_symbol[0] += " " + s;
                        }
                    }

                    // 発音記号を編集すると、自動で「発音記号をプロテクトする」モードになるよ
                    symbol_protected[0] = true;
                } else {
                    // 歌詞を編集するモード
                    if ( !symbol_protected[0] ) {
                        // 発音記号をプロテクトしない場合、歌詞から発音記号を引当てる
                        SymbolTableEntry entry = SymbolTable.attatch( phrase[0] );
                        if ( entry == null ) {
                            phonetic_symbol[0] = "a";
                        } else {
                            phonetic_symbol[0] = entry.getSymbol();
                            // 分節の分割記号'-'が入っている場合
#if DEBUG
                            sout.println( "FormMain#executeLyricChangeCommand; word=" + entry.Word + "; symbol=" + entry.getSymbol() + "; rawSymbol=" + entry.getRawSymbol() );
#endif
                            if ( entry.Word.IndexOf( '-' ) >= 0 ) {
                                String[] spl_phrase = PortUtil.splitString( entry.Word, '\t' );
                                if ( spl_phrase.Length <= count ) {
                                    // 分節の分割数が,後続の音符数と同じか少ない場合
                                    String[] spl_symbol = PortUtil.splitString( entry.getRawSymbol(), '\t' );
                                    for ( int i = 0; i < spl_phrase.Length; i++ ) {
                                        phrase[i] = spl_phrase[i];
                                        phonetic_symbol[i] = spl_symbol[i];
                                    }
                                } else {
                                    // 後続の音符の個数が足りない
                                    phrase[0] = entry.Word.Replace( "\t", "" );
                                }
                            }
                        }
                    } else {
                        // 発音記号をプロテクトする場合、発音記号は最初のやつを使う
                        phonetic_symbol[0] = original_symbol[0];
                    }
                }
#if DEBUG
                AppManager.debugWriteLine( "    phrase,phonetic_symbol=" + phrase + "," + phonetic_symbol );
#endif

                for ( int j = 0; j < count; j++ ) {
                    if ( phonetic_symbol_edit_mode ) {
                        items[j].ID.LyricHandle.L0.setPhoneticSymbol( phonetic_symbol[j] );
                    } else {
                        items[j].ID.LyricHandle.L0.Phrase = phrase[j];
                        items[j].ID.LyricHandle.L0.setPhoneticSymbol( phonetic_symbol[j] );
                        AppManager.applyUtauParameter( vsq_track, items[j] );
                    }
                    if ( !str.compare( original_symbol[j], phonetic_symbol[j] ) ) {
#if JAVA
                        Vector<String> spl = items[j].ID.LyricHandle.L0.getPhoneticSymbolList();
#else
                        List<String> spl = items[j].ID.LyricHandle.L0.getPhoneticSymbolList();
#endif
                        Vector<Integer> adjustment = new Vector<Integer>();
                        for ( int i = 0; i < vec.size( spl ); i++ ) {
                            String s = vec.get( spl, i );
                            adjustment.add( VsqPhoneticSymbol.isConsonant( s ) ? 64 : 0 );
                        }
                        items[j].ID.LyricHandle.L0.setConsonantAdjustmentList( adjustment );
                    }
                }

                CadenciiCommand run = new CadenciiCommand( VsqCommand.generateCommandEventReplaceRange( selected, items ) );
                AppManager.editHistory.register( vsq.executeCommand( run ) );
                setEdited( true );
            }
        }

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index