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

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

描画すべきオブジェクトのリスト,AppManager.drawObjectsを更新します

Definition at line 6377 of file FormMain.cs.

References org::kbinani::cadencii::UtauVoiceDB::attachFileNameFromLyric(), org::kbinani::cadencii::AppManager::DYNAFF_ITEM_WIDTH, org::kbinani::cadencii::AppManager::editorConfig, org::kbinani::vsq::VsqTrack::getDynamicsEventIterator(), org::kbinani::vsq::VsqTrack::getNoteEventIterator(), org::kbinani::vsq::Lyric::getPhoneticSymbol(), org::kbinani::vsq::VsqTrack::getSingerEventAt(), org::kbinani::vsq::IconDynamicsHandle::getStartDyn(), org::kbinani::cadencii::VsqFileEx::getTrackRendererKind(), org::kbinani::cadencii::AppManager::getVsqFile(), org::kbinani::vsq::IconDynamicsHandle::IDS, org::kbinani::vsq::VsqEvent::InternalID, org::kbinani::vsq::IconDynamicsHandle::isCrescendType(), org::kbinani::vsq::IconDynamicsHandle::isDecrescendType(), org::kbinani::vsq::IconDynamicsHandle::isDynaffType(), org::kbinani::cadencii::AppManager::keyOffset, org::kbinani::cadencii::DrawObject::mClock, org::kbinani::cadencii::AppManager::mDrawIsUtau, org::kbinani::cadencii::AppManager::mDrawObjects, org::kbinani::cadencii::AppManager::mDrawStartIndex, org::kbinani::cadencii::DrawObject::mIsOverlapped, org::kbinani::cadencii::DrawObject::mLength, org::kbinani::cadencii::AppManager::mUtauVoiceDB, org::kbinani::vsq::Lyric::Phrase, org::kbinani::vsq::VsqFile::Track, org::kbinani::cadencii::Utility::trimString(), and org::kbinani::vsq::SingerConfig::VOICEIDSTR.

        {
            // AppManager.m_draw_objects
            if ( AppManager.mDrawObjects == null ) {
                AppManager.mDrawObjects = new Vector<Vector<DrawObject>>();
            }
            lock ( AppManager.mDrawObjects ) {
                if ( AppManager.getVsqFile() == null ) {
                    return;
                }
                for ( int i = 0; i < AppManager.mDrawStartIndex.Length; i++ ) {
                    AppManager.mDrawStartIndex[i] = 0;
                }
                if ( AppManager.mDrawObjects != null ) {
                    for ( Iterator<Vector<DrawObject>> itr = AppManager.mDrawObjects.iterator(); itr.hasNext(); ) {
                        Vector<DrawObject> list = itr.next();
                        list.clear();
                    }
                    AppManager.mDrawObjects.clear();
                }

                int xoffset = AppManager.keyOffset;// 6 + AppManager.keyWidth;
                int yoffset = (int)(127 * (int)(100 * controller.getScaleY()));
                float scalex = controller.getScaleX();
                Font SMALL_FONT = null;
                try {
                    SMALL_FONT = new Font( AppManager.editorConfig.ScreenFontName, java.awt.Font.PLAIN, AppManager.FONT_SIZE8 );
                    int track_height = (int)(100 * controller.getScaleY());
                    VsqFileEx vsq = AppManager.getVsqFile();
                    int track_count = vsq.Track.size();
                    Polygon env = new Polygon( new int[7], new int[7], 7 );
                    ByRef<Integer> overlap_x = new ByRef<Integer>( 0 );
                    for ( int track = 1; track < track_count; track++ ) {
                        VsqTrack vsq_track = vsq.Track.get( track );
                        Vector<DrawObject> tmp = new Vector<DrawObject>();
                        RendererKind kind = VsqFileEx.getTrackRendererKind( vsq_track );
                        AppManager.mDrawIsUtau[track - 1] = kind == RendererKind.UTAU;

                        // 音符イベント
                        Iterator<VsqEvent> itr_note = vsq_track.getNoteEventIterator();
                        VsqEvent item_prev = null;
                        VsqEvent item = null;
                        VsqEvent item_next = itr_note.hasNext() ? itr_note.next() : null;
                        while ( item_prev != null || item != null || item_next != null ) {
                            item_prev = item;
                            item = item_next;
                            if ( itr_note.hasNext() ) {
                                item_next = itr_note.next();
                            } else {
                                item_next = null;
                            }
                            if ( item == null ) {
                                continue;
                            }
                            if ( item.ID.LyricHandle == null ) {
                                continue;
                            }
                            int timesig = item.Clock;
                            int length = item.ID.getLength();
                            int note = item.ID.Note;
                            int x = (int)(timesig * scalex + xoffset);
                            int y = -note * track_height + yoffset;
                            int lyric_width = (int)(length * scalex);
                            String lyric_jp = item.ID.LyricHandle.L0.Phrase;
                            String lyric_en = item.ID.LyricHandle.L0.getPhoneticSymbol();
                            String title = Utility.trimString( lyric_jp + " [" + lyric_en + "]", SMALL_FONT, lyric_width );
                            int accent = item.ID.DEMaccent;
                            int px_vibrato_start = x + lyric_width;
                            int px_vibrato_end = x;
                            int px_vibrato_delay = lyric_width * 2;
                            int vib_delay = length;
                            if ( item.ID.VibratoHandle != null ) {
                                vib_delay = item.ID.VibratoDelay;
                                double rate = (double)vib_delay / (double)length;
                                px_vibrato_delay = _PX_ACCENT_HEADER + (int)((lyric_width - _PX_ACCENT_HEADER) * rate);
                            }
                            VibratoBPList rate_bp = null;
                            VibratoBPList depth_bp = null;
                            int rate_start = 0;
                            int depth_start = 0;
                            if ( item.ID.VibratoHandle != null ) {
                                rate_bp = item.ID.VibratoHandle.getRateBP();
                                depth_bp = item.ID.VibratoHandle.getDepthBP();
                                rate_start = item.ID.VibratoHandle.getStartRate();
                                depth_start = item.ID.VibratoHandle.getStartDepth();
                            }

                            // analyzed/のSTFが引き当てられるかどうか
                            // UTAUのWAVが引き当てられるかどうか
                            boolean is_valid_for_utau = false;
                            VsqEvent singer_at_clock = vsq_track.getSingerEventAt( timesig );
                            int program = singer_at_clock.ID.IconHandle.Program;
                            if ( 0 <= program && program < AppManager.editorConfig.UtauSingers.size() ) {
                                SingerConfig sc = AppManager.editorConfig.UtauSingers.get( program );
                                // 通常のUTAU音源
                                if ( AppManager.mUtauVoiceDB.containsKey( sc.VOICEIDSTR ) ) {
                                    UtauVoiceDB db = AppManager.mUtauVoiceDB.get( sc.VOICEIDSTR );
                                    OtoArgs oa = db.attachFileNameFromLyric( lyric_jp );
                                    if ( oa.fileName == null ||
                                        (oa.fileName != null && str.compare( oa.fileName, "" )) ) {
                                        is_valid_for_utau = false;
                                    } else {
                                        is_valid_for_utau = fsys.isFileExists( fsys.combine( sc.VOICEIDSTR, oa.fileName ) );
                                    }
                                }
                            }
                            int intensity = item.UstEvent == null ? 100 : item.UstEvent.getIntensity();

                            //追加
                            tmp.add( new DrawObject( DrawObjectType.Note,
                                                     vsq,
                                                     new Rectangle( x, y, lyric_width, track_height ),
                                                     title,
                                                     accent,
                                                     item.ID.DEMdecGainRate,
                                                     item.ID.Dynamics,
                                                     item.InternalID,
                                                     px_vibrato_delay,
                                                     false,
                                                     item.ID.LyricHandle.L0.PhoneticSymbolProtected,
                                                     rate_bp,
                                                     depth_bp,
                                                     rate_start,
                                                     depth_start,
                                                     item.ID.Note,
                                                     item.UstEvent.getEnvelope(),
                                                     length,
                                                     timesig,
                                                     is_valid_for_utau,
                                                     is_valid_for_utau, // vConnect-STANDはstfファイルを必要としないので,
                                                     vib_delay,
                                                     intensity ) );
                        }

                        // Dynaff, Crescendイベント
                        for ( Iterator<VsqEvent> itr = vsq_track.getDynamicsEventIterator(); itr.hasNext(); ) {
                            VsqEvent item_itr = itr.next();
                            IconDynamicsHandle handle = item_itr.ID.IconDynamicsHandle;
                            if ( handle == null ) {
                                continue;
                            }
                            int clock = item_itr.Clock;
                            int length = item_itr.ID.getLength();
                            if ( length <= 0 ) {
                                length = 1;
                            }
                            int raw_width = (int)(length * scalex);
                            DrawObjectType type = DrawObjectType.Note;
                            int width = 0;
                            String str = "";
                            if ( handle.isDynaffType() ) {
                                // 強弱記号
                                type = DrawObjectType.Dynaff;
                                width = AppManager.DYNAFF_ITEM_WIDTH;
                                int startDyn = handle.getStartDyn();
                                if ( startDyn == 120 ) {
                                    str = "fff";
                                } else if ( startDyn == 104 ) {
                                    str = "ff";
                                } else if ( startDyn == 88 ) {
                                    str = "f";
                                } else if ( startDyn == 72 ) {
                                    str = "mf";
                                } else if ( startDyn == 56 ) {
                                    str = "mp";
                                } else if ( startDyn == 40 ) {
                                    str = "p";
                                } else if ( startDyn == 24 ) {
                                    str = "pp";
                                } else if ( startDyn == 8 ) {
                                    str = "ppp";
                                } else {
                                    str = "?";
                                }
                            } else if ( handle.isCrescendType() ) {
                                // クレッシェンド
                                type = DrawObjectType.Crescend;
                                width = raw_width;
                                str = handle.IDS;
                            } else if ( handle.isDecrescendType() ) {
                                // デクレッシェンド
                                type = DrawObjectType.Decrescend;
                                width = raw_width;
                                str = handle.IDS;
                            }
                            if ( type == DrawObjectType.Note ) {
                                continue;
                            }
                            int note = item_itr.ID.Note;
                            int x = (int)(clock * scalex + xoffset);
                            int y = -note * (int)(100 * controller.getScaleY()) + yoffset;
                            tmp.add( new DrawObject( type,
                                                     vsq,
                                                     new Rectangle( x, y, width, track_height ),
                                                     str,
                                                     0,
                                                     0,
                                                     0,
                                                     item_itr.InternalID,
                                                     0,
                                                     false,
                                                     false,
                                                     null,
                                                     null,
                                                     0,
                                                     0,
                                                     item_itr.ID.Note,
                                                     null,
                                                     length,
                                                     clock,
                                                     true,
                                                     true,
                                                     length,
                                                     0 ) );
                        }

                        // 重複部分があるかどうかを判定
                        int count = tmp.size();
                        for ( int i = 0; i < count - 1; i++ ) {
                            DrawObject itemi = tmp.get( i );
                            DrawObjectType parent_type = itemi.mType;
                            /*if ( itemi.type != DrawObjectType.Note ) {
                                continue;
                            }*/
                            boolean overwrapped = false;
                            int istart = itemi.mClock;
                            int iend = istart + itemi.mLength;
                            if ( itemi.mIsOverlapped ) {
                                continue;
                            }
                            for ( int j = i + 1; j < count; j++ ) {
                                DrawObject itemj = tmp.get( j );
                                if ( (itemj.mType == DrawObjectType.Note && parent_type != DrawObjectType.Note) ||
                                     (itemj.mType != DrawObjectType.Note && parent_type == DrawObjectType.Note) ) {
                                    continue;
                                }
                                int jstart = itemj.mClock;
                                int jend = jstart + itemj.mLength;
                                if ( jstart <= istart ) {
                                    if ( istart < jend ) {
                                        overwrapped = true;
                                        itemj.mIsOverlapped = true;
                                        // breakできない.2個以上の重複を検出する必要があるので.
                                    }
                                }
                                if ( istart <= jstart ) {
                                    if ( jstart < iend ) {
                                        overwrapped = true;
                                        itemj.mIsOverlapped = true;
                                    }
                                }
                            }
                            if ( overwrapped ) {
                                itemi.mIsOverlapped = true;
                            }
                        }
                        Collections.sort( tmp );
                        AppManager.mDrawObjects.add( tmp );
                    }
                } catch ( Exception ex ) {
                    Logger.write( typeof( FormMain ) + ".updateDrawObjectList; ex=" + ex + "\n" );
                    serr.println( "FormMain#updateDrawObjectList; ex=" + ex );
#if JAVA
                    ex.printStackTrace();
#endif
                } finally {
#if !JAVA
                    if ( SMALL_FONT != null ) {
                        SMALL_FONT.font.Dispose();
                    }
#endif
                }
            }
        }

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index