public static void Start(this ModulationEnvelope envelope, RegionPair region, int key, int velocity) { // According to the implementation of TinySoundFont, the attack time should be adjusted by the velocity. var delay = region.DelayModulationEnvelope; var attack = region.AttackModulationEnvelope * ((145 - velocity) / 144F); var hold = region.HoldModulationEnvelope * SoundFontMath.KeyNumberToMultiplyingFactor(region.KeyNumberToModulationEnvelopeHold, key); var decay = region.DecayModulationEnvelope * SoundFontMath.KeyNumberToMultiplyingFactor(region.KeyNumberToModulationEnvelopeDecay, key); var sustain = 1F - region.SustainModulationEnvelope / 100F; var release = region.ReleaseModulationEnvelope; 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 ModulationEnvelope envelope, InstrumentRegion region, int key, int velocity) { Start(envelope, new RegionPair(PresetRegion.Default, region), key, velocity); }