Ejemplo n.º 1
0
        public double getAmplifyR()
        {
            double ret = 0.0;

            if (!mMuted)
            {
                ret = VocaloSysUtil.getAmplifyCoeffFromFeder(mFeder) * VocaloSysUtil.getAmplifyCoeffFromPanRight(mPanpot);
            }
            return(ret);
        }
Ejemplo n.º 2
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;
        }