Where are the millisec in ChannelBytes2Sec ?

Started by fredvs,

fredvs

Hello everybody.
Thanks for your bass Ian.
In a last thread, you give us a function :

Function ConvertSecondsToTime(iSeconds: real): TDateTime;
Var
 hours, min: Word;
Begin
 hours := Trunc(iSeconds / 3600);
 iSeconds := iSeconds - (3600 * Trunc(iSeconds / 3600));
 min := Trunc(iSeconds / 60);
 iSeconds := iSeconds - (60 * Trunc(iSeconds / 60));
 Result := EncodeTime(hours, min, trunc(iSeconds), 0);
End;

Perfect, i have now the correct sec and minuts.
But how can i find the milliseconds, i always receive a integer value for iSeconds, the same as trunc(iSecconds) ?

fredvs

Sorry Folks, it is my fault.
Hello Ian, i must say to you, i use Delphi 3 (i find it more stable, more components, exe more litle) and in a old thread, you speak me about the COMP Delphi 3 var in place of the INT64 Delphi 6.

I have changed it in bass.pas for:

Function BASS_ChannelBytes2Seconds(handle: DWORD; pos: COMP)

Function BASS_ChannelSetPosition(handle: DWORD; pos: COMP)

and of course in const :
   QW_ERROR = LONGINT(-1);    // -1 (QWORD)

and in var
  QWORD = longint;
(if i change QWORD = comp, it does not work ?!)

Now, bass functionate perfectly, i can use all your functions.

And the problem of miliseconds was from me.
The result of Function BASS_ChannelBytes2Seconds is a FLOAT
value, not a COMP who is a integer value.

If you want, i can mail you the Delphi3 bass.pas, i have tested nearly all of your functions and it works perfectly.


Dana

I know this is an old thread, but for what it may be worth...

Delphi 3 and earlier do not have a 64 bit Integer.  Comp is a floating point integer type, not a true 64 bit integer.  Using Comp as an INVAR or OUTVAR in place of any 64 bit integer will produce unexpected results, including Invalid Floating Point Operation, and gibberish instead of logical integer values.

Type casting QWORD (64 bits) into an integer (32 bits) will produce unexpected results because the stack frame will not have the correct number of bytes allocated to hold the 64 bit result returned from BASS.DLL.

Alternatively, you should use an array of DWord or packed record such as TLargeInteger defined in Windows.pas in place of QWORD.  Do not access the QuadPart field defined in TLargeInteger because the 64 bit (floating point) Comp value will contain gibberish.  You may try to access the TLargeInteger.LowPart field (DWord) and hope that the 64 bit result did not contain any value larger than 32 bits.

I'm currently attempting a Delphi v2 port of Bass.pas (dynamic loading) that will (hopefully) exploit the full range of Delphi's Comp (floating point) type using additional code to check for a BASS result error value and convert valid 64 bit results into Delphi's Comp type.

Suggestions anyone?


fredvs

Thanks for your opinion.

I dont find any problem with the comp vaiable with Delphi 3.

Here my program writen with Delphi 3.

http://briefcase.yahoo.com/. (yahoo! ID : mixkfiens, password : naomie)

Maybe, you can try it, if you get unexpected result, please report it here. Thanks.

DanaPaul


Quotehttp://fr.briefcase.yahoo.com/mixkfiens.

Maybe, you can try it, if you get unexpected result, please report it here. Thanks.

I would be happy to, but, errr... all I could find was a screen shot?

The example code that you posted earlier, type casting QWORD as a 4 byte "integer" may be incorrect.  Additionally, this example also defined the QW_ERROR constant as an integer;

All of the documentation that I've come across state that a Delphi "integer" is a 4 byte value through Delphi ver 6. Perhaps this would explain any apparent success you've experienced with the COMP floating point value, 4 bytes instead of the full 8 bytes allocated by COMP and returned by BASS?

Chris

do you draw the time with an Label or with an 7segment ???
chris                               

fredvs

Hello DannaPaul

http://briefcase.yahoo.com/.

The login is mixkfiens and the password is naomie...


DanaPaul

Thanks for access to the file Fred. I've downloaded your app and I'll take it for a spin in a bit.

I tried your example, Delphi COMP (8 bytes) for OUTVAR parameters and DWord (4 byte) for (INVAR parameters) function Result and it works like a champ.

Mia Culpa

Hmmmm... which begs the question, has anyone really tested BASS 1.8 seeking and positioning methods with any media file sizes larger than 2 GB or 4 GB?  Of course, these file sizes are difficult (or impossible) on a FAT32 drive.

fredvs

No, sorry, and i work with Win 98 SE, but i will be happy to have your result with MixK (of course, you will not see the hours positions).

DanaPaul


Quotehas anyone really tested BASS 1.8 seeking and positioning methods


Err.... Base 8.1, (not 1.8!! :)


Chris

for you Fred.....
du want to draw the time or for what du you need it..?
chris

fredvs

Sorry Chris, i dont understand what you mean with "draw the time". (I dont speak very well english)

Chris

Once more about your BASS_ChannelBytes2Seconds
here the code to get it icl. Milliseconds

function GetPlayLength : DWORD;
var
   SongLength : int64;
   FloatLen : FLOAT;
begin
   result := 0;
SongLength := BASS_StreamGetLength(Channel);
FloatLen := BASS_ChannelBytes2Seconds(Channel, SongLength);
   result := round(1000 * FloatLen);   // sec -> milli sec
now you have your milliseconds

Chris

Ian @ un4seen

QuoteDelphi 3 and earlier do not have a 64 bit Integer.  Comp is a floating point integer type, not a true 64 bit integer.
I've never used COMP (or even Delphi), so I'm not sure about this, but I think COMP uses floating-point math, with the result converted to and stored as a 64-bit integer? If that's the case, it should be perfectly good for passing 64-bit parameters, though maybe not for receiving 64-bit return values (depends on how/where Delphi expects COMP values to be returned).

QuoteType casting QWORD (64 bits) into an integer (32 bits) will produce unexpected results because the stack frame will not have the correct number of bytes allocated to hold the 64 bit result returned from BASS.DLL.
Casting 64-bit return values to 32-bit is not a problem (apart from the loss of the upper 32-bits of course :)).

Return values (integer) are given in the EAX and EDX registers (not the stack). So if a compiler does not support 64-bit, or the variable to receive the return value is not 64-bit, it simply ignores EDX (the high 32-bits), with no damage to the stack.

QuoteHmmmm... which begs the question, has anyone really tested BASS 1.8 seeking and positioning methods with any media file sizes larger than 2 GB or 4 GB?  Of course, these file sizes are difficult (or impossible) on a FAT32 drive.
Remember they are decoded playback positions, not encoded file positions :)

DanaPaul


QuoteCOMP uses floating-point math, with the result converted to and stored as a 64-bit integer? If that's the case, it should be perfectly good for passing 64-bit parameters, though maybe not for receiving 64-bit return values (depends on how/where Delphi expects COMP values to be returned).


Correct, this is the behavour we are seeing.  Comp behaves fine in the parameter list, but retrieves gibberish when returned as a function result.


QuoteReturn values (integer) are given in the EAX and EDX registers (not the stack). So if a compiler does not support 64-bit, or the variable to receive the return value is not 64-bit, it simply ignores EDX (the high 32-bits), with no damage to the stack.


Thanks, I have an ASM snippet somewhere that builds a parameter stack and calls a function.  Maybe I can make some use of this.  Delphi supports inline and embedded ASM :)

fredvs

For you DJ Chris.

Thanks, but the subject of the thread is the INT64 variable that dont exist in Delphi 3, then we use the COMP variable.

Chris

Ok then use the Comp variable..and then you have the milliseconds.....but my question in one thread befor was for what do you need it ???

fredvs

Hi DJ-Chris.

It was to have the exact position in milisecond.

DanaPaul

Fred,

I have a Bass 1.8 header file for Delphi (ver 2.0 and later) that will use ASM (for Delphi versions 3 and earlier) to call the BASS functions that return a 64 bit value.  The 64 bit returned values (EAX & EDX combined registers) are put into a Delphi COMP type.  The gibberish is eliminated :)

I'll post the Delphi header file by this weekend and note the URL here in case you are interested.