Einzelnen Beitrag anzeigen

Abversoft

Registriert seit: 30. Aug 2010
6 Beiträge
 
#7

AW: Scrolling Spectrum

  Alt 13. Feb 2014, 19:46
Then what do you need? We can do marvelous things here, but reading minds ain't one. Why do so many people have such problems simply stating what they want to do, and what happens instead? Escapes me entirely.
When in doubt, post code, mark the line where compiling fails or a runtime error appears, and copy&paste the error message(s) underneath. Even if it's just that output differs from expectation, at least SOME information about what you did would be greatly appreciated. And by that I, of course, mean code.
Below is a code that allows you to create motion Spectrum. The problem is that it is wrong to count the data. As a result, Spectrum does not look believable.


var
Form1 : TForm1;
Mp3Len : Cardinal;
XPos : Integer = 0;
aLevel : Cardinal;
aLeft, aRight: single;
WaveOscil : TWaveData;
wavebufL, wavebufR: array of smallint;
ArrWaveL, ArrWaveR: array of array of Integer;

procedure DrawLine(Canvas: TCanvas; X, Y, X2, Y2: Integer);
begin
Canvas.MoveTo(X, Y);
Canvas.LineTo(X2, Y2);
end;

{Draw waveforms}

procedure TForm1.Draw;
var
i, j, y : integer;
WvWig : integer;
L, R, aL, aR : SmallInt;
VisBuff : Tbitmap;
Sample : Smallint;
begin
VisBuff := CreateBmp32(PaintBox2.Width, PaintBox2.Height);
y := (PaintBox2.height - 2) div 2;
WvWig := Round(PaintBox2.Width / WvSpeed);

VisBuff.Canvas.Brush.Color := 0;
VisBuff.Canvas.Pen.Color := $00E6C62D;
VisBuff.Canvas.FillRect(VisBuff.Canvas.ClipRect);
for j := 0 to WvSpeed do
begin

Sample := MulDiv(128, Smallint(LOWORD(WaveOscil[j])), 32768);
if Sample < Low(ShortInt) then
Sample := Low(ShortInt)
else if Sample > High(ShortInt) then
Sample := High(ShortInt);
//-----------------------
L := SmallInt(Loword(WaveOscil[j]));
R := SmallInt(Hiword(WaveOscil[j]));
aL := (trunc(((L ) / (65535)) * y));
// aL := Abs(Trunc(L/32768*50));
aR := (trunc(((R) / (65535)) * y));
//----------------------------
ArrWaveL[j][0] := aL;
ArrWaveR[j][0] := aR;

for i := 0 to WvWig do
begin
ArrWaveL[j][WvWig - i] := ArrWaveL[j][WvWig - i - 1];
ArrWaveR[j][WvWig - i] := ArrWaveR[j][WvWig - i - 1];
end;

end;

for i := 0 to WvWig do
begin
for j := 0 to WvSpeed do
begin
DrawLine(VisBuff.Canvas,
i * WvSpeed + j, y div 2,
i * WvSpeed + j, (y div 2) + ArrWaveL[j][WvWig - i]);

DrawLine(VisBuff.Canvas,
i * WvSpeed + j, y div 2,
i * WvSpeed + j, (y div 2) - ArrWaveL[j][WvWig - i]);

DrawLine(VisBuff.Canvas,
i * WvSpeed + j, (VisBuff.height div 2) + (y div 2),
i * WvSpeed + j, (VisBuff.height div 2) + (y div 2) + ArrWaveR[j][WvWig -
i]);

DrawLine(VisBuff.Canvas,
i * WvSpeed + j, (VisBuff.height div 2) + (y div 2),
i * WvSpeed + j, (VisBuff.height div 2) + (y div 2) - ArrWaveR[j][WvWig -
i]);

end;
end;

BitBlt(PaintBox2.Canvas.Handle, 0, 0, VisBuff.Width, VisBuff.Height,
VisBuff.Canvas.Handle, 0, 0, srccopy);
VisBuff.Free;

end;

See the compiled example
Miniaturansicht angehängter Grafiken
screen1.jpg  
Angehängte Dateien
Dateityp: zip mp3_9d.zip (234,7 KB, 20x aufgerufen)

Geändert von Abversoft (13. Feb 2014 um 19:57 Uhr)
  Mit Zitat antworten Zitat