Author Topic: Where are the millisec in ChannelBytes2Sec ?  (Read 9816 times)

fredvs

  • Posts: 325
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

  • Posts: 325
Re: Where are the millisec  in ChannelBytes2Sec ?
« Reply #1 on: 20 Feb '03 - 17:05 »
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

  • Guest
Re: Where are the millisec  in ChannelBytes2Sec ?
« Reply #2 on: 13 May '03 - 18:06 »
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

  • Posts: 325
Re: Where are the millisec  in ChannelBytes2Sec ?
« Reply #3 on: 13 May '03 - 18:43 »
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.
« Last Edit: 15 May '03 - 02:00 by fredvs »

DanaPaul

  • Posts: 335
Re: Where are the millisec  in ChannelBytes2Sec ?
« Reply #4 on: 13 May '03 - 20:52 »

Quote


http://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

  • Posts: 2221
Re: Where are the millisec  in ChannelBytes2Sec ?
« Reply #5 on: 13 May '03 - 22:00 »
do you draw the time with an Label or with an 7segment ???
chris                               
« Last Edit: 13 May '03 - 22:04 by Chris »

fredvs

  • Posts: 325
Re: Where are the millisec  in ChannelBytes2Sec ?
« Reply #6 on: 13 May '03 - 22:43 »
Hello DannaPaul

http://briefcase.yahoo.com/.

The login is mixkfiens and the password is naomie...
« Last Edit: 15 May '03 - 02:00 by fredvs »

fredvs

  • Posts: 325
Re: Where are the millisec  in ChannelBytes2Sec ?
« Reply #7 on: 13 May '03 - 22:47 »
Hello DJ-Chris, for who was your question ?

DanaPaul

  • Posts: 335
Re: Where are the millisec  in ChannelBytes2Sec ?
« Reply #8 on: 13 May '03 - 23:18 »
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

  • Posts: 325
Re: Where are the millisec  in ChannelBytes2Sec ?
« Reply #9 on: 13 May '03 - 23:21 »
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).
« Last Edit: 13 May '03 - 23:22 by fredvs »

DanaPaul

  • Posts: 335
Re: Where are the millisec  in ChannelBytes2Sec ?
« Reply #10 on: 13 May '03 - 23:28 »

Quote


has anyone really tested BASS 1.8 seeking and positioning methods



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

fredvs

  • Posts: 325
Re: Where are the millisec  in ChannelBytes2Sec ?
« Reply #11 on: 13 May '03 - 23:59 »
Base 8.1 ??????????????

Chris

  • Posts: 2221
Re: Where are the millisec  in ChannelBytes2Sec ?
« Reply #12 on: 14 May '03 - 00:39 »
for you Fred.....
du want to draw the time or for what du you need it..?
chris

fredvs

  • Posts: 325
Re: Where are the millisec  in ChannelBytes2Sec ?
« Reply #13 on: 14 May '03 - 01:38 »
Sorry Chris, i dont understand what you mean with "draw the time". (I dont speak very well english)
« Last Edit: 14 May '03 - 01:38 by fredvs »

Chris

  • Posts: 2221
Re: Where are the millisec  in ChannelBytes2Sec ?
« Reply #14 on: 14 May '03 - 10:13 »
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

  • Administrator
  • Posts: 26223
Re: Where are the millisec  in ChannelBytes2Sec ?
« Reply #15 on: 14 May '03 - 12:56 »
Quote
Delphi 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).

Quote
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.

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.

Quote
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.

Remember they are decoded playback positions, not encoded file positions :)

DanaPaul

  • Posts: 335
Re: Where are the millisec  in ChannelBytes2Sec ?
« Reply #16 on: 14 May '03 - 18:30 »

Quote


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).



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


Quote


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.



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

  • Posts: 325
Re: Where are the millisec  in ChannelBytes2Sec ?
« Reply #17 on: 14 May '03 - 20:27 »
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

  • Posts: 2221
Re: Where are the millisec  in ChannelBytes2Sec ?
« Reply #18 on: 14 May '03 - 21:18 »
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

  • Posts: 325
Re: Where are the millisec  in ChannelBytes2Sec ?
« Reply #19 on: 14 May '03 - 21:32 »
Hi DJ-Chris.

It was to have the exact position in milisecond.

DanaPaul

  • Posts: 335
Re: Where are the millisec  in ChannelBytes2Sec ?
« Reply #20 on: 15 May '03 - 04:41 »
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.

fredvs

  • Posts: 325
Re: Where are the millisec  in ChannelBytes2Sec ?
« Reply #21 on: 15 May '03 - 16:49 »
Thanks a lot, of course it interest me.