示例#1
0
        void dx7_voice_recalculate_volume(hexter_instance instance)
        {
            float f;
            int   i;

            this.last_port_volume = instance.volume;
            this.last_cc_volume   = instance.cc_volume;

            /* This 41 OL volume cc mapping matches my TX7 fairly well, to within
             * +/-0.8dB for most of the scale. (It even duplicates the "feature"
             * of not going completely silent at zero....) */
            f  = (instance.volume - 20.0f) * 1.328771f + 86.0f;
            f += (float)instance.cc_volume * 41.0f / 16256.0f;
            i  = (int)Math.Round(f - 0.5f);
            f -= (float)i;
            this.volume_target = (Inline.FP_TO_FLOAT(Data.dx7_voice_eg_ol_to_amp_table[128 + i]) +
                                  f * Inline.FP_TO_FLOAT(Data.dx7_voice_eg_ol_to_amp_table[128 + i + 1] -
                                                         Data.dx7_voice_eg_ol_to_amp_table[128 + i])) *
                                 0.110384f / Data.dx7_voice_carrier_count[this.algorithm];

            if (this.volume_value < 0.0f)
            { /* initial setup */
                this.volume_value    = this.volume_target;
                this.volume_duration = 0;
            }
            else
            {
                this.volume_duration  = instance.ramp_duration;
                this.volume_increment = (this.volume_target - this.volume_value) /
                                        (float)this.volume_duration;
            }
        }