Exemplo n.º 1
0
 public override void SetVolume(byte vol, sbyte pan)
 {
     if (State < ADSRState.Releasing)
     {
         var range = Engine.GetPanpotRange() / 2;
         if (pan < -range)
         {
             curPan = GBPan.Left;
         }
         else if (pan > range)
         {
             curPan = GBPan.Right;
         }
         else
         {
             curPan = GBPan.Center;
         }
         peakVelocity    = (byte)((Note.Velocity * vol) >> 10).Clamp(0, 0xF);
         sustainVelocity = (byte)((peakVelocity * adsr.S + 0xF) >> 4).Clamp(0, 0xF);
         if (State == ADSRState.Playing)
         {
             curVelocity = sustainVelocity;
         }
     }
 }
Exemplo n.º 2
0
 public override void SetVolume(byte vol, sbyte pan)
 {
     if (State < EnvelopeState.Releasing)
     {
         _panpot          = pan < -21 ? GBPan.Left : pan > 20 ? GBPan.Right : GBPan.Center;
         _peakVelocity    = (byte)((Note.Velocity * vol) >> 10);
         _sustainVelocity = (byte)(((_peakVelocity * _adsr.S) + 0xF) >> 4); // TODO
         if (State == EnvelopeState.Playing)
         {
             _velocity = _sustainVelocity;
         }
     }
 }
Exemplo n.º 3
0
        public override void SetVolume(byte vol, sbyte pan)
        {
            int combinedPan = pan + _instPan;

            if (combinedPan > 63)
            {
                combinedPan = 63;
            }
            else if (combinedPan < -64)
            {
                combinedPan = -64;
            }
            if (State < EnvelopeState.Releasing)
            {
                _panpot          = combinedPan < -21 ? GBPan.Left : combinedPan > 20 ? GBPan.Right : GBPan.Center;
                _peakVelocity    = (byte)((Note.Velocity * vol) >> 10);
                _sustainVelocity = (byte)(((_peakVelocity * _adsr.S) + 0xF) >> 4); // TODO
                if (State == EnvelopeState.Playing)
                {
                    _velocity = _sustainVelocity;
                }
            }
        }