Exemple #1
0
 public LfoDescriptor()
 {
     DelayTime = 0;
     Frequency = SynthConstants.DefaultLfoFrequency;
     Depth = 1;
     Generator = DefaultGenerators.DefaultSine;
 }
Exemple #2
0
 public void QuickSetup(int sampleRate, LfoDescriptor lfoInfo)
 {
     _generator = lfoInfo.Generator;
     _delayTime = (int)(sampleRate * lfoInfo.DelayTime);
     Frequency = lfoInfo.Frequency;
     _increment = _generator.Period * Frequency / sampleRate;
     Depth = lfoInfo.Depth;
     Reset();
 }
Exemple #3
0
 public Lfo()
 {
     CurrentState = LfoState.Delay;
     _generator = DefaultGenerators.DefaultSine;
     _delayTime = 0;
     _increment = 0;
     _phase = 0;
     Frequency = 0;
     CurrentState = 0;
     Value = 0;
     Depth = 0;
 }
Exemple #4
0
        private void LoadGen(Sf2Region region, AssetManager assets)
        {
            SampleDataAsset sda = assets.SampleAssets[region.Generators[(int)GeneratorEnum.SampleID]];

            gen              = new SampleGenerator();
            gen.EndPhase     = sda.End + region.Generators[(int)GeneratorEnum.EndAddressOffset] + 32768 * region.Generators[(int)GeneratorEnum.EndAddressCoarseOffset];
            gen.Frequency    = sda.SampleRate;
            gen.KeyTrack     = region.Generators[(int)GeneratorEnum.ScaleTuning];
            gen.LoopEndPhase = sda.LoopEnd + region.Generators[(int)GeneratorEnum.EndLoopAddressOffset] + 32768 * region.Generators[(int)GeneratorEnum.EndLoopAddressCoarseOffset];
            switch (region.Generators[(int)GeneratorEnum.SampleModes] & 0x3)
            {
            case 0x0:
            case 0x2:
                gen.LoopMode = LoopMode.NoLoop;
                break;

            case 0x1:
                gen.LoopMode = LoopMode.Continuous;
                break;

            case 0x3:
                gen.LoopMode = LoopMode.LoopUntilNoteOff;
                break;
            }
            gen.LoopStartPhase = sda.LoopStart + region.Generators[(int)GeneratorEnum.StartLoopAddressOffset] + 32768 * region.Generators[(int)GeneratorEnum.StartLoopAddressCoarseOffset];
            gen.Offset         = 0;
            gen.Period         = 1.0;
            if (region.Generators[(int)GeneratorEnum.OverridingRootKey] > -1)
            {
                gen.RootKey = region.Generators[(int)GeneratorEnum.OverridingRootKey];
            }
            else
            {
                gen.RootKey = sda.RootKey;
            }
            gen.StartPhase    = sda.Start + region.Generators[(int)GeneratorEnum.StartAddressOffset] + 32768 * region.Generators[(int)GeneratorEnum.StartAddressCoarseOffset];
            gen.Tune          = (short)(sda.Tune + region.Generators[(int)GeneratorEnum.FineTune] + 100 * region.Generators[(int)GeneratorEnum.CoarseTune]);
            gen.VelocityTrack = 0;
            ((SampleGenerator)gen).Samples = sda.SampleData;
        }
 public void QuickSetup(Generator generator)
 {
     CurrentStart = generator.StartPhase;
     Phase = CurrentStart + generator.Offset;
     switch (generator.LoopMode)
     {
         case LoopMode.Continuous:
         case LoopMode.LoopUntilNoteOff:
             if (Phase >= generator.EndPhase)
             {//phase is greater than the end index so generator is finished
                 CurrentState = GeneratorState.Finished;
             }
             else if (Phase >= generator.LoopEndPhase)
             {//phase is greater than the loop end point so generator is in post loop
                 CurrentState = GeneratorState.PostLoop;
                 CurrentEnd = generator.EndPhase;
             }
             else if (Phase >= generator.LoopStartPhase)
             {//phase is greater than loop start so we are inside the loop
                 CurrentState = GeneratorState.Loop;
                 CurrentEnd = generator.LoopEndPhase;
                 CurrentStart = generator.LoopStartPhase;
             }
             else
             {//phase is less than the loop so generator is in pre loop
                 CurrentState = GeneratorState.PreLoop;
                 CurrentEnd = generator.LoopStartPhase;
             }
             break;
         default:
             CurrentEnd = generator.EndPhase;
             if (Phase >= CurrentEnd)
                 CurrentState = GeneratorState.Finished;
             else
                 CurrentState = GeneratorState.PostLoop;
             break;
     }
 }
Exemple #6
0
 private void LoadGen(Sf2Region region, AssetManager assets)
 {
     SampleDataAsset sda = assets.SampleAssets[region.Generators[(int)GeneratorEnum.SampleID]];
     gen = new SampleGenerator();
     gen.EndPhase = sda.End + region.Generators[(int)GeneratorEnum.EndAddressOffset] + 32768 * region.Generators[(int)GeneratorEnum.EndAddressCoarseOffset];
     gen.Frequency = sda.SampleRate;
     gen.KeyTrack = region.Generators[(int)GeneratorEnum.ScaleTuning];
     gen.LoopEndPhase = sda.LoopEnd + region.Generators[(int)GeneratorEnum.EndLoopAddressOffset] + 32768 * region.Generators[(int)GeneratorEnum.EndLoopAddressCoarseOffset];
     switch (region.Generators[(int)GeneratorEnum.SampleModes] & 0x3)
     {
         case 0x0:
         case 0x2:
             gen.LoopMode = LoopMode.NoLoop;
             break;
         case 0x1:
             gen.LoopMode = LoopMode.Continuous;
             break;
         case 0x3:
             gen.LoopMode = LoopMode.LoopUntilNoteOff;
             break;
     }
     gen.LoopStartPhase = sda.LoopStart + region.Generators[(int)GeneratorEnum.StartLoopAddressOffset] + 32768 * region.Generators[(int)GeneratorEnum.StartLoopAddressCoarseOffset];
     gen.Offset = 0;
     gen.Period = 1.0;
     if (region.Generators[(int)GeneratorEnum.OverridingRootKey] > -1)
         gen.RootKey = region.Generators[(int)GeneratorEnum.OverridingRootKey];
     else
         gen.RootKey = sda.RootKey;
     gen.StartPhase = sda.Start + region.Generators[(int)GeneratorEnum.StartAddressOffset] + 32768 * region.Generators[(int)GeneratorEnum.StartAddressCoarseOffset];
     gen.Tune = (short)(sda.Tune + region.Generators[(int)GeneratorEnum.FineTune] + 100 * region.Generators[(int)GeneratorEnum.CoarseTune]);
     gen.VelocityTrack = 0;
     ((SampleGenerator)gen).Samples = sda.SampleData;
 }