public static void Start(this VolumeEnvelope envelope, RegionPair region, int key, int velocity) { // If the release time is shorter than 10 ms, it will be clamped to 10 ms to avoid pop noise. var delay = region.DelayVolumeEnvelope; var attack = region.AttackVolumeEnvelope; var hold = region.HoldVolumeEnvelope * SoundFontMath.KeyNumberToMultiplyingFactor(region.KeyNumberToVolumeEnvelopeHold, key); var decay = region.DecayVolumeEnvelope * SoundFontMath.KeyNumberToMultiplyingFactor(region.KeyNumberToVolumeEnvelopeDecay, key); var sustain = SoundFontMath.DecibelsToLinear(-region.SustainVolumeEnvelope); var release = Math.Max(region.ReleaseVolumeEnvelope, 0.01F); envelope.Start(delay, attack, hold, decay, sustain, release); }
internal Voice(Synthesizer synthesizer) { this.synthesizer = synthesizer; volEnv = new VolumeEnvelope(synthesizer); modEnv = new ModulationEnvelope(synthesizer); vibLfo = new Lfo(synthesizer); modLfo = new Lfo(synthesizer); oscillator = new Oscillator(synthesizer); filter = new BiQuadFilter(synthesizer); block = new float[synthesizer.BlockSize]; }
public static void Start(this VolumeEnvelope envelope, InstrumentRegion region, int key, int velocity) { Start(envelope, new RegionPair(PresetRegion.Default, region), key, velocity); }