Ejemplo n.º 1
0
 public AttackVariation convertFrom(string value)
 {
     if (value.Equals(new AttackVariation().mDescription))
     {
         return(new AttackVariation());
     }
     else
     {
         SynthesizerType type = SynthesizerType.VOCALOID2;
         VsqFileEx       vsq  = AppManager.getVsqFile();
         if (vsq != null)
         {
             string svalue = (string)value;
             foreach (var aconfig in VocaloSysUtil.attackConfigIterator(type))
             {
                 string display_string = aconfig.getDisplayString();
                 if (svalue.Equals(display_string))
                 {
                     return(new AttackVariation(display_string));
                 }
             }
         }
         return(new AttackVariation());
     }
 }
Ejemplo n.º 2
0
        public double getAmplifyR()
        {
            double ret = 0.0;

            if (!mMuted)
            {
                ret = VocaloSysUtil.getAmplifyCoeffFromFeder(mFeder) * VocaloSysUtil.getAmplifyCoeffFromPanRight(mPanpot);
            }
            return(ret);
        }
Ejemplo n.º 3
0
        public List <Object> getStandardValues()
        {
            SynthesizerType type = SynthesizerType.VOCALOID2;
            VsqFileEx       vsq  = AppManager.getVsqFile();
            List <Object>   list = new List <Object>();

            list.Add(new AttackVariation());
            foreach (var aconfig in VocaloSysUtil.attackConfigIterator(type))
            {
                list.Add(new AttackVariation(aconfig.getDisplayString()));
            }
            return(list);//new StandardValuesCollection( list.toArray( new AttackVariation[] { } ) );
        }
Ejemplo n.º 4
0
        /// <summary>
        /// ビブラートの選択肢の状態を更新します
        /// </summary>
        private void updateComboBoxStatus()
        {
            // 選択位置
            int old = comboVibratoType.SelectedIndex;

            // 全部削除
            comboVibratoType.Items.Clear();

            // 「ビブラート無し」を表すアイテムを追加
            VibratoHandle empty = new VibratoHandle();

            empty.setCaption("[Non Vibrato]");
            empty.IconID = "$04040000";
            comboVibratoType.Items.Add(empty);

            // 選択元を元に,選択肢を追加する
            if (radioUserDefined.Checked)
            {
                // ユーザー定義のを使う場合
                int size = AppManager.editorConfig.AutoVibratoCustom.Count;
                for (int i = 0; i < size; i++)
                {
                    VibratoHandle handle = AppManager.editorConfig.AutoVibratoCustom[i];
                    comboVibratoType.Items.Add(handle);
                }
            }
            else
            {
                // VOCALOID1/VOCALOID2のシステム定義のを使う場合
                SynthesizerType type = radioVocaloid1.Checked ? SynthesizerType.VOCALOID1 : SynthesizerType.VOCALOID2;
                foreach (var vconfig in VocaloSysUtil.vibratoConfigIterator(type))
                {
                    comboVibratoType.Items.Add(vconfig);
                }
            }

            // 選択位置を戻せるなら戻す
            int index = old;

            if (index >= comboVibratoType.Items.Count)
            {
                index = comboVibratoType.Items.Count - 1;
            }
            if (0 <= index)
            {
                comboVibratoType.SelectedIndex = index;
            }
        }
Ejemplo n.º 5
0
 public VibratoVariation convertFrom(string value)
 {
     if (value.Equals(VibratoVariation.empty.description))
     {
         return(new VibratoVariation(VibratoVariation.empty.description));
     }
     else
     {
         if (AppManager.editorConfig.UseUserDefinedAutoVibratoType)
         {
             int size = AppManager.editorConfig.AutoVibratoCustom.Count;
             for (int i = 0; i < size; i++)
             {
                 string display_string = AppManager.editorConfig.AutoVibratoCustom[i].getDisplayString();
                 if (value.Equals(display_string))
                 {
                     return(new VibratoVariation(display_string));
                 }
             }
         }
         else
         {
             SynthesizerType type = SynthesizerType.VOCALOID2;
             VsqFileEx       vsq  = AppManager.getVsqFile();
             if (vsq != null)
             {
                 /*
                  * RendererKind kind = VsqFileEx.getTrackRendererKind(vsq.Track[AppManager.getSelected()]);
                  * if (kind == RendererKind.VOCALOID1) {
                  *  type = SynthesizerType.VOCALOID1;
                  * }*/
                 foreach (var vconfig in VocaloSysUtil.vibratoConfigIterator(type))
                 {
                     string display_string = vconfig.getDisplayString();
                     if (value.Equals(display_string))
                     {
                         return(new VibratoVariation(display_string));
                     }
                 }
             }
         }
         return(new VibratoVariation(VibratoVariation.empty.description));
     }
 }
Ejemplo n.º 6
0
        public List <VibratoVariation> getStandardValues()
        {
            // ビブラート種類の候補値を列挙
            List <VibratoVariation> list = new List <VibratoVariation>();

            list.Add(new VibratoVariation(VibratoVariation.empty.description));

            if (AppManager.editorConfig.UseUserDefinedAutoVibratoType)
            {
                // ユーザー定義の中から選ぶ場合
                int size = AppManager.editorConfig.AutoVibratoCustom.Count;
#if DEBUG
                sout.println("VibratoVariationConverter#GetStandardValues; size=" + size);
#endif
                for (int i = 0; i < size; i++)
                {
                    VibratoHandle handle = AppManager.editorConfig.AutoVibratoCustom[i];
#if DEBUG
                    sout.println("VibratoVariationConverter#GetStandardValues; handle.getDisplayString()=" + handle.getDisplayString());
#endif
                    list.Add(new VibratoVariation(handle.getDisplayString()));
                }
            }
            else
            {
                // VOCALOID1, VOCALOID2のシステム定義の中から選ぶ場合
                SynthesizerType type = SynthesizerType.VOCALOID1;

                /*
                 * VsqFileEx vsq = AppManager.getVsqFile();
                 * if (vsq != null) {
                 *  RendererKind kind = VsqFileEx.getTrackRendererKind(vsq.Track[AppManager.getSelected()]);
                 *  if (kind == RendererKind.VOCALOID1) {
                 *      type = SynthesizerType.VOCALOID1;
                 *  }
                 * }*/
                foreach (var vconfig in VocaloSysUtil.vibratoConfigIterator(type))
                {
                    list.Add(new VibratoVariation(vconfig.getDisplayString()));
                }
            }
            return(list);
        }
        public FormGenerateKeySound(bool close_when_finished)
        {
            InitializeComponent();
            bgWork = new System.ComponentModel.BackgroundWorker();
            bgWork.WorkerReportsProgress      = true;
            bgWork.WorkerSupportsCancellation = true;
            folderBrowser = new FolderBrowserDialog();

            m_close_when_finished = close_when_finished;
            m_singer_config1      = VocaloSysUtil.getSingerConfigs(SynthesizerType.VOCALOID1);
            m_singer_config2      = VocaloSysUtil.getSingerConfigs(SynthesizerType.VOCALOID2);
            m_singer_config_utau  = AppManager.editorConfig.UtauSingers.ToArray();
            if (m_singer_config1.Length > 0)
            {
                comboSingingSynthSystem.Items.Add("VOCALOID1");
            }
            if (m_singer_config2.Length > 0)
            {
                comboSingingSynthSystem.Items.Add("VOCALOID2");
            }

            // 取りあえず最初に登録されているresamplerを使うってことで
            string resampler = AppManager.editorConfig.getResamplerAt(0);

            if (m_singer_config_utau.Length > 0 &&
                AppManager.editorConfig.PathWavtool != null && File.Exists(AppManager.editorConfig.PathWavtool) &&
                resampler != null && File.Exists(resampler))
            {
                comboSingingSynthSystem.Items.Add("UTAU");
            }
            if (comboSingingSynthSystem.Items.Count > 0)
            {
                comboSingingSynthSystem.SelectedIndex = 0;
            }
            updateSinger();
            txtDir.Text = Utility.getKeySoundPath();

            registerEventHandlers();
        }
        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);
                    }
                }
            }
        }
Ejemplo n.º 9
0
        public void comboVibratoType_SelectedIndexChanged(Object sender, EventArgs e)
        {
            int index = comboVibratoType.SelectedIndex;

#if DEBUG
            sout.println("FormVibratoConfig#comboVibratoType_SelectedIndexChanged; index=" + index);
#endif
            if (index >= 0)
            {
                string s = ((VibratoHandle)comboVibratoType.Items[index]).IconID;
#if DEBUG
                sout.println("FormVibratoConfig#comboVibratoType_SelectedIndexChanged; index=" + index + "; iconid=" + s);
#endif
                if (s.Equals("$04040000"))
                {
#if DEBUG
                    sout.println("FormVibratoConfig#comboVibratoType_SelectedIndexChanged; B; m_vibrato -> null");
#endif
                    m_vibrato = null;
                    txtVibratoLength.Enabled = false;
                    return;
                }
                else
                {
                    txtVibratoLength.Enabled = true;
                    VibratoHandle src = null;
                    if (radioUserDefined.Checked)
                    {
                        int size = AppManager.editorConfig.AutoVibratoCustom.Count;
                        for (int i = 0; i < size; i++)
                        {
                            VibratoHandle handle = AppManager.editorConfig.AutoVibratoCustom[i];
                            if (s == handle.IconID)
                            {
                                src = handle;
                                break;
                            }
                        }
                    }
                    else
                    {
                        SynthesizerType type = radioVocaloid1.Checked ? SynthesizerType.VOCALOID1 : SynthesizerType.VOCALOID2;
                        foreach (var vconfig in VocaloSysUtil.vibratoConfigIterator(type))
                        {
                            if (s == vconfig.IconID)
                            {
                                src = vconfig;
                                break;
                            }
                        }
                    }
#if DEBUG
                    sout.println("FormVibratoConfig#comboVibratoType_SelectedIndexChanged; (src==null)=" + (src == null));
#endif
                    if (src != null)
                    {
                        int percent;
                        try {
                            percent = int.Parse(txtVibratoLength.Text);
                        } catch (Exception ex) {
                            return;
                        }
                        m_vibrato = (VibratoHandle)src.clone();
                        m_vibrato.setLength((int)(m_note_length * percent / 100.0f));
                        return;
                    }
                }
            }
        }
Ejemplo n.º 10
0
        public FormNoteExpressionConfig(SynthesizerType type, NoteHeadHandle note_head_handle)
        {
            InitializeComponent();
            registerEventHandlers();
            setResources();
            Util.applyFontRecurse(this, AppManager.editorConfig.getBaseFont());
            applyLanguage();

            if (note_head_handle != null)
            {
                m_note_head_handle = (NoteHeadHandle)note_head_handle.clone();
            }

            if (type == SynthesizerType.VOCALOID1)
            {
                flowLayoutPanel.Controls.Remove(groupDynamicsControl);
                flowLayoutPanel.Controls.Remove(panelVocaloid2Template);
                flowLayoutPanel.Controls.Remove(groupPitchControl);
            }
            else
            {
                flowLayoutPanel.Controls.Remove(groupAttack);
            }

            //comboAttackTemplateを更新
            NoteHeadHandle empty = new NoteHeadHandle();

            comboAttackTemplate.Items.Clear();
            empty.IconID = "$01010000";
            empty.setCaption("[Non Attack]");
            comboAttackTemplate.Items.Add(empty);
            comboAttackTemplate.SelectedItem = empty;
            string icon_id = "";

            if (m_note_head_handle != null)
            {
                icon_id          = m_note_head_handle.IconID;
                txtDuration.Text = m_note_head_handle.getDuration() + "";
                txtDepth.Text    = m_note_head_handle.getDepth() + "";
            }
            else
            {
                txtDuration.Enabled   = false;
                txtDepth.Enabled      = false;
                trackDuration.Enabled = false;
                trackDepth.Enabled    = false;
            }
            foreach (var item in VocaloSysUtil.attackConfigIterator(SynthesizerType.VOCALOID1))
            {
                comboAttackTemplate.Items.Add(item);
                if (item.IconID.Equals(icon_id))
                {
                    comboAttackTemplate.SelectedItem = comboAttackTemplate.Items[comboAttackTemplate.Items.Count - 1];
                }
            }
            comboAttackTemplate.SelectedIndexChanged += new EventHandler(comboAttackTemplate_SelectedIndexChanged);

            comboTemplate.Items.Clear();
            string[] strs = new string[] {
                "[Select a template]",
                "normal",
                "accent",
                "strong accent",
                "legato",
                "slow legate",
            };
            for (int i = 0; i < strs.Length; i++)
            {
                comboTemplate.Items.Add(strs[i]);
            }

            Size current_size = this.ClientSize;

            this.ClientSize      = new Size(current_size.Width, flowLayoutPanel.ClientSize.Height + flowLayoutPanel.Top * 2);
            this.FormBorderStyle = FormBorderStyle.FixedDialog;
        }
Ejemplo n.º 11
0
        private void init()
        {
            foreach (var handle in VocaloSysUtil.dynamicsConfigIterator(SynthesizerType.VOCALOID1))
            {
                string           icon_id = handle.IconID;
                DraggableBButton btn     = new DraggableBButton();
                btn.Name = icon_id;
                btn.setHandle(handle);
                string buttonIconPath = handle.getButtonImageFullPath();

                bool setimg = System.IO.File.Exists(buttonIconPath);
                if (setimg)
                {
                    btn.Image = System.Drawing.Image.FromStream(new System.IO.FileStream(buttonIconPath, System.IO.FileMode.Open, System.IO.FileAccess.Read));
                }
                else
                {
                    System.Drawing.Image img = null;
                    string str     = "";
                    string caption = handle.IDS;
                    if (caption.Equals("cresc_1"))
                    {
                        img = Properties.Resources.cresc1;
                    }
                    else if (caption.Equals("cresc_2"))
                    {
                        img = Properties.Resources.cresc2;
                    }
                    else if (caption.Equals("cresc_3"))
                    {
                        img = Properties.Resources.cresc3;
                    }
                    else if (caption.Equals("cresc_4"))
                    {
                        img = Properties.Resources.cresc4;
                    }
                    else if (caption.Equals("cresc_5"))
                    {
                        img = Properties.Resources.cresc5;
                    }
                    else if (caption.Equals("dim_1"))
                    {
                        img = Properties.Resources.dim1;
                    }
                    else if (caption.Equals("dim_2"))
                    {
                        img = Properties.Resources.dim2;
                    }
                    else if (caption.Equals("dim_3"))
                    {
                        img = Properties.Resources.dim3;
                    }
                    else if (caption.Equals("dim_4"))
                    {
                        img = Properties.Resources.dim4;
                    }
                    else if (caption.Equals("dim_5"))
                    {
                        img = Properties.Resources.dim5;
                    }
                    else if (caption.Equals("Dynaff11"))
                    {
                        str = "fff";
                    }
                    else if (caption.Equals("Dynaff12"))
                    {
                        str = "ff";
                    }
                    else if (caption.Equals("Dynaff13"))
                    {
                        str = "f";
                    }
                    else if (caption.Equals("Dynaff21"))
                    {
                        str = "mf";
                    }
                    else if (caption.Equals("Dynaff22"))
                    {
                        str = "mp";
                    }
                    else if (caption.Equals("Dynaff31"))
                    {
                        str = "p";
                    }
                    else if (caption.Equals("Dynaff32"))
                    {
                        str = "pp";
                    }
                    else if (caption.Equals("Dynaff33"))
                    {
                        str = "ppp";
                    }
                    if (img != null)
                    {
                        btn.Image = img;
                    }
                    else
                    {
                        btn.Text = str;
                    }
                }
                btn.MouseDown += new MouseEventHandler(handleCommonMouseDown);
                btn.Size       = new System.Drawing.Size(buttonWidth, buttonWidth);
                int iw = 0;
                int ih = 0;
                if (icon_id.StartsWith(IconDynamicsHandle.ICONID_HEAD_DYNAFF))
                {
                    // dynaff
                    dynaffButtons.Add(btn);
                    ih = 0;
                    iw = dynaffButtons.Count - 1;
                }
                else if (icon_id.StartsWith(IconDynamicsHandle.ICONID_HEAD_CRESCEND))
                {
                    // crescend
                    crescendButtons.Add(btn);
                    ih = 1;
                    iw = crescendButtons.Count - 1;
                }
                else if (icon_id.StartsWith(IconDynamicsHandle.ICONID_HEAD_DECRESCEND))
                {
                    // decrescend
                    decrescendButtons.Add(btn);
                    ih = 2;
                    iw = decrescendButtons.Count - 1;
                }
                else
                {
                    continue;
                }
                btn.Location = new System.Drawing.Point(iw * buttonWidth, ih * buttonWidth);
                this.Controls.Add(btn);
                btn.BringToFront();
            }

            // ウィンドウのサイズを固定化する
            int height = 0;
            int width  = 0;

            if (dynaffButtons.Count > 0)
            {
                height += buttonWidth;
            }
            width = Math.Max(width, buttonWidth * dynaffButtons.Count);
            if (crescendButtons.Count > 0)
            {
                height += buttonWidth;
            }
            width = Math.Max(width, buttonWidth * crescendButtons.Count);
            if (decrescendButtons.Count > 0)
            {
                height += buttonWidth;
            }
            width           = Math.Max(width, buttonWidth * decrescendButtons.Count);
            this.ClientSize = new System.Drawing.Size(width, height);
            var size = this.Size;

            this.MaximumSize = new System.Drawing.Size(size.Width, size.Height);
            this.MinimumSize = new System.Drawing.Size(size.Width, size.Height);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 自動ビブラートを作成します
        /// </summary>
        /// <param name="type"></param>
        /// <param name="vibrato_clocks"></param>
        /// <returns></returns>
        public VibratoHandle createAutoVibrato(SynthesizerType type, int vibrato_clocks)
        {
            if (UseUserDefinedAutoVibratoType)
            {
                if (AutoVibratoCustom == null)
                {
                    AutoVibratoCustom = new List <VibratoHandle>();
                }

                // 下4桁からインデックスを取得
                int index = 0;
                if (this.AutoVibratoTypeCustom == null)
                {
                    index = 0;
                }
                else
                {
                    int trimlen = 4;
                    int len     = PortUtil.getStringLength(this.AutoVibratoTypeCustom);
                    if (len < 4)
                    {
                        trimlen = len;
                    }
                    if (trimlen > 0)
                    {
                        string s = this.AutoVibratoTypeCustom.Substring(len - trimlen, trimlen);
                        try {
                            index = (int)PortUtil.fromHexString(s);
                            index--;
                        } catch (Exception ex) {
                            serr.println(typeof(EditorConfig) + ".createAutoVibrato; ex=" + ex + "; AutoVibratoTypeCustom=" + AutoVibratoTypeCustom + "; s=" + s);
                            index = 0;
                        }
                    }
                }

#if DEBUG
                sout.println("EditorConfig.createAutoVibrato; AutoVibratoTypeCustom=" + AutoVibratoTypeCustom + "; index=" + index);
#endif
                VibratoHandle ret = null;
                if (0 <= index && index < this.AutoVibratoCustom.Count)
                {
                    ret = this.AutoVibratoCustom[index];
                    if (ret != null)
                    {
                        ret = (VibratoHandle)ret.clone();
                    }
                }
                if (ret == null)
                {
                    ret = new VibratoHandle();
                }
                ret.IconID = "$0404" + PortUtil.toHexString(index + 1, 4);
                ret.setLength(vibrato_clocks);
                return(ret);
            }
            else
            {
                string        iconid = type == SynthesizerType.VOCALOID1 ? AutoVibratoType1 : AutoVibratoType2;
                VibratoHandle ret    = VocaloSysUtil.getDefaultVibratoHandle(iconid,
                                                                             vibrato_clocks,
                                                                             type);
                if (ret == null)
                {
                    ret        = new VibratoHandle();
                    ret.IconID = "$04040001";
                    ret.setLength(vibrato_clocks);
                }
                return(ret);
            }
        }
Ejemplo n.º 13
0
        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;
        }
Ejemplo n.º 14
0
        public Preference()
        {
            InitializeComponent();
            fontDialog = new FontDialog();
            fontDialog.AllowVectorFonts   = false;
            fontDialog.AllowVerticalFonts = false;
            fontDialog.FontMustExist      = true;
            fontDialog.ShowEffects        = false;
            openUtauCore = new OpenFileDialog();

            folderBrowserSingers = new FolderBrowserDialog();
            folderBrowserSingers.ShowNewFolderButton = false;
            applyLanguage();

            comboVibratoLength.Items.Clear();
            foreach (DefaultVibratoLengthEnum dvl in Enum.GetValues(typeof(DefaultVibratoLengthEnum)))
            {
                comboVibratoLength.Items.Add(DefaultVibratoLengthUtil.toString(dvl));
            }
            comboVibratoLength.SelectedIndex = 1;

            txtAutoVibratoThresholdLength.Text = "480";

            comboAutoVibratoType1.Items.Clear();
            foreach (var vconfig in VocaloSysUtil.vibratoConfigIterator(SynthesizerType.VOCALOID1))
            {
                comboAutoVibratoType1.Items.Add(vconfig);
            }
            if (comboAutoVibratoType1.Items.Count > 0)
            {
                comboAutoVibratoType1.SelectedIndex = 0;
            }

            comboAutoVibratoType2.Items.Clear();
            foreach (var vconfig in VocaloSysUtil.vibratoConfigIterator(SynthesizerType.VOCALOID2))
            {
                comboAutoVibratoType2.Items.Add(vconfig);
            }
            if (comboAutoVibratoType2.Items.Count > 0)
            {
                comboAutoVibratoType2.SelectedIndex = 0;
            }

            updateCustomVibrato();

            comboResolControlCurve.Items.Clear();
            foreach (var cr in ClockResolutionUtility.iterator())
            {
                comboResolControlCurve.Items.Add(ClockResolutionUtility.toString(cr));
            }
            comboResolControlCurve.SelectedIndex = 0;

            comboLanguage.Items.Clear();
            string[] list  = Messaging.getRegisteredLanguage();
            int      index = 0;

            comboLanguage.Items.Add("Default");
            int count = 0;

            foreach (string s in list)
            {
                count++;
                comboLanguage.Items.Add(s);
                if (s.Equals(Messaging.getLanguage()))
                {
                    index = count;
                }
            }
            comboLanguage.SelectedIndex = index;

            SingerConfig[] dict = VocaloSysUtil.getSingerConfigs(SynthesizerType.VOCALOID2);
            m_program_change = new List <string>();
            comboDefualtSinger.Items.Clear();
            foreach (SingerConfig kvp in dict)
            {
                m_program_change.Add(kvp.VOICENAME);
                comboDefualtSinger.Items.Add(kvp.VOICENAME);
            }
            comboDefualtSinger.Enabled = (comboDefualtSinger.Items.Count > 0);
            if (comboDefualtSinger.Items.Count > 0)
            {
                comboDefualtSinger.SelectedIndex = 0;
            }

            updateMidiDevice();

            listSingers.Columns[0].Width = columnWidthHeaderProgramChange;
            listSingers.Columns[1].Width = columnWidthHeaderName;
            listSingers.Columns[2].Width = columnWidthHeaderPath;


            numBuffer.Maximum = EditorConfig.MAX_BUFFER_MILLISEC;
            numBuffer.Minimum = EditorConfig.MIN_BUFFER_MILLIXEC;

            registerEventHandlers();
            setResources();
        }