AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Projekte Mein kleiner mp3-Player... Updated 13.12.04
Thema durchsuchen
Ansicht
Themen-Optionen

Mein kleiner mp3-Player... Updated 13.12.04

Ein Thema von dizzy · begonnen am 25. Sep 2004 · letzter Beitrag vom 26. Feb 2005
 
Benutzerbild von dizzy
dizzy

Registriert seit: 26. Nov 2003
Ort: Lünen
1.932 Beiträge
 
Delphi 7 Enterprise
 
#11

Re: Mein kleiner mp3-Player...

  Alt 18. Nov 2004, 14:17
Zitat von urbanbruhin:
aber kann man auch mit der bass.dll arbeiten, wenn man zum abspielen von dateien den Tmediaplayer nimmt??
Nein. Es könnte u.U. einen Umweg geben, indem man mit der bass.dll das vom Mediaplayer wiedergegebene aufnehmen lässt, und sich den Pegel davon abholt, aber das ist ziemlicher Schwachfug .
Der Mediaplayer ist imho nicht wirklich der Weisheit letzter Schluss...

Zitat von urbanbruhin:
wenn ja: wie kann man so ein colles dings da in der mitte programmieren?? (ein code wäre nicht schlecht, falls du ihn hergeben willst)
Willst du wirklich!?
Na gut....
Delphi-Quellcode:
//------------------------------------------------------------------------------
//------- The Volume-Bars ------------------------------------------------------
// SECTION BEGIN ---------------------------------------------------------------
{ How does it work?
  At first the volumes is "smoothed". This is done by checking whether the new
  volume is lower or greater than the former one.
  If it is lower, then not the actual new vlomue is taken, but the former one
  slightly decreased.
  If it is greater, the value is just taken "as is".
  The resulting volume-values are taken to calculate an angle between 0 and
  (3/4)*pi.
  (Pi would make a 180°-turn, and i didn't want the bars to clap together at
  max-volume -> thus i took (3/4)*pi.)
  The channel-volume is also the base for calculating the colors. Low volume
  produces green color, and the higher the volume gets, the more the color turns
  into red.
  Then when drawing the bars, i use a loop that draws the lines for all volumes
  that are lower or equal to the actual value, because just drawing the line
  for the actual value wouldn't result in "bars" but simple two dancing lines...
  The constant numbers in the drawing-routines are depending on where the bars
  should appear, and how large the inner and outer ellipse should be.
  (They are constant here because it is faster.)                               }

procedure DrawVisVolume(var bmp: TBitmap32; const Source: TBassplayer);
var
  lv, rv : Double;
  m : Double;
  c : Integer;
  sinM, cosM: Extended;
const
  step: Double = 0.02;
begin
  lv := Source.LeftPeak;
  rv := Source.RightPeak;
  if lv > 128 then lv := 0;
  if rv > 128 then rv := 0;
  lv := 0.018407769*lv; // := 0.005859375*lv*pi; // := (lv / 128)*(pi/4)*3; <--- is same
  rv := 0.018407769*rv; // := 0.005859375*rv*pi; // := (rv / 128)*(pi/4)*3; <--- is same

  if lv < lVol then
    lVol := lVol - 0.125
  else
    lVol := lv;

  if rv < rVol then
    rVol := rVol - 0.125
  else
    rVol := rv;

  m := 0;
  repeat
    c := trunc(108.2253613*m); // := trunc(340*m / pi); <--- // := trunc((m * 255) / ((3/4)*pi)); <--- is same
    sincos(m, sinM, cosM);
    bmp.LineF(200+120*-sinM,
              200+150* cosM,
              200+180*-sinM,
              200+180* cosM,
              Color32(c,255-c,32));
    m := m + step;
  until m > lVol;

  m := step;
  repeat
    c := trunc(108.2253613*m); // := trunc(340*m / pi); <--- // := trunc((m * 255) / ((3/4)*pi)); <--- is same
    sincos(m, sinM, cosM);
    bmp.LineF(200-120*-sinM,
              200+150* cosM,
              200-180*-sinM,
              200+180* cosM,
              Color32(c,255-c,32));
    m := m + step;
  until m > rVol;
end;
Packs die nicht standardmäßig bei Delphi dabei sind: Graphics32-Lib; bass.dll + modifizierte Version der Bassplayer.pas vom DP-User Gandalfus (TBassplayer).
Die komischen Kommentare im Code sind für mich zur Erinnerung wie die konstanten Werte im eigentlichen Code ursprünglich entstanden sind.
Diese Prozedur zeichnet die Volume-Bars auf ein beliebiges TBitmap32 das ausreichend groß ist. Da das ganze allerdings doch schon recht speziell ist, weiss ich nicht, ob dir das so wirklich weiter hilft...

Zitat von urbanbruhin:
oder einfach ein ganz normaler Tstatusbar, der den pegel anzeigt??
Wäre zumindest erstmal die einfachere Alternative. Um ehrlich zu sein hab ich das auch zunächst so gemacht. Einfach rumspielen und haufenweise Fehler kassieren, und wenn es irgendwann gut aussieht, dann so lassen. So mach ich das immer

Gruss,
Fabian

\\edit: btw.: Die gesamte Unit für die Visuals ist genau 599 Zeilen, die die dafür sorgt dass alles zur rechten Zeit an rechter Stelle gezeichnet wird macht nochmal ~300. Das sind mal sopntan 900 Zeilen Code nur für das Visual, da ist noch kein Lied mit abgespielt, geschweige denn eine GUI gebaut und gesteuert...
Fabian K.
INSERT INTO HandVonFreundin SELECT * FROM Himmel
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 07:26 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz