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

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

歌詞の流し込みダイアログを開き,選択された音符を起点に歌詞を流し込みます

Definition at line 4959 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::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::cadencii::AppManager::itemSelection, org::kbinani::cadencii::SelectedEventEntry::original, org::kbinani::vsq::Lyric::Phrase, org::kbinani::cadencii::EditHistoryModel::register(), org::kbinani::vsq::Lyric::setPhoneticSymbol(), org::kbinani::cadencii::AppManager::showModalDialog(), org::kbinani::vsq::VsqFile::Track, and org::kbinani::vsq::SymbolTableEntry::Word.

        {
            int start = 0;
            int selected = AppManager.getSelected();
            VsqFileEx vsq = AppManager.getVsqFile();
            VsqTrack vsq_track = vsq.Track.get( selected );
            int selectedid = AppManager.itemSelection.getLastEvent().original.InternalID;
            int numEvents = vsq_track.getEventCount();
            for ( int i = 0; i < numEvents; i++ ) {
                if ( selectedid == vsq_track.getEvent( i ).InternalID ) {
                    start = i;
                    break;
                }
            }
            int count = vsq_track.getEventCount() - 1 - start + 1;
            try {
                if ( mDialogImportLyric == null ) {
                    mDialogImportLyric = new FormImportLyric( count );
                } else {
                    mDialogImportLyric.setMaxNotes( count );
                }
                mDialogImportLyric.setLocation( getFormPreferedLocation( mDialogImportLyric ) );
                BDialogResult dr = AppManager.showModalDialog( mDialogImportLyric, this );
                if ( dr == BDialogResult.OK ) {
                    String[] phrases = mDialogImportLyric.getLetters();
#if DEBUG
                    foreach ( String s in phrases ) {
                        sout.println( "FormMain#importLyric; phrases; s=" + s );
                    }
#endif
                    int min = Math.Min( count, phrases.Length );
                    Vector<String> new_phrases = new Vector<String>();
                    Vector<String> new_symbols = new Vector<String>();
                    for ( int i = 0; i < phrases.Length; i++ ) {
                        SymbolTableEntry entry = SymbolTable.attatch( phrases[i] );
                        if ( new_phrases.size() + 1 > count ) {
                            break;
                        }
                        if ( entry == null ) {
                            new_phrases.add( phrases[i] );
                            new_symbols.add( "a" );
                        } else {
                            if ( entry.Word.IndexOf( '-' ) >= 0 ) {
                                // 分節に分割する必要がある
                                String[] spl = PortUtil.splitString( entry.Word, '\t' );
                                if ( new_phrases.size() + spl.Length > count ) {
                                    // 分節の全部を分割すると制限個数を超えてしまう
                                    // 分割せずにハイフンを付けたまま登録
                                    new_phrases.add( entry.Word.Replace( "\t", "" ) );
                                    new_symbols.add( entry.getSymbol() );
                                } else {
                                    String[] spl_symbol = PortUtil.splitString( entry.getRawSymbol(), '\t' );
                                    for ( int j = 0; j < spl.Length; j++ ) {
                                        new_phrases.add( spl[j] );
                                        new_symbols.add( spl_symbol[j] );
                                    }
                                }
                            } else {
                                // 分節に分割しない
                                new_phrases.add( phrases[i] );
                                new_symbols.add( entry.getSymbol() );
                            }
                        }
                    }
                    VsqEvent[] new_events = new VsqEvent[new_phrases.size()];
                    int indx = -1;
                    for ( Iterator<Integer> itr = vsq_track.indexIterator( IndexIteratorKind.NOTE ); itr.hasNext(); ) {
                        int index = itr.next();
                        if ( index < start ) {
                            continue;
                        }
                        indx++;
                        VsqEvent item = vsq_track.getEvent( index );
                        new_events[indx] = (VsqEvent)item.clone();
                        new_events[indx].ID.LyricHandle.L0.Phrase = new_phrases.get( indx );
                        new_events[indx].ID.LyricHandle.L0.setPhoneticSymbol( new_symbols.get( indx ) );
                        AppManager.applyUtauParameter( vsq_track, new_events[indx] );
                        if ( indx + 1 >= new_phrases.size() ) {
                            break;
                        }
                    }
                    CadenciiCommand run = new CadenciiCommand(
                        VsqCommand.generateCommandEventReplaceRange( selected, new_events ) );
                    AppManager.editHistory.register( vsq.executeCommand( run ) );
                    setEdited( true );
                    repaint();
                }
            } catch ( Exception ex ) {
                Logger.write( typeof( FormMain ) + ".importLyric; ex=" + ex + "\n" );
            } finally {
                mDialogImportLyric.setVisible( false );
            }
        }

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index