22 May '13 - 12:28 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Reply  |  Print  
Author Topic: slider position BASS_CHANNEL  (Read 882 times)
lumoraes
Posts: 6


« on: 31 Dec '11 - 11:47 »
Reply with quoteQuote

i need example code in delphi to know the position of the audio within a timer. example:

00:00:01 / 03:00:00

elapsed time / total time

using BASS_Channel

thanks
Logged
ZuBy
Posts: 46


« Reply #1 on: 31 Dec '11 - 15:00 »
Reply with quoteQuote

Hi

Look at the demo project from the bass

ZuBy
Logged
Ian @ un4seen
Administrator
Posts: 15259


« Reply #2 on: 3 Jan '12 - 15:15 »
Reply with quoteQuote

elapsed_bytes = BASS_ChannelGetPosition(handle, BASS_POS_BYTE);
elapsed_time = BASS_ChannelBytes2Seconds(handle, elapsed_bytes);

total_bytes = BASS_ChannelGetLength(handle, BASS_POS_BYTE);
total_time = BASS_ChannelBytes2Seconds(handle, total_bytes);

Please see the documentation for details on the aforementioned function.
Logged
lumoraes
Posts: 6


« Reply #3 on: 16 Jan '12 - 14:51 »
Reply with quoteQuote

Hello Zuby.

The examples in demo project not exists for BASS24 , only bass_fx24.

HELP ME?Huh

THANKS

LUMORAES- BRAZIL



Hi

Look at the demo project from the bass

ZuBy
Logged
AnthonyM
Posts: 47


« Reply #4 on: 17 Jan '12 - 10:54 »
Reply with quoteQuote

lumoraes:

Ian gave you enough information to do what you want.
With his code, reading of the documentation for the specified functions and a bit of experience in Delphi you should be able to work out the rest.

I will do my best with NO EXPERIENCE with Delphi.

Add a TTimer to your program this can be found in the System Tab within the Component Palette. (1)

Set the interval property of the TTimer to how often you want to check the elapsed time. I usually set it for 250 (milliseconds).
But 1000 (1 second) should be frequent enough. (1)

Create a new function to convert seconds to a time string (2):
function SecToTime(Sec: Integer): string;
var
   H, M, S: string;
   ZH, ZM, ZS: Integer;
begin
   ZH := Sec div 3600;
   ZM := Sec div 60 - ZH * 60;
   ZS := Sec - (ZH * 3600 + ZM * 60) ;
   H := IntToStr(ZH) ;
   M := IntToStr(ZM) ;
   S := IntToStr(ZS) ;
   Result := H + ':' + M + ':' + S;
end;
The above function will produce an output of HH:MM:SS (adjust as you need).

In the TTimer's "OnTimer" event put the following code (3):
elapsed_bytes = BASS_ChannelGetPosition(handle, BASS_POS_BYTE);
elapsed_time = BASS_ChannelBytes2Seconds(handle, elapsed_bytes);
elapsed_time_str = SecToTime(elapsed_time);

total_bytes = BASS_ChannelGetLength(handle, BASS_POS_BYTE);
total_time = BASS_ChannelBytes2Seconds(handle, total_bytes);
total_time_str = SecToTime(total_time);

time_str = elapsed_time_str + "/" + total_time_str;
You should really get the total_time value ONCE when you first create the channel and store it somewhere as it won't change as the channel plays. But to keep the example simple I kept it in the timer event.

I hope this helps Smiley

(1) http://stackoverflow.com/questions/5399928/execute-action-every-x-seconds-delphi
(2) http://delphi.about.com/cs/adptips2003/a/bltip0403_5.htm
(3) Adapted from Ian's post.
« Last Edit: 17 Jan '12 - 10:57 by AnthonyM » Logged
lumoraes
Posts: 6


« Reply #5 on: 3 Apr '12 - 01:37 »
Reply with quoteQuote

thanks for help

is how I view the microseconds?

thanks

LUMORAES BRAZIL

Logged
AnthonyM
Posts: 47


« Reply #6 on: 3 Apr '12 - 02:04 »
Reply with quoteQuote

Hello Lumoraes,

BASS doesn't have an inbuilt function to get milliseconds elapsed.
Logged
Ian @ un4seen
Administrator
Posts: 15259


« Reply #7 on: 3 Apr '12 - 14:16 »
Reply with quoteQuote

The BASS_ChannelBytes2Seconds return value is floating-point, so you aren't limited to second precision/units, eg. you can multiply it by 1000 for milliseconds.
Logged
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines