• Welcome to Theos PowerBasic Museum 2017.

BassBox

Started by Patrice Terrier, October 08, 2007, 10:57:44 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Petr Schreiber

Hi Charles,

last version of Soundscape works at 66FPS in window, 36FPS in "fullscreen". Both situations result in nice, smooth animation on my system.
One idea - the mountains created according to sound are visible too late, maybe whole plane could be moved "deeper in screen" ?


Thanks,
Petr
AMD Sempron 3400+ | 1GB RAM @ 533MHz | GeForce 6200 / GeForce 9500GT | 32bit Windows XP SP3

psch.thinbasic.com

Patrice Terrier

--Charles

I still have sound distortion with Soundscape, especialy when there are high peak levels.

Quotethe mountains created according to sound are visible too late, maybe whole plane could be moved "deeper in screen" ?
Yes that would be nice if the representation could be more accurate.
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Patrice Terrier

#362
This is a new plugin I did for the fun, it could be used for advertising  :)

Try it with the "popcorn" audio file, and try to figure the effects being used without looking first at the source code.


You can also try it with this file:
http://www.zapsolution.com/BassBox/La_isla_bonita.ogg

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Patrice Terrier

Here is another one to play with "ShowRoom"

http://www.zapsolution.com/BassBox/Madonna_feat_abba.ogg

See how close the animation is to the sound, and the beautiful lighting effects.

Perhaps this could be sold to a night-club  ;D
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Kent Sarikaya

Hmmmm.... this was strange.

I first installed Charles's update to soundscape. I ran BassBox and still got really bad flickering... in fact so bad, that after I was looking at if for over a minute, when I shut down bassbox, I could still see flickering  on the screen till my eyes sort of came back to normal.

I then installed Patrice's new plugin showroom and all played fine, including of course soundscape. So I can't figure that out.

About ShowRoom, wow it is neat how it reacts to different songs dramatically with colors and more objects being rendered. It does have the feel of its name!

Charles Pegge

RE: Soundscape

I think it is a combination of polygon count, textures and screen pixel count that causes the instability. I notice that most of the boys' video games only run in full screen mode and the pixel count is max 800*600 even on a 1600x1050 screen.

I wonder if there is a simple way of measuring whether the system is being overburdened by the scene rendering code. It could be along the lines of restricting frame rendering time to 10-20% of the frame interval using QueryPerformanceCounter.  Limiting the viewport size if the load is too high.

Terraforming which occurs at the front of the landscape, has to be done out of view, hence the delay between the music and the shape of the terrain as it first appears. This can be improved to a limited extent.


Petr Schreiber

Charles,

for benchmarking and catching bottlenecks, gDebugger is very nice tool.
There is available 30 days trial - it is really worth installing: http://www.gremedy.com/download.php
See screenshots here: http://www.gremedy.com/screenshots.php

It displays how much is CPU and GPU under "load", how much GL commands per frame ... really nice.

On my PC, although with low end card, I still can't experience any troubles with soundscape.
I have latest ForceWare drivers available for my NVIDIA.


Bye,
Petr
AMD Sempron 3400+ | 1GB RAM @ 533MHz | GeForce 6200 / GeForce 9500GT | 32bit Windows XP SP3

psch.thinbasic.com

Charles Pegge


Thank you Petr, that looks a very sophisticated tool. I am going to try to introduce some adaptive behaviour into the plugins - it will enable restriction of  polygons, viewport size etc in response to distressed hardware, and generate performance data when the plugin is terminated. There are so many hardware configurations out there as well as different OSes and driver versions.

It will also be possible to emulate low performing hardware by restricting the proportion of time allocated to scene rendering.


Petr Schreiber

#368
Charles,

there must be something else causing the problem - Kent has current 3D card one generation newer than mine. I am sure it is some GL problem, some double glEnd or something.

Regarding on the fly optimizations, here is a story from my experience, to entertain or scare you :)

Looong time ago, when my newest PB was version 6 for windows, I was working on a 3D adventure game. As my friends had a bit werid PCs ( one had no 3D card, the second had Voodoo but without OpenGL HW support ), I introduced optimizations to the engine, which did following in realtime:

  • changing view distance
  • changing viewport size

But as it was very unmature, based only on current FPS, it resulted very often in quite funny artifacts, please see attached images.
Whatever was the resolution, viewport size quickly started to get smaller and smaller, and the draw distance cut the important details of the scene in most cases ;D.


Bye,
Petr

P.S. First image is lorry with dead body inside - in the background there was city, which got all cut by draw distance, second image is dead body ( ok just sleeping :) ) in wardrobe, where for change almost whole forrest got cut. Last screen was some library interior, only one which was not punished by my "amazing" optimizations.
AMD Sempron 3400+ | 1GB RAM @ 533MHz | GeForce 6200 / GeForce 9500GT | 32bit Windows XP SP3

psch.thinbasic.com

Petr Schreiber

#369
Charles,

I used GLIntercept on BassBox, and for Soundscape got following:
Quote
GL ERROR - Function glCallList generated error GL_INVALID_OPERATION
Quote
glCallList(5) Textures[ (0,9) ]  glGetError() =GL_INVALID_OPERATION

When I comment out contents of glNewList 5 ... glEndList, program does no longer cause invalid operation!
I cannot see any glGenLists or glDeleteLists in your code, which could be a reason too.

I am sure once this will get solved, no further optimizations will be needed. Driver just got sad from the GL_INVALID_OPERATION in case of Kent's PC, and this is probably the reason for flicker or any other unwanted behaviour.

For BassBox alone ( start and close ) I get following:
Quote
DisplayListManager::RemoveData - Attempting to delete unknown DisplayList ID 0
DisplayListManager::RemoveData - Attempting to delete unknown DisplayList ID 0
DisplayListManager::RemoveData - Attempting to delete unknown DisplayList ID 1
DisplayListManager::RemoveData - Attempting to delete unknown DisplayList ID 2
DisplayListManager::RemoveData - Attempting to delete unknown DisplayList ID 3
DisplayListManager::RemoveData - Attempting to delete unknown DisplayList ID 4
DisplayListManager::RemoveData - Attempting to delete unknown DisplayList ID 5
DisplayListManager::RemoveData - Attempting to delete unknown DisplayList ID 6
DisplayListManager::RemoveData - Attempting to delete unknown DisplayList ID 7
DisplayListManager::RemoveData - Attempting to delete unknown DisplayList ID 8
DisplayListManager::RemoveData - Attempting to delete unknown DisplayList ID 9
DisplayListManager::RemoveData - Attempting to delete unknown DisplayList ID 0
DisplayListManager::RemoveData - Attempting to delete unknown DisplayList ID 1
DisplayListManager::RemoveData - Attempting to delete unknown DisplayList ID 2
DisplayListManager::RemoveData - Attempting to delete unknown DisplayList ID 3
DisplayListManager::RemoveData - Attempting to delete unknown DisplayList ID 4
DisplayListManager::RemoveData - Attempting to delete unknown DisplayList ID 5
DisplayListManager::RemoveData - Attempting to delete unknown DisplayList ID 6
DisplayListManager::RemoveData - Attempting to delete unknown DisplayList ID 7
DisplayListManager::RemoveData - Attempting to delete unknown DisplayList ID 8
DisplayListManager::RemoveData - Attempting to delete unknown DisplayList ID 9
ImageManager::Destructor - OpenGL id 1 is still active. (Image Memory leak?)
ImageManager::Destructor - OpenGL id 2 is still active. (Image Memory leak?)
ImageManager::Destructor - OpenGL id 3 is still active. (Image Memory leak?)

This might be false alarm as well as some real problem too.


Hope it helps,
Petr
AMD Sempron 3400+ | 1GB RAM @ 533MHz | GeForce 6200 / GeForce 9500GT | 32bit Windows XP SP3

psch.thinbasic.com

Patrice Terrier

BassBox has been updated to version 1.24.

The distribution package now contains two more plugins with their corresponding textures.
1 - LightShow
2 - ShowRoom (this version is sligthy different from the previous one)

See the first post of this thread to download the latest zip file.

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Kent Sarikaya

Thanks, all the plugins are playing just fine now. I just used the default bassbox screen size on start to go through all of them and all is great!

Very nice range of visuals and nice changes too. Thanks guys!

Charles Pegge


Thanks Petr, that is very helpful. I will use glGetError as part of the code development procedure.
Taking it line by line, it should be very sensitive to any dud gl instructions.

I can see that the Soundscape  code could benefit from glDeleteLists to clean up at the end but no need for glGenLists since old lists are automatically overwritten.

Apart from limiting distant polygons, I think I have found a way to further optimise GPU processing: writing opaque objects, from near to distant. (Translucents always have to be writen from distant to near). Occluded fragments are not processed any further after the depth test.

Plugins do not have control over the viewport, so I will reserve that along with any special pleading to Patrice as a last resort. :)

Charles Pegge

#373
Kent,

This is my current rough 'n ready version of Soundscape adapted to use FreeImage instead of GDIplus.

You will need to drop FreeImage.DLL into the BassBox main folder if you dont have it in System32.

The code interest to you will be the TexImage function - I have left in all the GDI stuff - not too confusing I hope. The GetPixelColor prototype has been tweaked to receive a LONG instead of RGBquad - its simpler to handle.

I found 3 major differences.

1 FreeImage needs to know what type of image it is loading explicitly (2 for jpeg 13 for png).
2 No need to flip the image vertically.
3 Alpha must be set to opaque (255) for jpeg (GDIplus did it automatically for you).

The filename is given in plain 8 bit Asciiz.



GLOBAL pixmap() AS STRING
GLOBAL texture() AS LONG


' ========================================================================================
' DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Load(FREE_IMAGE_FORMAT fif, const char *filename,
' int flags FI_DEFAULT(0));
' ========================================================================================
DECLARE FUNCTION FreeImage_Load _
   LIB "FreeImage.dll" ALIAS "_FreeImage_Load@12" ( _
   BYVAL LONG, _                       ' FREE_IMAGE_FORMAT fif
   BYREF ASCIIZ, _                     ' const char *filename
   OPTIONAL BYVAL LONG _               ' int flags FI_DEFAULT(0)
   ) AS DWORD                          ' FIBITMAP *
' ========================================================================================


' ========================================================================================
' DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Rescale(FIBITMAP *dib, int dst_width,
' int dst_height, FREE_IMAGE_FILTER filter);
' ========================================================================================
DECLARE FUNCTION FreeImage_Rescale _
   LIB "FreeImage.dll" ALIAS "_FreeImage_Rescale@16" ( _
   BYVAL DWORD, _                      ' FIBITMAP *dib
   BYVAL LONG, _                       ' int dst_width
   BYVAL LONG, _                       ' int dst_height
   BYVAL LONG _                        ' FREE_IMAGE_FILTER filter
   ) AS DWORD                          ' FIBITMAP *
' ========================================================================================

' ========================================================================================
' DLL_API BOOL DLL_CALLCONV FreeImage_FlipVertical(FIBITMAP *dib);
' ========================================================================================
DECLARE FUNCTION FreeImage_FlipVertical _
   LIB "FreeImage.dll" ALIAS "_FreeImage_FlipVertical@4" ( _
   BYVAL DWORD _                       ' FIBITMAP *dib
   ) AS LONG                           ' BOOL
' ========================================================================================


' ========================================================================================
' DLL_API BOOL DLL_CALLCONV FreeImage_GetPixelColor(FIBITMAP *dib, unsigned x, unsigned y,
' RGBQUAD *value);
' ========================================================================================
DECLARE FUNCTION FreeImage_GetPixelColor _
   LIB "FreeImage.dll" ALIAS "_FreeImage_GetPixelColor@16" ( _
   BYVAL DWORD, _                      ' FIBITMAP *dib
   BYVAL DWORD, _                      ' unsigned x
   BYVAL DWORD, _                      ' unsigned y
   BYREF LONG _                     ' RGBQUAD *value
   ) AS LONG                           ' BOOL
' ========================================================================================


' ========================================================================================
' DLL_API void DLL_CALLCONV FreeImage_Unload(FIBITMAP *dib);
' ========================================================================================
DECLARE SUB FreeImage_Unload _
   LIB "FreeImage.dll" ALIAS "_FreeImage_Unload@4" ( _
   BYVAL DWORD _                       ' FIBITMAP *dib
   )                                   ' void
' ========================================================================================


SUB TexImage (img AS STRING, ref AS LONG, p AS LONG )
   #REGISTER NONE
   'LOCAL hStatus AS LONG
   'LOCAL pBitmap AS LONG
   'LOCAL pThumb  AS LONG
   'LOCAL strFileName AS STRING
   'strFileName = UCODE$(img)
   LOCAL zFileName AS ASCIIZ*128
   zFileName=img
   pixmap(ref)=NUL$(4*256*256) ' GLOBAL pixmap()
   
   'hStatus = GdipLoadImageFromFile(strFileName, pBitmap)
   'hStatus = GdipGetImageThumbnail ( pBitMap, 256, 256, pThumb, 0, 0 )
   'hStatus = GdipImageRotateFlip(pThumb,%RotateNoneFlipY) 'invert
   LOCAL h,t AS LONG
    h=FreeImage_Load (2,zFileName,0) ' -1 unkn 2 jpeg 13 png
    t=FreeImage_Rescale (h,256,256,0)
    'FreeImage_FlipVertical t ' No need to flip with FreeImage
   DIM w AS LONG PTR
   p=STRPTR(pixmap(ref))
   w=p
   'DIM x AS LONG, y AS LONG
   LOCAL x,y,pf AS LONG
   FOR y=0 TO 255
    FOR x=0 TO 255
     'GdipBitmapGetPixel pThumb, x, y, @w
     FreeImage_GetPixelColor t,x,y,@w
     ' RED BLUE SWAP FOR OPENGL
     ! mov edx,w
     ! mov al,[edx]
     ! xchg al,[edx+2]
     ! mov [edx],al
     ! mov byte ptr [edx+3],255 ' with FREEIMAGE we must set jpeg alpha
     ! add dword ptr w,4
    NEXT
   NEXT
   'IF pBitmap THEN GdipDisposeImage(pBitmap)
   'IF pThumb  THEN GdipDisposeImage(pThumb)
    FreeImage_Unload h
   FreeImage_Unload t
   DIM pp AS BYTE PTR
   pp=p
   glBindTexture GL_TEXTURE_2D, texture(ref) ' GLOBAL texture()
   glTexParameterf GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR
   glTexParameterf GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR
   '             target      level components width height  border format   datatype      ptr to image data
   glTexImage2D GL_TEXTURE_2D, 0,      4, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, @pp
END SUB



Kent Sarikaya

#374
Thanks Charles. Will have a study period with it now, thanks again!

I was searching on the freeimage forums and apparently none of the developers for freeimage are familiar with OpenGL, I sort of found that odd and hence no examples for using their library for textures in 3D apps, although they list it in the features area.