Autor Beitrag
Leuchtturm
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1087

Win Vista, Knoppix, Ubuntu
Delphi 7 Pe, Turbo Delphi, C#(VS 2005 Express), (X)HTML + CSS, bald Assembler
BeitragVerfasst: So 12.11.06 12:50 
Hi,
warum funktioniert das nicht:
ausblenden Delphi-Quelltext
1:
2:
3:
  PositionsTimer.Enabled := false;
  pos := TrackBar2.Position;
  BASS_ChannelSetPosition(Channel, pos);

Ich will das die Position der TrackBar die Position des Liedes ändert.
Das funktioniert aber nicht ein bissll. Ich kann die TrackBar zwar verschieben aber da fängt das Lied immer wieder von vorne an.
Was müsste man anders machen :?:
Leuchtturm

_________________
Ich bin dafür verantwortlich was ich sage - nicht dafür was du verstehst.
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8548
Erhaltene Danke: 477

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: So 12.11.06 12:54 
Wie sind denn die Werte in der Trackbar? Die Positionsangaben bei der Bass.dll sind in Bytes im umkomprimierten Audiostrom! Ein Lied hat also locker ne maximale Position von 50.000.000 (grobe Rechnung: 1 CDDA=700MB, 10Lieder/Cd => 70MB/Lied, und dann noch was abgezogen).
Wenn deine Trackbar von 0 bis 100 geht, ist Alles am Anfang des Liedes ;-)

_________________
We are, we were and will not be.
Leuchtturm Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1087

Win Vista, Knoppix, Ubuntu
Delphi 7 Pe, Turbo Delphi, C#(VS 2005 Express), (X)HTML + CSS, bald Assembler
BeitragVerfasst: So 12.11.06 12:57 
Meine TrackBar geht von 0 bis 500.
wie könnte man das umwandeln

_________________
Ich bin dafür verantwortlich was ich sage - nicht dafür was du verstehst.
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8548
Erhaltene Danke: 477

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: So 12.11.06 13:03 
Mit Bass_ChannelGetLength bekommst du die Länge des Streams. Dann einfach die Position der Trackbar entsprechend umsetzen:

ausblenden Delphi-Quelltext
1:
2:
BASS_ChannelSetPosition(Channel, TrackbarPos * BassLänge / TrackbarMax);
// Variablen-Bezeichner natürlich entsprechend ändern ;-)

_________________
We are, we were and will not be.
Leuchtturm Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1087

Win Vista, Knoppix, Ubuntu
Delphi 7 Pe, Turbo Delphi, C#(VS 2005 Express), (X)HTML + CSS, bald Assembler
BeitragVerfasst: So 12.11.06 15:45 
Jetzt spielts jede Sekunde zweimal und geht dan zur nächsten
Ich glaube es liegt hier dran liegt es:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
  VisTimer.Enabled := false;
  PositionsTimer.Enabled := false;
  pos := TrackBar2.Position;
  TrackLength := Bass_ChannelGetLength(Channel);
  BASS_ChannelSetPosition(Channel, pos * TrackLength div TrackBar2.Max);
  VisTimer.Enabled := true;
  PositionsTimer.Enabled := true;//ich denke das es hier dran liegt


Wenn ich PositionsTimer.Enabled := true; auskommentiere geht es einwndfrei:

ausblenden Code aus PositionsTimer
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
procedure TForm1.PositionsTimer(Sender: TObject);
var
a, b: DWord;
x, ADS: Integer;
begin
  try
    a := Bass_ChannelGetLength(Channel);
    b := BASS_ChannelGetPosition(Channel);
    x := a div 500;
    ADS := b div x;
    TrackBar2.Position := ADS;
  except
  end;  
end;

Liegt das jetzt am Timer oder an der TrackBarprocedure :?: :nixweiss:
Leuchtturm

_________________
Ich bin dafür verantwortlich was ich sage - nicht dafür was du verstehst.
Leuchtturm Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1087

Win Vista, Knoppix, Ubuntu
Delphi 7 Pe, Turbo Delphi, C#(VS 2005 Express), (X)HTML + CSS, bald Assembler
BeitragVerfasst: Fr 17.11.06 17:01 
weiß denn da keiner eine lösung

_________________
Ich bin dafür verantwortlich was ich sage - nicht dafür was du verstehst.
Leuchtturm Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1087

Win Vista, Knoppix, Ubuntu
Delphi 7 Pe, Turbo Delphi, C#(VS 2005 Express), (X)HTML + CSS, bald Assembler
BeitragVerfasst: Mo 20.11.06 19:23 
*push*

_________________
Ich bin dafür verantwortlich was ich sage - nicht dafür was du verstehst.
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8548
Erhaltene Danke: 477

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mo 20.11.06 19:39 
Ich würde jetzt spontan auf zwei Sachen tippen.

Erstens verändert der Timer Trackbar.Position, was möglicherweise das Onchange-Event der Trackbar auslöst, wodurch die Position im Lied neu gesetzt wird. D.h.: Im Timer vor dem Umsetzen diesem Ereignis Nil zuweisen und hinterher wieder auf die Change-Prozedur setzen.

Zum anderen ist deine Berechnung der Position unelegant, da du dort mehrfach rundest. Besser wäre, das direkt zu berechnen per
ausblenden Delphi-Quelltext
1:
TrackBar2.Position := Round(500 * BASS_ChannelGetPosition(Channel) / Bass_ChannelGetLength(Channel));					

_________________
We are, we were and will not be.