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

void org::kbinani::cadencii::FormMain::fixAddingEvent (  ) [inline, private]

現在追加しようとしている音符の内容(AppManager.mAddingEvent)をfixします

Returns:

Definition at line 1439 of file FormMain.cs.

References org::kbinani::cadencii::UtauVoiceDB::attachFileNameFromLyric(), org::kbinani::cadencii::EditorConfig::AutoVibratoThresholdLength, org::kbinani::vsq::VsqEvent::clone(), org::kbinani::vsq::VsqTrack::clone(), org::kbinani::cadencii::EditorConfig::createAutoVibrato(), org::kbinani::cadencii::AppManager::editHistory, org::kbinani::cadencii::AppManager::editorConfig, org::kbinani::cadencii::EditorConfig::EnableAutoVibrato, org::kbinani::cadencii::AppManager::getSelected(), org::kbinani::vsq::VsqTrack::getSingerEventAt(), org::kbinani::vsq::VsqFile::getTimesigAt(), org::kbinani::cadencii::VsqFileEx::getTrackRendererKind(), org::kbinani::cadencii::AppManager::getVsqFile(), org::kbinani::cadencii::AppManager::mAddingEvent, org::kbinani::cadencii::AppManager::mAutoNormalize, org::kbinani::cadencii::AppManager::mUtauVoiceDB, org::kbinani::vsq::Lyric::Phrase, org::kbinani::cadencii::EditHistoryModel::register(), org::kbinani::vsq::VsqFile::Track, and org::kbinani::vsq::SingerConfig::VOICEIDSTR.

        {
            VsqFileEx vsq = AppManager.getVsqFile();
            int selected = AppManager.getSelected();
            VsqTrack vsq_track = vsq.Track.get( selected );
            LyricHandle lyric = new LyricHandle( "あ", "a" );
            VibratoHandle vibrato = null;
            int vibrato_delay = 0;
            if ( AppManager.editorConfig.EnableAutoVibrato ) {
                int note_length = AppManager.mAddingEvent.ID.getLength();
                // 音符位置での拍子を調べる
                Timesig timesig = vsq.getTimesigAt( AppManager.mAddingEvent.Clock );

                // ビブラートを自動追加するかどうかを決める閾値
                int threshold = AppManager.editorConfig.AutoVibratoThresholdLength;
                if ( note_length >= threshold ) {
                    int vibrato_clocks = 0;
                    if ( AppManager.editorConfig.DefaultVibratoLength == DefaultVibratoLengthEnum.L100 ) {
                        vibrato_clocks = note_length;
                    } else if ( AppManager.editorConfig.DefaultVibratoLength == DefaultVibratoLengthEnum.L50 ) {
                        vibrato_clocks = note_length / 2;
                    } else if ( AppManager.editorConfig.DefaultVibratoLength == DefaultVibratoLengthEnum.L66 ) {
                        vibrato_clocks = note_length * 2 / 3;
                    } else if ( AppManager.editorConfig.DefaultVibratoLength == DefaultVibratoLengthEnum.L75 ) {
                        vibrato_clocks = note_length * 3 / 4;
                    }
                    SynthesizerType type = SynthesizerType.VOCALOID2;
                    RendererKind kind = VsqFileEx.getTrackRendererKind( vsq.Track.get( selected ) );
                    if ( kind == RendererKind.VOCALOID1 ) {
                        type = SynthesizerType.VOCALOID1;
                    }
                    vibrato = AppManager.editorConfig.createAutoVibrato( type, vibrato_clocks );
                    vibrato_delay = note_length - vibrato_clocks;
                }
            }

            // oto.iniの設定を反映
            VsqEvent item = vsq_track.getSingerEventAt( AppManager.mAddingEvent.Clock );
            SingerConfig singerConfig = null;
            if ( item != null && item.ID != null && item.ID.IconHandle != null ) {
                singerConfig = AppManager.getSingerInfoUtau( item.ID.IconHandle.Language, item.ID.IconHandle.Program );
            }

            if ( singerConfig != null && AppManager.mUtauVoiceDB.containsKey( singerConfig.VOICEIDSTR ) ) {
                UtauVoiceDB utauVoiceDb = AppManager.mUtauVoiceDB.get( singerConfig.VOICEIDSTR );
                OtoArgs otoArgs = utauVoiceDb.attachFileNameFromLyric( lyric.L0.Phrase );
                AppManager.mAddingEvent.UstEvent.setPreUtterance( otoArgs.msPreUtterance );
                AppManager.mAddingEvent.UstEvent.setVoiceOverlap( otoArgs.msOverlap );
            }

            // 自動ノーマライズのモードで、処理を分岐
            if ( AppManager.mAutoNormalize ) {
                VsqTrack work = (VsqTrack)vsq_track.clone();
                AppManager.mAddingEvent.ID.type = VsqIDType.Anote;
                AppManager.mAddingEvent.ID.Dynamics = 64;
                AppManager.mAddingEvent.ID.VibratoHandle = vibrato;
                AppManager.mAddingEvent.ID.LyricHandle = lyric;
                AppManager.mAddingEvent.ID.VibratoDelay = vibrato_delay;

                boolean changed = true;
                while ( changed ) {
                    changed = false;
                    for ( int i = 0; i < work.getEventCount(); i++ ) {
                        int start_clock = work.getEvent( i ).Clock;
                        int end_clock = work.getEvent( i ).ID.getLength() + start_clock;
                        if ( start_clock < AppManager.mAddingEvent.Clock && AppManager.mAddingEvent.Clock < end_clock ) {
                            work.getEvent( i ).ID.setLength( AppManager.mAddingEvent.Clock - start_clock );
                            changed = true;
                        } else if ( start_clock == AppManager.mAddingEvent.Clock ) {
                            work.removeEvent( i );
                            changed = true;
                            break;
                        } else if ( AppManager.mAddingEvent.Clock < start_clock && start_clock < AppManager.mAddingEvent.Clock + AppManager.mAddingEvent.ID.getLength() ) {
                            AppManager.mAddingEvent.ID.setLength( start_clock - AppManager.mAddingEvent.Clock );
                            changed = true;
                        }
                    }
                }
                VsqEvent add = (VsqEvent)AppManager.mAddingEvent.clone();
                work.addEvent( add );
                CadenciiCommand run = VsqFileEx.generateCommandTrackReplace( selected,
                                                                             work,
                                                                             AppManager.getVsqFile().AttachedCurves.get( selected - 1 ) );
                AppManager.editHistory.register( AppManager.getVsqFile().executeCommand( run ) );
                setEdited( true );
            } else {
                VsqEvent[] items = new VsqEvent[1];
                AppManager.mAddingEvent.ID.type = VsqIDType.Anote;
                AppManager.mAddingEvent.ID.Dynamics = 64;
                items[0] = (VsqEvent)AppManager.mAddingEvent.clone();// new VsqEvent( 0, AppManager.addingEvent.ID );
                items[0].Clock = AppManager.mAddingEvent.Clock;
                items[0].ID.LyricHandle = lyric;
                items[0].ID.VibratoDelay = vibrato_delay;
                items[0].ID.VibratoHandle = vibrato;

                CadenciiCommand run = new CadenciiCommand( VsqCommand.generateCommandEventAddRange( AppManager.getSelected(), items ) );
                AppManager.editHistory.register( AppManager.getVsqFile().executeCommand( run ) );
                setEdited( true );
            }
        }

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index