Пример #1
0
        private void BeforeInit()
        {
            if (Modulator.CubeGrid.Physics == null)
            {
                return;
            }

            _isServer    = Session.Instance.IsServer;
            _isDedicated = Session.Instance.DedicatedServer;

            ResetComp();

            Session.Instance.Modulators.Add(this);

            CreateUi();
            ModUi.ComputeDamage(this, ModUi.GetDamage(Modulator));

            Entity.TryGetSubpart("Rotor", out _subpartRotor);
            PowerInit();
            Modulator.RefreshCustomInfo();
            StateChange(true);
            if (!Session.Instance.ModAction)
            {
                Session.Instance.ModAction = true;
                Session.AppendConditionToAction <IMyUpgradeModule>((a) => Session.Instance.ModActions.Contains(a.Id), (a, b) => b.GameLogic.GetAs <Modulators>() != null && Session.Instance.ModActions.Contains(a.Id));
            }
            MainInit     = true;
            NeedsUpdate |= MyEntityUpdateEnum.BEFORE_NEXT_FRAME;
            _bTime       = _isDedicated ? 10 : 1;
            _bInit       = true;
        }
Пример #2
0
 internal void TerminalRefresh(bool update = true)
 {
     Modulator.RefreshCustomInfo();
     if (update && InControlPanel && InThisTerminal)
     {
         MyCube.UpdateTerminal();
     }
 }
Пример #3
0
 private void ModulatorOn()
 {
     if (_isServer && StateChange())
     {
         NeedUpdate();
         StateChange(true);
         Modulator.RefreshCustomInfo();
     }
 }
Пример #4
0
        public override void ApplyToAll(Modulator mod)
        {
            int i;

            for (i = 0; i < Length; i++)
            {
                this[i] = mod(this[i]);
            }
        }
Пример #5
0
        public Voice(double samplerate, int bufferSize)
        {
            this.samplerate = samplerate;
            bufsize         = bufferSize;

            ampEnvBuffer     = new double[bufsize];
            filter1EnvBuffer = new double[bufsize];
            filter2EnvBuffer = new double[bufsize];

            path1Buffer     = new double[bufsize];
            path2Buffer     = new double[bufsize];
            processBuffer   = new double[bufsize];
            OutputBuffer    = new double[2][];
            OutputBuffer[0] = new double[48000];
            OutputBuffer[1] = new double[48000];

            Modules = new Dictionary <ModuleId, object>();

            Osc1 = new MultiOsc(samplerate, bufsize);
            Osc2 = new BlOsc(samplerate, bufsize);
            Osc3 = new BlOsc(samplerate, bufsize);
            Osc4 = new BlOsc(samplerate, bufsize);

            //Ins1 = new InsRedux(samplerate, Bufsize);
            //Ins2 = new InsRedux(samplerate, Bufsize);
            Ins1 = new InsDistortion(samplerate, bufsize);
            Ins2 = new InsDistortion(samplerate, bufsize);

            Filter1 = new DualFilter(samplerate, bufsize);
            Filter2 = new DualFilter(samplerate, bufsize);

            AmpEnv     = new Ahdsr(samplerate);
            Filter1Env = new Ahdsr(samplerate);
            Filter2Env = new Ahdsr(samplerate);

            Mod1 = new Modulator(samplerate);
            Mod2 = new Modulator(samplerate);
            Mod3 = new Modulator(samplerate);
            Mod4 = new Modulator(samplerate);
            Mod5 = new Modulator(samplerate);
            Mod6 = new Modulator(samplerate);

            MidiInput = new MidiInput();
            ModMatrix = new ModMatrix(this);
            Mixer     = new Mixer();

            RefreshModuleObjects();

            Mod1.UpdateStepsize();
            Mod2.UpdateStepsize();
            Mod3.UpdateStepsize();
            Mod4.UpdateStepsize();
            Mod5.UpdateStepsize();
            Mod6.UpdateStepsize();
            Mixer.Update();
        }
 public ModulatorChunk(string id, int size, BinaryReader reader)
     : base(id, size)
 {
     if (size % 10 != 0)
         throw new Exception("Invalid SoundFont. The presetzone chunk was invalid.");
     modulators = new Modulator[(size / 10) - 1];
     for (int x = 0; x < modulators.Length; x++)
         modulators[x] = new Modulator(reader);
     new Modulator(reader); //terminal record
 }
Пример #7
0
    public override float dataReturn(Modulator mod)
    {
        var toReturn = gain * Mathf.Sin(phase + mod.getMod());

        if (phase > 2 * Mathf.PI)
        {
            phase = 0;
        }
        return(toReturn);
    }
Пример #8
0
    public override float dataReturn(Modulator mod)
    {
        var toReturn = -1.0f + (gain * phase) + mod.getMod();

        if (phase > 2)
        {
            phase = 0;
            //Debug.Log("Resetting phase");
        }
        return(toReturn);
    }
Пример #9
0
 public ModulatorChunk(string id, int size, IReadable input)
     : base(id, size)
 {
     if(size % 10 != 0)
         throw new Exception("Invalid SoundFont. The presetzone chunk was invalid.");
     Modulators = new Modulator[(size/10) - 1];
     for (int x = 0; x < Modulators.Length; x++)
     {
         Modulators[x] = new Modulator(input);
     }
     new Modulator(input);
 }
Пример #10
0
        public override void ApplyToAll(Modulator mod)
        {
            int i;
            int j;

            for (i = 0; i < RowCount; i++)
            {
                for (j = 0; j < ColumnCount; j++)
                {
                    this[i, j] = mod(this[i, j]);
                }
            }
        }
Пример #11
0
 public ModulatorChunk(string id, int size, IReadable input)
     : base(id, size)
 {
     if (size % 10 != 0)
     {
         throw new Exception("Invalid SoundFont. The presetzone chunk was invalid.");
     }
     Modulators = new Modulator[(size / 10) - 1];
     for (int x = 0; x < Modulators.Length; x++)
     {
         Modulators[x] = new Modulator(input);
     }
     new Modulator(input);
 }
Пример #12
0
 public ModulatorChunk(string id, int size, BinaryReader reader)
     : base(id, size)
 {
     if (size % 10 != 0)
     {
         throw new Exception("Invalid SoundFont. The presetzone chunk was invalid.");
     }
     modulators = new Modulator[(size / 10) - 1];
     for (int x = 0; x < modulators.Length; x++)
     {
         modulators[x] = new Modulator(reader);
     }
     new Modulator(reader); //terminal record
 }
 public Zone[] ToZones(Modulator[] modulators, Generator[] generators)
 {
     Zone[] zones = new Zone[zoneData.Length - 1];
     for (int x = 0; x < zones.Length; x++)
     {
         RawZoneData rawZone = zoneData[x];
         Zone zone = new Zone();
         zone.Generators = new Generator[rawZone.generatorCount];
         Array.Copy(generators, rawZone.generatorIndex, zone.Generators, 0, rawZone.generatorCount);
         zone.Modulators = new Modulator[rawZone.modulatorCount];
         Array.Copy(modulators, rawZone.modulatorIndex, zone.Modulators, 0, rawZone.modulatorCount);
         zones[x] = zone;
     }
     return zones;
 }
Пример #14
0
    public override float dataReturn(Modulator mod)
    {
        var triPhase = phase + mod.getMod();

        if (triPhase > 1)
        {
            triPhase = 1.0f - (triPhase - 1);
        }
        var toReturn = -1.0f + (2 * gain * triPhase);

        //Debug.Log(toReturn);
        if (phase > 2)
        {
            phase = 0;
        }
        return(toReturn);
    }
Пример #15
0
        private void Timing()
        {
            if (_tock60 && !_isDedicated)
            {
                TerminalRefresh();
            }

            if (_tock33)
            {
                if (SettingsUpdated)
                {
                    SettingsUpdated = false;
                    ModSet.SaveSettings();
                    ModState.SaveState();
                    if (Session.Enforced.Debug == 3)
                    {
                        Log.Line($"SettingsUpdated: server:{_isServer} - ModulatorId [{Modulator.EntityId}]");
                    }
                }
            }
            else if (_tock34)
            {
                if (ClientUiUpdate)
                {
                    ClientUiUpdate = false;
                    MyCube.UpdateTerminal();
                    Modulator.RefreshCustomInfo();
                    if (!_isServer)
                    {
                        ModSet.NetworkUpdate();
                    }
                }
            }

            if (_isDedicated || (_subDelayed && _tick > _subTick + 9))
            {
                if (Session.Enforced.Debug == 3)
                {
                    Log.Line($"Delayed tick: {_tick} - hierarchytick: {_subTick}");
                }
                _subDelayed = false;
                HierarchyChanged();
            }
        }
Пример #16
0
        private void ModulatorOff()
        {
            var stateChange = StateChange();

            if (stateChange)
            {
                if (_isServer)
                {
                    NeedUpdate();
                    StateChange(true);
                    Modulator.RefreshCustomInfo();
                }
                else
                {
                    StateChange(true);
                    Modulator.RefreshCustomInfo();
                }
            }
        }
Пример #17
0
        private bool BlockWorking()
        {
            if (_tock60 || _firstRun)
            {
                _powered = Sink.IsPowerAvailable(_gId, 0.01f);
            }
            if (!MyCube.IsWorking || !_powered)
            {
                if (!_isDedicated && _tock60)
                {
                    Modulator.RefreshCustomInfo();
                }
                ModState.State.Online = false;
                return(false);
            }
            if (ModulatorComp.Modulator == null)
            {
                ModulatorComp.Modulator = this;
            }
            else if (ModulatorComp.Modulator != this)
            {
                if (!ModState.State.Backup || _firstLoop)
                {
                    Session.Instance.BlockTagBackup(Modulator);
                }
                ModState.State.Backup = true;
                ModState.State.Online = false;
                _firstLoop            = false;
                return(false);
            }

            ModState.State.Backup = false;

            if (_tock60 || _firstRun)
            {
                ServerCheckForCompLink();
            }
            ModState.State.Online = true;
            _firstLoop            = false;
            return(true);
        }
Пример #18
0
 public void setMod(Modulator mod)
 {
     this.mod = mod;
 }
Пример #19
0
 public abstract void ApplyToAll(Modulator mod);
Пример #20
0
 public virtual float dataReturn(Modulator mod)
 {
     return(0);
 }
Пример #21
0
 public virtual void increment(Modulator mod)
 {
     //mod.increment ();
     phase += inc + mod.getMod();
 }