⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mmoscope.pas

📁 一套及时通讯的原码
💻 PAS
📖 第 1 页 / 共 5 页
字号:
                  if ((i+1) mod rZoom = 0) then inc(j);
               end
               else
               for i := 0 to FWidth-1 do
               begin
                  FData^[i] := PSmallArray(PCMData)^[j+j+ReIndex];
                  if ((i+1) mod rZoom = 0) then inc(j);
               end;
            end;
         end;
      end;
      SetData(FData);
   end;
end;

{-- TMMOscope ------------------------------------------------------------}
Procedure TMMOscope.SetData(lpData: PSmallArray);
var
   i,Last,Value: integer;

begin
   if (lpData <> FData) then
      GlobalMoveMem(lpData^,FData^,FWidth*sizeOf(Smallint));

   if FLowPass then
   begin
      Last := 0;
      for i := 0 to FWidth-1 do
      begin
         Value     := FData^[i];
         FData^[i] := (Last+Longint(Value)*3) div 4; { Soft LowPass }
         Last      := Value;
      end;
   end;

   FastDraw(DrawOscope,False);
end;

{-- TMMOscope ------------------------------------------------------------}
Procedure TMMOscope.DrawAsDots;
Var
   i: integer;
   Y1: integer;
   aColor: Long;
   rForeClr: Long;
   rInactClr: Long;
   rEffectClr: Long;
   Value: Longint;

begin
   with DIBCanvas do
   begin
      rForeClr := DIB_ColorToIndex(FForeColor);
      rInactClr := DIB_ColorToIndex(FInactColor);
      if FScroll then
      begin
         DIB_SetTColor(Color);
         DIB_VLine(Fx1,0,FHeight);
         DIB_SetColor(rForeClr);
         if (FEffect = efNone) then
         begin
            for i := 0 to 1 do
            begin              { display points by plotting samples in FData.}
               Value := FData^[i];
               if Value >= 32767 then PcmOverflow;
               Y1 := Long(Value * FGain div 8 + FCenter)* FHeight div FRange;
               if (Y1 > FHeight) then GainOverflow;

               DIB_SetPixel(Fx1, FHeight-Y1-1, rForeClr);
            end;
         end
         else
         begin
            rEffectClr := DIB_ColorToIndex(FEffectColor);
            for i := 0 to 1 do
            begin
               Value := FData^[i];
               if (Value >= 32767) then PcmOverflow;
               Y1 := Long(Value * FGain div 8 + FCenter)* FHeight div FRange;
               if (Y1 > FHeight) then GainOverflow;

               if (Y1 < FEffectTop) or (Y1 > FEffectBottom) then
                  DIB_SetPixel(Fx1, FHeight-Y1-1, rEffectClr)
               else
                DIB_SetPixel(Fx1, FHeight-Y1-1, rForeClr);
            end;
         end;
      end
      else
      begin
         if (FEffect = efNone) then
         begin
            aColor := rInactClr;
            i := 0;
            while i < FWidth do
            begin              { display points by plotting samples in FData.}
               Value := FData^[i];
               if Value >= 32767 then PcmOverflow;
               Y1 := Long(Value * FGain div 8 + FCenter)* FHeight div FRange;
               if (Y1 > FHeight) then GainOverflow;

               if i > FMarkEnd then aColor := rInactClr
               else if i >= FMarkBegin then aColor := rForeClr;

               DIB_SetPixel(i, FHeight-Y1-1, aColor);
               inc(i,FSteps);
            end;
         end
         else
         begin
            rEffectClr := DIB_ColorToIndex(FEffectColor);
            aColor := rInactClr;
            i := 0;
            while i < FWidth do
            begin              { display points by plotting samples in FData.}
               Value := FData^[i];
               if Value >= 32767 then PcmOverflow;
               Y1 := Long(Value * FGain div 8 + FCenter)* FHeight div FRange;
               if (Y1 > FHeight) then GainOverflow;

               if i > FMarkEnd then aColor := rInactClr
               else if i >= FMarkBegin then aColor := rForeClr;

               if (aColor = rForeClr) and ((Y1 < FEffectTop) or (Y1 > FEffectBottom)) then
                  DIB_SetPixel(i, FHeight-Y1-1, rEffectClr)
               else
                  DIB_SetPixel(i, FHeight-Y1-1, aColor);
               inc(i,FSteps);
            end;
         end;
      end;
   end;
end;

{-- TMMOscope ------------------------------------------------------------}
Procedure TMMOscope.DrawAsConLines;
Var
   i: integer;
   Y1: integer;
   aColor: Long;
   rForeClr: Long;
   rInactClr: Long;
   rEffectClr: Long;
   Value: Longint;

begin
   with DIBCanvas do
   begin
      rForeClr := DIB_ColorToIndex(FForeColor);
      rInactClr := DIB_ColorToIndex(FInactColor);
      rEffectClr := DIB_ColorToIndex(FEffectColor);
      if FScroll then
      begin
         DIB_SetTColor(Color);
         DIB_VLine(Fx1,0,FHeight);
         DIB_SetColor(rForeClr);
         DIB_MoveTo(OldDrawPos.X,OldDrawPos.Y);
         if (FEffect = efNone) then
         begin
            for i := 0 to 1 do
            begin
               Value := FData^[i];
               if Value >= 32767 then PcmOverflow;
               Y1 := Long(Value * FGain div 8 + FCenter)* FHeight div FRange;
               if (Y1 > FHeight) then GainOverflow;
               DIB_LineTo(Fx1, FHeight-Y1-1);
            end;
         end
         else
         begin
            for i := 0 to 1 do
            begin
               Value := FData^[i];
               if Value >= 32767 then PcmOverflow;
               Y1 := Long(Value * FGain div 8 + FCenter)* FHeight div FRange;
               if (Y1 > FHeight) then GainOverflow;

               if (Y1 < FEffectTop) or (Y1 > FEffectBottom) then
               begin
                  DIB_SetColor(rEffectClr);
                  DIB_LineTo(Fx1, FHeight-Y1-1);
               end
               else
               begin
                  DIB_SetColor(rForeClr);
                  DIB_LineTo(Fx1, FHeight-Y1-1);
               end;
            end;
         end;
         OldDrawPos := Point(Fx1, FHeight-Y1-1);
      end
      else
      begin
         DIB_SetColor(rInactClr);
         if (FEffect = efNone) then
         begin
            i := FSteps;
            Y1 := Long(FData^[0] * Long(FGain) div 8 + FCenter)* FHeight div FRange;
            DIB_MoveTo(0,FHeight-Y1-1);
            while i < FWidth do
            begin           { display lines by plotting samples in FData.}
               Value := FData^[i];
               if Value >= 32767 then PcmOverflow;
               Y1 := Long(Value * FGain div 8 + FCenter)* FHeight div FRange;
               if (Y1 > FHeight) then GainOverflow;

               if i > FMarkEnd then DIB_SetColor(rInactClr)
               else if i > FMarkBegin then DIB_SetColor(rForeClr);

               DIB_LineTo(i, FHeight-Y1-1);
               inc(i, FSteps);
            end;
            DIB_LineTo(i, FHeight-Y1-1);
         end
         else
         begin
            aColor := rInactClr;
            i := FSteps;
            Y1 := Long(FData^[0] * Long(FGain) div 8 + FCenter)* FHeight div FRange;
            DIB_MoveTo(0, FHeight-Y1-1);
            while i < FWidth do
            begin           { display lines by plotting samples in FData.}
               Value := FData^[i];
               if Value >= 32767 then PcmOverflow;
               Y1 := Long(Value * FGain div 8 + FCenter)* FHeight div FRange;
               if (Y1 > FHeight) then GainOverflow;

               if i > FMarkEnd then aColor := rInactClr
               else if i > FMarkBegin then aColor := rForeClr;

               if (aColor = rForeClr) and ((Y1 < FEffectTop) or (Y1 > FEffectBottom)) then
               begin
                  DIB_SetColor(rEffectClr);
                  DIB_LineTo(i, FHeight-Y1-1);
               end
               else
               begin
                  DIB_SetColor(aColor);
                  DIB_LineTo(i, FHeight-Y1-1);
               end;
               inc(i, FSteps);
            end;
            DIB_LineTo(i, FHeight-Y1-1);
         end;
      end;
   end;
end;

{-- TMMOscope ------------------------------------------------------------}
Procedure TMMOscope.DrawAsVertLines;
Var
   i: integer;
   Y1: integer;
   aColor: Long;
   rForeClr: Long;
   rInactClr: Long;
   rEffectClr: Long;
   Value: Longint;

begin
   with DIBCanvas do
   begin
      rForeClr := DIB_ColorToIndex(FForeColor);
      rInactClr := DIB_ColorToIndex(FInactColor);
      rEffectClr := DIB_ColorToIndex(FEffectColor);
      i := 0;
      if FScroll then
      begin
         DIB_SetTColor(Color);
         DIB_VLine(Fx1,0,FHeight);
         DIB_SetColor(rForeClr);
         if (FEffect = efNone) then
         begin
            Value := FData^[i];
            if abs(FData^[i+1]) > abs(Value) then Value := FData^[i+1];
            if Value >= 32767 then PcmOverflow;
            Y1 := FHeight-(Long(Value * FGain div 8 + FCenter)* FHeight div FRange)-1;
            if (Y1 < -1) then GainOverflow;

            DIB_VLine(Fx1, FMiddle, Y1);
         end
         else if (FEffect = efPeak) then
         begin
            Value := FData^[i];
            if abs(FData^[i+1]) > abs(Value) then Value := FData^[i+1];
            if Value >= 32767 then PcmOverflow;
            Y1 := FHeight-(Long(Value * FGain div 8 + FCenter)* FHeight div FRange)-1;
            if (Y1 < -1) then GainOverflow;

            DIB_VLine(Fx1, FMiddle, Y1);

            if (Y1 < FEffectTop) then
            begin
               DIB_SetColor(rEffectClr);
               DIB_VLine(Fx1, Y1, Y1+5);
            end
            else if (Y1 > FEffectBottom) then
            begin
               DIB_SetColor(rEffectClr);
               DIB_VLine(Fx1, Y1, Y1-5);
            end;
         end
         else if (FEffect = efSplit) then
         begin
            for i := 0 to 1 do
            begin               { display lines by plotting samples in FData.}
               Value := FData^[i];
               if Value >= 32767 then PcmOverflow;
               Y1 := FHeight-(Long(Value * FGain div 8 + FCenter)* FHeight div FRange)-1;
               if (Y1 < -1) then GainOverflow;

               if (Y1 < FEffectBottom) then
                  DIB_SetColor(rEffectClr)
               else
                  DIB_SetColor(rForeClr);

               DIB_VLine(Fx1, FMiddle, Y1);
            end;
         end;
      end
      else
      begin
         DIB_SetColor(rInactClr);
         if (FEffect = efNone) then
         begin
            DIB_HLine(0, FMarkBegin, FMiddle);
            DIB_HLine(0, FMarkBegin, FMiddle-1);
            DIB_SetColor(rForeClr);
            DIB_HLine(FMarkBegin, FMarkEnd+1, FMiddle);
            DIB_HLine(FMarkBegin, FMarkEnd+1, FMiddle-1);
            DIB_SetColor(rInactClr);
            DIB_HLine(FMarkEnd+1, FWidth, FMiddle);
            DIB_HLine(FMarkEnd+1, FWidth, FMiddle-1);
            while i < FWidth do
            begin               { display lines by plntting samples in FData.}
               Value := FData^[i];
               if Value >= 32767 then PcmOverflow;
               Y1 := FHeight-(Long(Value * FGain div 8 + FCenter)* FHeight div FRange)-1;
               if (Y1 < -1) then GainOverflow;

               if i > FMarkEnd then DIB_SetColor(rInactClr)
               else if i >= FMarkBegin then DIB_SetColor(rForeClr);

               DIB_VLine(i, FMiddle, Y1);
               inc(i,FSteps);
            end;
         end
         else if (FEffect = efPeak) then
         begin
            DIB_HLine(0, FMarkBegin, FMiddle);
            DIB_HLine(0, FMarkBegin, FMiddle-1);
            DIB_SetColor(rForeClr);
            DIB_HLine(FMarkBegin, FMarkEnd+1, FMiddle);
            DIB_HLine(FMarkBegin, FMarkEnd+1, FMiddle-1);
            DIB_SetColor(rInactClr);
            DIB_HLine(FMarkEnd+1, FWidth, FMiddle);
            DIB_HLine(FMarkEnd+1, FWidth, FMiddle-1);
            aColor := rInactClr;
            while i < FWidth do
            begin               { display lines by plotting samples in FData.}
               Value := FData^[i];
               if Value >= 32767 then PcmOverflow;
               Y1 := FHeight-(Long(Value * FGain div 8 + FCenter)* FHeight div FRange)-1;
               if (Y1 < -1) then GainOverflow;

               if i > FMarkEnd then aColor := rInactClr
               else if i >= FMarkBegin then aColor := rForeClr;

               DIB_SetColor(aColor);
               DIB_VLine(i, FMiddle, Y1);

               if (aColor = rForeClr) then
               begin
                  if (Y1 < FEffectTop) then
                  begin
                     DIB_SetColor(rEffectClr);
                     DIB_VLine(i, Y1, Y1+5);
                  end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -