/// <summary>
        /// 合成器が使用可能かどうかを元に、メニューのアイコンを更新する
        /// </summary>
        /// <param name="config">エディタの設定情報</param>
        public void updateRendererAvailability(EditorConfig config)
        {
            string wine_prefix = config.WinePrefix;
            string wine_top    = config.WineTop;
            Image  icon        = null;

            if (!VSTiDllManager.isRendererAvailable(kind_, wine_prefix, wine_top))
            {
                icon = Properties.Resources.slash;
            }
            if (track_menu_ != null)
            {
                track_menu_.Image = icon;
            }
            if (context_menu_ != null)
            {
                context_menu_.Image = icon;
            }
        }
        public static void GenerateSinglePhone(int note, string singer, string file, double amp)
        {
            string renderer = "";

            SingerConfig[] singers1             = VocaloSysUtil.getSingerConfigs(SynthesizerType.VOCALOID1);
            int            c                    = singers1.Length;
            string         first_found_singer   = "";
            string         first_found_renderer = "";

            for (int i = 0; i < c; i++)
            {
                if (first_found_singer.Equals(""))
                {
                    first_found_singer   = singers1[i].VOICENAME;
                    first_found_renderer = VsqFileEx.RENDERER_DSB2;
                }
                if (singers1[i].VOICENAME.Equals(singer))
                {
                    renderer = VsqFileEx.RENDERER_DSB2;
                    break;
                }
            }

            SingerConfig[] singers2 = VocaloSysUtil.getSingerConfigs(SynthesizerType.VOCALOID2);
            c = singers2.Length;
            for (int i = 0; i < c; i++)
            {
                if (first_found_singer.Equals(""))
                {
                    first_found_singer   = singers2[i].VOICENAME;
                    first_found_renderer = VsqFileEx.RENDERER_DSB3;
                }
                if (singers2[i].VOICENAME.Equals(singer))
                {
                    renderer = VsqFileEx.RENDERER_DSB3;
                    break;
                }
            }

            foreach (var sc in AppManager.editorConfig.UtauSingers)
            {
                if (first_found_singer.Equals(""))
                {
                    first_found_singer   = sc.VOICENAME;
                    first_found_renderer = VsqFileEx.RENDERER_UTU0;
                }
                if (sc.VOICENAME.Equals(singer))
                {
                    renderer = VsqFileEx.RENDERER_UTU0;
                    break;
                }
            }

            VsqFileEx vsq = new VsqFileEx(singer, 1, 4, 4, 500000);

            if (renderer.Equals(""))
            {
                singer   = first_found_singer;
                renderer = first_found_renderer;
            }
            vsq.Track[1].getCommon().Version = renderer;
            VsqEvent item = new VsqEvent(1920, new VsqID(0));

            item.ID.LyricHandle = new LyricHandle("あ", "a");
            item.ID.setLength(480);
            item.ID.Note          = note;
            item.ID.VibratoHandle = null;
            item.ID.type          = VsqIDType.Anote;
            vsq.Track[1].addEvent(item);
            vsq.updateTotalClocks();
            int    ms_presend = 500;
            string tempdir    = Path.Combine(AppManager.getCadenciiTempDir(), AppManager.getID());

            if (!Directory.Exists(tempdir))
            {
                try {
                    PortUtil.createDirectory(tempdir);
                } catch (Exception ex) {
                    Logger.write(typeof(FormGenerateKeySound) + ".GenerateSinglePhone; ex=" + ex + "\n");
                    serr.println("Program#GenerateSinglePhone; ex=" + ex);
                    return;
                }
            }
            WaveWriter ww = null;

            try {
                ww = new WaveWriter(file);
                RendererKind     kind        = VsqFileEx.getTrackRendererKind(vsq.Track[1]);
                WaveGenerator    generator   = VSTiDllManager.getWaveGenerator(kind);
                int              sample_rate = vsq.config.SamplingRate;
                FileWaveReceiver receiver    = new FileWaveReceiver(file, 1, 16, sample_rate);
                generator.setReceiver(receiver);
                generator.setGlobalConfig(AppManager.editorConfig);
#if DEBUG
                sout.println("FormGenerateKeySound#GenerateSinglePhone; sample_rate=" + sample_rate);
#endif
                generator.init(vsq, 1, 0, vsq.TotalClocks, sample_rate);
                double         total_sec = vsq.getSecFromClock(vsq.TotalClocks) + 1.0;
                WorkerStateImp state     = new WorkerStateImp();
                generator.begin((long)(total_sec * sample_rate), state);
            } catch (Exception ex) {
                serr.println("FormGenerateKeySound#GenerateSinglePhone; ex=" + ex);
                Logger.write(typeof(FormGenerateKeySound) + ".GenerateSinglePhone; ex=" + ex + "\n");
            } finally {
                if (ww != null)
                {
                    try {
                        ww.close();
                    } catch (Exception ex2) {
                        Logger.write(typeof(FormGenerateKeySound) + ".GenerateSinglePhone; ex=" + ex2 + "\n");
                        serr.println("FormGenerateKeySound#GenerateSinglePhone; ex2=" + ex2);
                    }
                }
            }
        }
 public void Program_FormClosed(Object sender, FormClosedEventArgs e)
 {
     VSTiDllManager.terminate();
 }
Exemple #4
0
        public void showPrefs(Form Parent, System.Drawing.Point location, bool showVBCfg)
        {
            try {
                if (mDialogPreference == null)
                {
                    mDialogPreference = new Preference();
                }
                mDialogPreference.setBaseFont(new Font(AppManager.editorConfig.BaseFontName, java.awt.Font.PLAIN, AppManager.FONT_SIZE9));
                mDialogPreference.setScreenFont(new Font(AppManager.editorConfig.ScreenFontName, java.awt.Font.PLAIN, AppManager.FONT_SIZE9));
                mDialogPreference.setWheelOrder(AppManager.editorConfig.WheelOrder);
                mDialogPreference.setCursorFixed(AppManager.editorConfig.CursorFixed);
                mDialogPreference.setDefaultVibratoLength(AppManager.editorConfig.DefaultVibratoLength);
                mDialogPreference.setAutoVibratoThresholdLength(AppManager.editorConfig.AutoVibratoThresholdLength);
                mDialogPreference.setAutoVibratoType1(AppManager.editorConfig.AutoVibratoType1);
                mDialogPreference.setAutoVibratoType2(AppManager.editorConfig.AutoVibratoType2);
                mDialogPreference.setAutoVibratoTypeCustom(AppManager.editorConfig.AutoVibratoTypeCustom);
                mDialogPreference.setEnableAutoVibrato(AppManager.editorConfig.EnableAutoVibrato);
                mDialogPreference.setPreSendTime(AppManager.editorConfig.PreSendTime);
                mDialogPreference.setControlCurveResolution(AppManager.editorConfig.ControlCurveResolution);
                mDialogPreference.setDefaultSingerName(AppManager.editorConfig.DefaultSingerName);
                mDialogPreference.setScrollHorizontalOnWheel(AppManager.editorConfig.ScrollHorizontalOnWheel);
                mDialogPreference.setMaximumFrameRate(AppManager.editorConfig.MaximumFrameRate);
                mDialogPreference.setKeepLyricInputMode(AppManager.editorConfig.KeepLyricInputMode);
                mDialogPreference.setPxTrackHeight(AppManager.editorConfig.PxTrackHeight);
                mDialogPreference.setMouseHoverTime(AppManager.editorConfig.getMouseHoverTime());
                mDialogPreference.setPlayPreviewWhenRightClick(AppManager.editorConfig.PlayPreviewWhenRightClick);
                mDialogPreference.setCurveSelectingQuantized(AppManager.editorConfig.CurveSelectingQuantized);
                mDialogPreference.setCurveVisibleAccent(AppManager.editorConfig.CurveVisibleAccent);
                mDialogPreference.setCurveVisibleBre(AppManager.editorConfig.CurveVisibleBreathiness);
                mDialogPreference.setCurveVisibleBri(AppManager.editorConfig.CurveVisibleBrightness);
                mDialogPreference.setCurveVisibleCle(AppManager.editorConfig.CurveVisibleClearness);
                mDialogPreference.setCurveVisibleDecay(AppManager.editorConfig.CurveVisibleDecay);
                mDialogPreference.setCurveVisibleDyn(AppManager.editorConfig.CurveVisibleDynamics);
                mDialogPreference.setCurveVisibleGen(AppManager.editorConfig.CurveVisibleGendorfactor);
                mDialogPreference.setCurveVisibleOpe(AppManager.editorConfig.CurveVisibleOpening);
                mDialogPreference.setCurveVisiblePit(AppManager.editorConfig.CurveVisiblePit);
                mDialogPreference.setCurveVisiblePbs(AppManager.editorConfig.CurveVisiblePbs);
                mDialogPreference.setCurveVisiblePor(AppManager.editorConfig.CurveVisiblePortamento);
                mDialogPreference.setCurveVisibleVel(AppManager.editorConfig.CurveVisibleVelocity);
                mDialogPreference.setCurveVisibleVibratoDepth(AppManager.editorConfig.CurveVisibleVibratoDepth);
                mDialogPreference.setCurveVisibleVibratoRate(AppManager.editorConfig.CurveVisibleVibratoRate);
                mDialogPreference.setCurveVisibleFx2Depth(AppManager.editorConfig.CurveVisibleFx2Depth);
                mDialogPreference.setCurveVisibleHarmonics(AppManager.editorConfig.CurveVisibleHarmonics);
                mDialogPreference.setCurveVisibleReso1(AppManager.editorConfig.CurveVisibleReso1);
                mDialogPreference.setCurveVisibleReso2(AppManager.editorConfig.CurveVisibleReso2);
                mDialogPreference.setCurveVisibleReso3(AppManager.editorConfig.CurveVisibleReso3);
                mDialogPreference.setCurveVisibleReso4(AppManager.editorConfig.CurveVisibleReso4);
                mDialogPreference.setCurveVisibleEnvelope(AppManager.editorConfig.CurveVisibleEnvelope);
#if ENABLE_MIDI
                mDialogPreference.setMidiInPort(AppManager.editorConfig.MidiInPort.PortNumber);
#endif
#if ENABLE_MTC
                m_preference_dlg.setMtcMidiInPort(AppManager.editorConfig.MidiInPortMtc.PortNumber);
#endif
                Vector <String>  resamplers = new Vector <String>();
                Vector <Boolean> with_wine  = new Vector <Boolean>();
                int size = AppManager.editorConfig.getResamplerCount();
                for (int i = 0; i < size; i++)
                {
                    resamplers.add(AppManager.editorConfig.getResamplerAt(i));
                    with_wine.add(AppManager.editorConfig.isResamplerWithWineAt(i));
                }
                mDialogPreference.setResamplersConfig(resamplers, with_wine);
                mDialogPreference.setPathWavtool(AppManager.editorConfig.PathWavtool);
                mDialogPreference.setWavtoolWithWine(AppManager.editorConfig.WavtoolWithWine);
                mDialogPreference.setUtausingers(AppManager.editorConfig.UtauSingers);
                mDialogPreference.setSelfDeRomantization(AppManager.editorConfig.SelfDeRomanization);
                mDialogPreference.setAutoBackupIntervalMinutes(AppManager.editorConfig.AutoBackupIntervalMinutes);
                mDialogPreference.setUseSpaceKeyAsMiddleButtonModifier(AppManager.editorConfig.UseSpaceKeyAsMiddleButtonModifier);
                mDialogPreference.setPathAquesTone(AppManager.editorConfig.PathAquesTone);
                mDialogPreference.setPathAquesTone2(AppManager.editorConfig.PathAquesTone2);
                mDialogPreference.setUseProjectCache(AppManager.editorConfig.UseProjectCache);
                mDialogPreference.setAquesToneRequired(!AppManager.editorConfig.DoNotUseAquesTone);
                mDialogPreference.setAquesTone2Requried(!AppManager.editorConfig.DoNotUseAquesTone2);
                mDialogPreference.setVocaloid1Required(!AppManager.editorConfig.DoNotUseVocaloid1);
                mDialogPreference.setVocaloid2Required(!AppManager.editorConfig.DoNotUseVocaloid2);
                mDialogPreference.setBufferSize(AppManager.editorConfig.BufferSizeMilliSeconds);
                mDialogPreference.setDefaultSynthesizer(AppManager.editorConfig.DefaultSynthesizer);
                mDialogPreference.setUseUserDefinedAutoVibratoType(AppManager.editorConfig.UseUserDefinedAutoVibratoType);
                mDialogPreference.setWinePrefix(AppManager.editorConfig.WinePrefix);
                mDialogPreference.setWineTop(AppManager.editorConfig.WineTop);
                mDialogPreference.setWineBuiltin(AppManager.editorConfig.WineTopBuiltin);
                mDialogPreference.setEnableWideCharacterWorkaround(AppManager.editorConfig.UseWideCharacterWorkaround);

                String old_wine_prefix = AppManager.editorConfig.WinePrefix;
                String old_wine_top    = AppManager.editorConfig.getWineTop();

                mDialogPreference.Location = location;

                //Show the special voicebank config menu if it's requested
                if (showVBCfg)
                {
                    mDialogPreference.showEasySetupUtauVB();
                }

                DialogResult dr = AppManager.showModalDialog(mDialogPreference, Parent);
                if (dr == DialogResult.OK)
                {
                    String old_base_font_name = AppManager.editorConfig.BaseFontName;
                    float  old_base_font_size = AppManager.editorConfig.BaseFontSize;
                    Font   new_base_font      = mDialogPreference.getBaseFont();
                    if (!old_base_font_name.Equals(new_base_font.getName()) ||
                        old_base_font_size != new_base_font.getSize2D())
                    {
                        AppManager.editorConfig.BaseFontName = mDialogPreference.getBaseFont().getName();
                        AppManager.editorConfig.BaseFontSize = mDialogPreference.getBaseFont().getSize2D();
                        //updateMenuFonts();
                    }

                    AppManager.editorConfig.ScreenFontName = mDialogPreference.getScreenFont().getName();
                    AppManager.editorConfig.WheelOrder     = mDialogPreference.getWheelOrder();
                    AppManager.editorConfig.CursorFixed    = mDialogPreference.isCursorFixed();

                    AppManager.editorConfig.DefaultVibratoLength       = mDialogPreference.getDefaultVibratoLength();
                    AppManager.editorConfig.AutoVibratoThresholdLength = mDialogPreference.getAutoVibratoThresholdLength();
                    AppManager.editorConfig.AutoVibratoType1           = mDialogPreference.getAutoVibratoType1();
                    AppManager.editorConfig.AutoVibratoType2           = mDialogPreference.getAutoVibratoType2();
                    AppManager.editorConfig.AutoVibratoTypeCustom      = mDialogPreference.getAutoVibratoTypeCustom();

                    AppManager.editorConfig.EnableAutoVibrato = mDialogPreference.isEnableAutoVibrato();
                    AppManager.editorConfig.PreSendTime       = mDialogPreference.getPreSendTime();
                    AppManager.editorConfig.Language          = mDialogPreference.getLanguage();
                    if (!Messaging.getLanguage().Equals(AppManager.editorConfig.Language))
                    {
                        Messaging.setLanguage(AppManager.editorConfig.Language);
                        //applyLanguage();
                        mDialogPreference.applyLanguage();
                        //AppManager.mMixerWindow.applyLanguage();
                        //if (mVersionInfo != null && !mVersionInfo.IsDisposed) {
                        //    mVersionInfo.applyLanguage();
                        //}
#if ENABLE_PROPERTY
                        AppManager.propertyWindow.applyLanguage();
                        AppManager.propertyPanel.updateValue(AppManager.getSelected());
#endif
                        //if (mDialogMidiImportAndExport != null) {
                        //    mDialogMidiImportAndExport.applyLanguage();
                        //}
                    }

                    AppManager.editorConfig.ControlCurveResolution  = mDialogPreference.getControlCurveResolution();
                    AppManager.editorConfig.DefaultSingerName       = mDialogPreference.getDefaultSingerName();
                    AppManager.editorConfig.ScrollHorizontalOnWheel = mDialogPreference.isScrollHorizontalOnWheel();
                    AppManager.editorConfig.MaximumFrameRate        = mDialogPreference.getMaximumFrameRate();
                    int fps = 1000 / AppManager.editorConfig.MaximumFrameRate;
                    //timer.Interval = (fps <= 0) ? 1 : fps;
                    //applyShortcut();
                    AppManager.editorConfig.KeepLyricInputMode = mDialogPreference.isKeepLyricInputMode();
                    if (AppManager.editorConfig.PxTrackHeight != mDialogPreference.getPxTrackHeight())
                    {
                        AppManager.editorConfig.PxTrackHeight = mDialogPreference.getPxTrackHeight();
                        //updateDrawObjectList();
                    }
                    AppManager.editorConfig.setMouseHoverTime(mDialogPreference.getMouseHoverTime());
                    AppManager.editorConfig.PlayPreviewWhenRightClick = mDialogPreference.isPlayPreviewWhenRightClick();
                    AppManager.editorConfig.CurveSelectingQuantized   = mDialogPreference.isCurveSelectingQuantized();

                    AppManager.editorConfig.CurveVisibleAccent       = mDialogPreference.isCurveVisibleAccent();
                    AppManager.editorConfig.CurveVisibleBreathiness  = mDialogPreference.isCurveVisibleBre();
                    AppManager.editorConfig.CurveVisibleBrightness   = mDialogPreference.isCurveVisibleBri();
                    AppManager.editorConfig.CurveVisibleClearness    = mDialogPreference.isCurveVisibleCle();
                    AppManager.editorConfig.CurveVisibleDecay        = mDialogPreference.isCurveVisibleDecay();
                    AppManager.editorConfig.CurveVisibleDynamics     = mDialogPreference.isCurveVisibleDyn();
                    AppManager.editorConfig.CurveVisibleGendorfactor = mDialogPreference.isCurveVisibleGen();
                    AppManager.editorConfig.CurveVisibleOpening      = mDialogPreference.isCurveVisibleOpe();
                    AppManager.editorConfig.CurveVisiblePit          = mDialogPreference.isCurveVisiblePit();
                    AppManager.editorConfig.CurveVisiblePbs          = mDialogPreference.isCurveVisiblePbs();
                    AppManager.editorConfig.CurveVisiblePortamento   = mDialogPreference.isCurveVisiblePor();
                    AppManager.editorConfig.CurveVisibleVelocity     = mDialogPreference.isCurveVisibleVel();
                    AppManager.editorConfig.CurveVisibleVibratoDepth = mDialogPreference.isCurveVisibleVibratoDepth();
                    AppManager.editorConfig.CurveVisibleVibratoRate  = mDialogPreference.isCurveVisibleVibratoRate();
                    AppManager.editorConfig.CurveVisibleFx2Depth     = mDialogPreference.isCurveVisibleFx2Depth();
                    AppManager.editorConfig.CurveVisibleHarmonics    = mDialogPreference.isCurveVisibleHarmonics();
                    AppManager.editorConfig.CurveVisibleReso1        = mDialogPreference.isCurveVisibleReso1();
                    AppManager.editorConfig.CurveVisibleReso2        = mDialogPreference.isCurveVisibleReso2();
                    AppManager.editorConfig.CurveVisibleReso3        = mDialogPreference.isCurveVisibleReso3();
                    AppManager.editorConfig.CurveVisibleReso4        = mDialogPreference.isCurveVisibleReso4();
                    AppManager.editorConfig.CurveVisibleEnvelope     = mDialogPreference.isCurveVisibleEnvelope();

#if ENABLE_MIDI
                    AppManager.editorConfig.MidiInPort.PortNumber = mDialogPreference.getMidiInPort();
#endif
#if ENABLE_MTC
                    AppManager.editorConfig.MidiInPortMtc.PortNumber = m_preference_dlg.getMtcMidiInPort();
#endif
#if ENABLE_MIDI || ENABLE_MTC
                    //updateMidiInStatus();
                    //reloadMidiIn();
#endif

                    Vector <String>  new_resamplers = new Vector <String>();
                    Vector <Boolean> new_with_wine  = new Vector <Boolean>();
                    mDialogPreference.copyResamplersConfig(new_resamplers, new_with_wine);
                    AppManager.editorConfig.clearResampler();
                    for (int i = 0; i < new_resamplers.size(); i++)
                    {
                        AppManager.editorConfig.addResampler(new_resamplers.get(i), new_with_wine.get(i));
                    }
                    AppManager.editorConfig.PathWavtool     = mDialogPreference.getPathWavtool();
                    AppManager.editorConfig.WavtoolWithWine = mDialogPreference.isWavtoolWithWine();

                    AppManager.editorConfig.UtauSingers.clear();
                    for (Iterator <SingerConfig> itr = mDialogPreference.getUtausingers().iterator(); itr.hasNext();)
                    {
                        SingerConfig sc = itr.next();
                        AppManager.editorConfig.UtauSingers.add((SingerConfig)sc.clone());
                    }
                    AppManager.reloadUtauVoiceDB();

                    AppManager.editorConfig.SelfDeRomanization                = mDialogPreference.isSelfDeRomantization();
                    AppManager.editorConfig.AutoBackupIntervalMinutes         = mDialogPreference.getAutoBackupIntervalMinutes();
                    AppManager.editorConfig.UseSpaceKeyAsMiddleButtonModifier = mDialogPreference.isUseSpaceKeyAsMiddleButtonModifier();

#if ENABLE_AQUESTONE
                    var old_aquestone_config = Tuple.Create(AppManager.editorConfig.PathAquesTone, AppManager.editorConfig.DoNotUseAquesTone);
                    AppManager.editorConfig.PathAquesTone     = mDialogPreference.getPathAquesTone();
                    AppManager.editorConfig.DoNotUseAquesTone = !mDialogPreference.isAquesToneRequired();
                    if (old_aquestone_config.Item1 != AppManager.editorConfig.PathAquesTone ||
                        old_aquestone_config.Item2 != AppManager.editorConfig.DoNotUseAquesTone)
                    {
                        VSTiDllManager.reloadAquesTone();
                    }

                    var old_aquestone2_config = Tuple.Create(AppManager.editorConfig.PathAquesTone2, AppManager.editorConfig.DoNotUseAquesTone2);
                    AppManager.editorConfig.PathAquesTone2     = mDialogPreference.getPathAquesTone2();
                    AppManager.editorConfig.DoNotUseAquesTone2 = !mDialogPreference.isAquesTone2Required();
                    if (old_aquestone2_config.Item1 != AppManager.editorConfig.PathAquesTone2 ||
                        old_aquestone2_config.Item2 != AppManager.editorConfig.DoNotUseAquesTone2)
                    {
                        VSTiDllManager.reloadAquesTone2();
                    }
#endif
                    //updateRendererMenu();

                    //AppManager.editorConfig.__revoked__WaveFileOutputFromMasterTrack = mDialogPreference.isWaveFileOutputFromMasterTrack();
                    //AppManager.editorConfig.__revoked__WaveFileOutputChannel = mDialogPreference.getWaveFileOutputChannel();
                    if (AppManager.editorConfig.UseProjectCache && !mDialogPreference.isUseProjectCache())
                    {
                        // プロジェクト用キャッシュを使用していたが,使用しないように変更された場合.
                        // プロジェクト用キャッシュが存在するなら,共用のキャッシュに移動する.
                        String file = AppManager.getFileName();
                        if (file != null && !file.Equals(""))
                        {
                            String dir             = PortUtil.getDirectoryName(file);
                            String name            = PortUtil.getFileNameWithoutExtension(file);
                            String projectCacheDir = Path.Combine(dir, name + ".cadencii");
                            String commonCacheDir  = Path.Combine(AppManager.getCadenciiTempDir(), AppManager.getID());
                            if (Directory.Exists(projectCacheDir))
                            {
                                VsqFileEx vsq = AppManager.getVsqFile();
                                for (int i = 1; i < vsq.Track.size(); i++)
                                {
                                    // wavを移動
                                    String wavFrom = Path.Combine(projectCacheDir, i + ".wav");
                                    String wavTo   = Path.Combine(commonCacheDir, i + ".wav");
                                    if (!System.IO.File.Exists(wavFrom))
                                    {
                                        continue;
                                    }
                                    if (System.IO.File.Exists(wavTo))
                                    {
                                        try {
                                            PortUtil.deleteFile(wavTo);
                                        }
                                        catch (Exception ex) {
                                            Logger.write(typeof(FormMain) + ".menuSettingPreference_Click; ex=" + ex + "\n");
                                            serr.println("FormMain#menuSettingPreference_Click; ex=" + ex);
                                            continue;
                                        }
                                    }
                                    try {
                                        PortUtil.moveFile(wavFrom, wavTo);
                                    }
                                    catch (Exception ex) {
                                        Logger.write(typeof(FormMain) + ".menuSettingPreference_Click; ex=" + ex + "\n");
                                        serr.println("FormMain#menuSettingPreference_Click; ex=" + ex);
                                    }

                                    // xmlを移動
                                    String xmlFrom = Path.Combine(projectCacheDir, i + ".xml");
                                    String xmlTo   = Path.Combine(commonCacheDir, i + ".xml");
                                    if (!System.IO.File.Exists(xmlFrom))
                                    {
                                        continue;
                                    }
                                    if (System.IO.File.Exists(xmlTo))
                                    {
                                        try {
                                            PortUtil.deleteFile(xmlTo);
                                        }
                                        catch (Exception ex) {
                                            Logger.write(typeof(FormMain) + ".menuSettingPreference_Click; ex=" + ex + "\n");
                                            serr.println("FormMain#menuSettingPreference_Click; ex=" + ex);
                                            continue;
                                        }
                                    }
                                    try {
                                        PortUtil.moveFile(xmlFrom, xmlTo);
                                    }
                                    catch (Exception ex) {
                                        Logger.write(typeof(FormMain) + ".menuSettingPreference_Click; ex=" + ex + "\n");
                                        serr.println("FormMain#menuSettingPreference_Click; ex=" + ex);
                                    }
                                }

                                // projectCacheDirが空なら,ディレクトリごと削除する
                                String[] files = PortUtil.listFiles(projectCacheDir, "*.*");
                                if (files.Length <= 0)
                                {
                                    try {
                                        PortUtil.deleteDirectory(projectCacheDir);
                                    }
                                    catch (Exception ex) {
                                        Logger.write(typeof(FormMain) + ".menuSettingPreference_Click; ex=" + ex + "\n");
                                        serr.println("FormMain#menuSettingPreference_Click; ex=" + ex);
                                    }
                                }

                                // キャッシュのディレクトリを再指定
                                AppManager.setTempWaveDir(commonCacheDir);
                            }
                        }
                    }
                    AppManager.editorConfig.UseProjectCache               = mDialogPreference.isUseProjectCache();
                    AppManager.editorConfig.DoNotUseVocaloid1             = !mDialogPreference.isVocaloid1Required();
                    AppManager.editorConfig.DoNotUseVocaloid2             = !mDialogPreference.isVocaloid2Required();
                    AppManager.editorConfig.BufferSizeMilliSeconds        = mDialogPreference.getBufferSize();
                    AppManager.editorConfig.DefaultSynthesizer            = mDialogPreference.getDefaultSynthesizer();
                    AppManager.editorConfig.UseUserDefinedAutoVibratoType = mDialogPreference.isUseUserDefinedAutoVibratoType();
                    AppManager.editorConfig.WinePrefix                 = mDialogPreference.getWinePrefix();
                    AppManager.editorConfig.WineTop                    = mDialogPreference.getWineTop();
                    AppManager.editorConfig.WineTopBuiltin             = mDialogPreference.isWineBuiltin();
                    AppManager.editorConfig.UseWideCharacterWorkaround = mDialogPreference.isEnableWideCharacterWorkaround();

                    //trackSelector.prepareSingerMenu(VsqFileEx.getTrackRendererKind(AppManager.getVsqFile().Track.get(AppManager.getSelected())));
                    //trackSelector.updateVisibleCurves();

                    //updateRendererMenu();
                    AppManager.updateAutoBackupTimerStatus();

                    // editorConfig.PxTrackHeightが変更されている可能性があるので,更新が必要
                    //controller.setStartToDrawY(calculateStartToDrawY(vScroll.Value));

                    //if (menuVisualControlTrack.Checked) {
                    //    splitContainer1.setPanel2MinSize(trackSelector.getPreferredMinSize());
                    //}

                    AppManager.saveConfig();
                    //applyLanguage();
#if ENABLE_SCRIPT
                    //updateScriptShortcut();
#endif

                    //updateDrawObjectList();
                    //refreshScreen();
                }
            }
            catch (Exception ex) {
                Logger.write(typeof(FormMain) + ".menuSettingPreference_Click; ex=" + ex + "\n");
                AppManager.debugWriteLine("FormMain#menuSettingPreference_Click; ex=" + ex);
            }
        }
        public void processQueue(WorkerState state, Object arg)
        {
#if DEBUG
            sout.println("SynthesizeWorker#processQueue");
#endif
            PatchWorkQueue q                = (PatchWorkQueue)arg;
            VsqFileEx      vsq              = q.vsq;
            int            channel          = vsq.config.WaveFileOutputChannel == 1 ? 1 : 2;
            double         amp_master       = VocaloSysUtil.getAmplifyCoeffFromFeder(vsq.Mixer.MasterFeder);
            double         pan_left_master  = VocaloSysUtil.getAmplifyCoeffFromPanLeft(vsq.Mixer.MasterPanpot);
            double         pan_right_master = VocaloSysUtil.getAmplifyCoeffFromPanRight(vsq.Mixer.MasterPanpot);
            int            numTrack         = vsq.Track.Count;
            string         tmppath          = AppManager.getTempWaveDir();
            int            track            = q.track;

            VsqTrack vsq_track = vsq.Track[track];
            int      count     = vsq_track.getEventCount();
            if (count <= 0)
            {
                return;// false;
            }
            double amp_track       = VocaloSysUtil.getAmplifyCoeffFromFeder(vsq.Mixer.Slave[track - 1].Feder);
            double pan_left_track  = VocaloSysUtil.getAmplifyCoeffFromPanLeft(vsq.Mixer.Slave[track - 1].Panpot);
            double pan_right_track = VocaloSysUtil.getAmplifyCoeffFromPanRight(vsq.Mixer.Slave[track - 1].Panpot);
            double amp_left        = amp_track * pan_left_track;
            double amp_right       = amp_track * pan_right_track;
            int    total_clocks    = vsq.TotalClocks;
            double total_sec       = vsq.getSecFromClock(total_clocks);

            RendererKind kind = VsqFileEx.getTrackRendererKind(vsq_track);
            mGenerator = VSTiDllManager.getWaveGenerator(kind);
            Amplifier amp = new Amplifier();
            amp.setRoot(mGenerator);
            if (q.renderAll)
            {
                amp.setAmplify(amp_left, amp_right);
            }
            mGenerator.setReceiver(amp);
            mGenerator.setGlobalConfig(AppManager.editorConfig);
            mGenerator.setMainWindow(mMainWindow);

            Mixer mixer = new Mixer();
            mixer.setRoot(mGenerator);
            mixer.setGlobalConfig(AppManager.editorConfig);
            amp.setReceiver(mixer);

            if (q.renderAll && vsq.config.WaveFileOutputFromMasterTrack)
            {
                // トラック全体を合成するモードで,かつ,他トラックを合成して出力するよう指示された場合
                if (numTrack > 2)
                {
                    for (int i = 1; i < numTrack; i++)
                    {
                        if (i == track)
                        {
                            continue;
                        }
                        string file = Path.Combine(tmppath, i + ".wav");
                        if (!File.Exists(file))
                        {
                            // mixするべきファイルが揃っていないのでbailout
                            return;// true;
                        }
                        WaveReader r = null;
                        try {
                            r = new WaveReader(file);
                        } catch (Exception ex) {
                            Logger.write(typeof(SynthesizeWorker) + ".processQueue; ex=" + ex + "\n");
                            r = null;
                        }
                        if (r == null)
                        {
                            return;// true;
                        }
                        double end_sec = vsq.getSecFromClock(q.clockStart);
                        r.setOffsetSeconds(end_sec);
                        Amplifier amp_i_unit = new Amplifier();
                        amp_i_unit.setRoot(mGenerator);
                        double amp_i       = VocaloSysUtil.getAmplifyCoeffFromFeder(vsq.Mixer.Slave[i - 1].Feder);
                        double pan_left_i  = VocaloSysUtil.getAmplifyCoeffFromPanLeft(vsq.Mixer.Slave[i - 1].Panpot);
                        double pan_right_i = VocaloSysUtil.getAmplifyCoeffFromPanRight(vsq.Mixer.Slave[i - 1].Panpot);
                        double amp_left_i  = amp_i * pan_left_i;
                        double amp_right_i = amp_i * pan_right_i;
#if DEBUG
                        sout.println("FormSynthesize#bgWork_DoWork; #" + i + "; amp_left_i=" + amp_left_i + "; amp_right_i=" + amp_right_i);
#endif
                        amp_i_unit.setAmplify(amp_left_i, amp_right_i);
                        FileWaveSender wave_sender = new FileWaveSender(r);
                        wave_sender.setRoot(mGenerator);
                        wave_sender.setGlobalConfig(AppManager.editorConfig);

                        amp_i_unit.setSender(wave_sender);
                        mixer.addSender(amp_i_unit);
                    }
                }
            }

            PortUtil.deleteFile(q.file);
            int sample_rate = vsq.config.SamplingRate;
#if DEBUG
            sout.println("FormSynthesize#bgWork_DoWork; q.file=" + q.file);
#endif
            FileWaveReceiver wave_receiver = new FileWaveReceiver(q.file, channel, 16, sample_rate);
            wave_receiver.setRoot(mGenerator);
            wave_receiver.setGlobalConfig(AppManager.editorConfig);
            Amplifier amp_unit_master = new Amplifier();
            amp_unit_master.setRoot(mGenerator);
            if (q.renderAll)
            {
                double l = amp_master * pan_left_master;
                double r = amp_master * pan_right_master;
                amp_unit_master.setAmplify(l, r);
            }
            mixer.setReceiver(amp_unit_master);
            amp_unit_master.setReceiver(wave_receiver);

            int end = q.clockEnd;
            if (end == int.MaxValue)
            {
                end = vsq.TotalClocks + 240;
            }
            mGenerator.init(vsq, track, q.clockStart, end, sample_rate);

            double sec_start = vsq.getSecFromClock(q.clockStart);
            double sec_end   = vsq.getSecFromClock(end);
            long   samples   = (long)((sec_end - sec_start) * sample_rate);
            mGenerator.begin(samples, state);

            return;// false;
        }