Author Topic: Sonique Visualization  (Read 53666 times)

Sebastian_Mares

  • Guest
Re:Sonique Visualization
« Reply #25 on: 4 Jan '04 - 19:31 »
Only 59% here. ;D

Irrational86

  • Posts: 960
Re:Sonique Visualization
« Reply #26 on: 4 Jan '04 - 21:15 »
Well, the CPU usage is not really a problem of the DLL, if not of some factors, like size of display area, the resolution of the timer you are using to render, and which plugin is in use, some are more resource hogs than others...
« Last Edit: 4 Jan '04 - 21:16 by XMinioNX »

Philip Hadar

  • Posts: 79
Re:Sonique Visualization
« Reply #27 on: 4 Jan '04 - 23:07 »
Well You are right !

I still have a problem, everytime my form get focused, I get an error message "Invalid Floating Point Operation"
I don't have anything on the OnActivate event.
I think it come from some kind of conflict with other classes in my use clause - wierd  :'(

Irrational86

  • Posts: 960
Re:Sonique Visualization
« Reply #28 on: 4 Jan '04 - 23:25 »
hmm...do you do some special processing different when the form is focused than when its not focused?

DanaPaul

  • Posts: 335
Re:Sonique Visualization
« Reply #29 on: 5 Jan '04 - 00:08 »
everytime my form get focused, I get an error message "Invalid Floating Point Operation"

Delphi doesn't raise Invalid Floating Point Operation (exception) immediately, instead, this exception is raised during a wait state, or the next time the Floating Point Processor is accessed/used.  You are probably seeing this during/after your form activation because this form activate event is always imediately followed by an Input Idle event.

I would check for buffer overrun, declared (floating point) integer types, and re-entrant code, try this...

procedure OnTimer;
  const
    Busy: boolean = False;
  begin
    if Busy then exit;
    Busy := True;
    Try
      (do sum stuff...)
    Finally
      Busy := False;
      end;
    end;
« Last Edit: 5 Jan '04 - 00:10 by DanaPaul »

Philip Hadar

  • Posts: 79
Re:Sonique Visualization
« Reply #30 on: 5 Jan '04 - 01:20 »
I already tried that but it won't work.
Is my PaintBox should be on a different form / thread ?

DanaPaul

  • Posts: 335
Re:Sonique Visualization
« Reply #31 on: 5 Jan '04 - 02:00 »
No.  Using a separate thread introduces a whole new world of issues, especially for Delphi VCL graphical objects, and the PaintBox is a graphical control.  Besides, the Paint Box doesn't use Floating Point integer types ;)

I had a similar issue with Lame.dll, it would cause this Floating Point exception to be raised immediately after initializing any encode stream until I got the (raw) buffer sizes perfect.

Otherwise, it's in your code, or the header, or the library itself.  You didn't have this error using Basss without the BassWA library?  

Curious, what Delphi version are you using and are your Bass 64 bit (result) types defined as INT64 or Comp?

Additionally, one Delphi header that I came across defined Delphi string types in Bass_WA header library function parameter lists.  This convention requires the "SharedMemory" unit that is shipped with Delphi for sharing large blocks of memory. This "SharedMem" unit must be compiled in both the (Delphi) library and the main executable.  

Otherwise, char array types should be defined as PChar types (conventional wisdom) or the old Delphi (1.0) ShortString type.



« Last Edit: 5 Jan '04 - 02:20 by DanaPaul »

Irrational86

  • Posts: 960
Re:Sonique Visualization
« Reply #32 on: 5 Jan '04 - 05:00 »
Well...the way DanaPaul said (the Busy := True and such) is the way i use in BassVis...and also with the try/except error handlers...i only once received a floating point error, and never again, so i cant really find out where it came from, my guess is that it comes from a plugin doing something wrong...btw, which plugin were you using when you got the error?

Philip Hadar

  • Posts: 79
Re:Sonique Visualization
« Reply #33 on: 5 Jan '04 - 12:54 »
Ok I think I got it, the problem occurs whenever there is a call to BASS_ChannelGetPosition

The visual is "ChaosWave.svp"
Delphi 4
I didn't understand the question about the Int64 stuff

georgebou

  • Posts: 189
Re:Sonique Visualization
« Reply #34 on: 5 Jan '04 - 15:24 »
Hi.

I think that the ChaosWave.svp uses OpenGL graphics.

In delphi's 6 help is reported the following:

Code: [Select]
It is recommended that you disable all floating-point exceptions when using OpenGL to render 3D graphics. To do this, call Set8087CW(0x133f) in your main form’s OnCreate event before calling any OpenGL functions.

Personally i use it ( Set8087CW(0x133f) ) in my application.
When i disabled this function and i tried to load the ChaosWave.svp,
i got the  floating point errors you are talking about

DanaPaul

  • Posts: 335
Re:Sonique Visualization
« Reply #35 on: 5 Jan '04 - 18:13 »
the problem occurs whenever there is a call to BASS_ChannelGetPosition ... The visual is "ChaosWave.svp" ... Delphi 4

With Delphi ver 4 and later, make sure that you are using Int64 (64 bit) integer type instead of Comp.  Comp is native to the Intel processor and uses the Floating Point Processor.  Delphi ver 3 and earlier need to use Comp for lack of any Int64 type.  Bass_ChannelGetPosition returns a 64 bit integer.  Check any old code that you may have for this Comp type.

Quote
It is recommended that you disable all floating-point exceptions when using OpenGL to render 3D graphics. To do this, call Set8087CW(0x133f) in your main form’s OnCreate event before calling any OpenGL functions.

Nice catch! ;)






Philip Hadar

  • Posts: 79
Re:Sonique Visualization
« Reply #36 on: 5 Jan '04 - 21:10 »
Many thanks to both of you!

Calling Set8087CW(4927) did a lot of help, I still get an exception if the paintbox is smaller than in the example provided with BassVis. As of the Bass result of BASS_ChannelGetPosition, it's a Int64 type. I never used Delphi 3 so I guess that was the reason I didn't understand you in the first place -
"Comp" never heard of that creature  ::)

I'll keep checking on other plugins and let you guys know.

Thanks again  :D

Philip

Philip Hadar

  • Posts: 79
Re:Sonique Visualization
« Reply #37 on: 6 Jan '04 - 16:13 »
Ok, after a long run checking, there is no way I can catch the problem. ChaosWave.svp is in deed the worth of all, but I still get error messages with other plugins. For example I get an AV when I tried to call BASS_StreamFree.

Any ideas ?  ???

Irrational86

  • Posts: 960
Re:Sonique Visualization
« Reply #38 on: 6 Jan '04 - 21:09 »
Where does the AV say it comes from?
After calling BASS_StreamFree, do you keep calling the render function?

I just tried with lots of plugins here, and nothing happened, i will send you an update to try

Philip Hadar

  • Posts: 79
Re:Sonique Visualization
« Reply #39 on: 6 Jan '04 - 21:26 »
Hi,

Thanks for the update, I still get exceptions.
I could manage to trace it, its when I call BASS_ChannelBytes2Seconds to set my progress thumb position.

Still working on it... I'll get to it - just a question of time  :P

Philip Hadar

  • Posts: 79
Re:Sonique Visualization
« Reply #40 on: 6 Jan '04 - 21:41 »
Ok the problem is when I trunc the Int64 result to an
integer - what the hell is the matter...

Irrational86

  • Posts: 960
Re:Sonique Visualization
« Reply #41 on: 6 Jan '04 - 22:56 »
Well...int64 is way bigger than integer, so maybe the value the int64 has is larger than the range integer supports and therefore giving you an error

Philip Hadar

  • Posts: 79
Re:Sonique Visualization
« Reply #42 on: 6 Jan '04 - 23:16 »
No, the problem is with the Trunc function and your Dll  :-\

Even calling Trunc(10.5), which is in the range of a signed 32-bit, will result in an exception.

So.... I came up with a solution that seems to work so far
until the next catch  ::)

I rewrote the original Trunc function in the system unit and I change the cwChop operand to $133F. I called it TruncX

Here the code:

    function TruncX(x : Extended) : Int64; register;
    asm
    SUB ESP,12
    FSTCW [ESP]
    FLDCW cwChop
    FLD x
    FISTP qword ptr [ESP+4]
    FLDCW [ESP]
    POP ECX
    POP EAX
    POP EDX

    end;
« Last Edit: 6 Jan '04 - 23:17 by Philip Hadar »

DanaPaul

  • Posts: 335
Re:Sonique Visualization
« Reply #43 on: 6 Jan '04 - 23:35 »
Ok the problem is when I trunc the Int64 result to an
integer - what the hell is the matter...

Int64 is not a FloatingPoint integer.  Due to the bit format of a FloatingPoint integer most Int64 values (that are typecast as Float) will result in a Not-A-Number (NAN) Floating Point Exception.  You would need to transfer these values...

Value {Int64} := Trunc(Float) {Extended, Double, Single, etc}

Incidently, "Round" executes quicker than "Trunc".

Nice touch with the ASM routine.  Man after my own heart ;)

For what it's worth, Delphi versions 3 and earlier didn't have an Int64 type, so library functions that return a 64 bit result always had gibberish the upper 32 bits because the compiler ignored the EDX return register....

function MyBassGetPosition(yada): Int64;
  begin
    Bass_GetPosition... (yada yada)
    asm
      mov  [Result].DWORD, EAX
      mov  [Result + 4].DWORD, EDX
      end;
    end;



Philip Hadar

  • Posts: 79
Re:Sonique Visualization
« Reply #44 on: 7 Jan '04 - 02:20 »
Btw, did you try to convert a wma to wav ?

DanaPaul

  • Posts: 335
Re:Sonique Visualization
« Reply #45 on: 7 Jan '04 - 03:02 »
Btw, did you try to convert a wma to wav ?

Huh?  Me? No.

Generally I shy away from MS formats because of constant changes and portability.

Ogg Vorbis! ;)

Philip Hadar

  • Posts: 79
Re:Sonique Visualization
« Reply #46 on: 7 Jan '04 - 03:08 »
I took a look at the writewav example but I came up with a 165 mb file  >:( on a 3:41 mn length
and people will tell that size doen't count  ;D

DanaPaul

  • Posts: 335
Re:Sonique Visualization
« Reply #47 on: 7 Jan '04 - 03:21 »
I'll give it a quick glance in post a reply in your other thread ;)

Svante

  • Posts: 296
Re:Sonique Visualization
« Reply #48 on: 7 Jan '04 - 12:03 »

DanaPaul

  • Posts: 335
Re:Sonique Visualization
« Reply #49 on: 9 Jan '04 - 19:15 »
I rewrote the original Trunc function in the system unit and I change the cwChop operand to $133F. I called it TruncX

Not to beat a dead horse, but I noticed in one of your other posts that you are still using this custom TrunX function.

You can test (Float) Single Floating Point values for Not-A-Number (NAN) conditions before accessing these values as a Floating Point integer, (passing the value to the Floating Point Processor) as follows...

//returns true if s is Infinity, NAN or Indeterminate
//4byte IEEE:
//msb[31] = signbit,
//bits[23-30] exponent,
//bits[0..22] mantissa
//exponent of all 1s = Infinity, NAN or Indeterminate
function InvalidFloat (Value: Single): boolean;
  const
    Junk = 255 shl 23;
  var
    Overlay: LongInt ABSOLUTE Value;
  begin
    if ((Overlay and Junk ) = Junk ) then
      RESULT := true
    else RESULT := false;
    end;

Keep in mind that an ordinary integer with a value of -1 has all bits set.
« Last Edit: 10 Jan '04 - 01:17 by DanaPaul »