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

Charles Pegge

Thanks Patrice!
It looks especially good with slow jazz.

Petr Schreiber

#16
Hi,

first visualisation alternative preview is here :)
It should run on older PCs as well, as it does not use textures and very thin geometry is drawn - just lines.

Put your current RenderOpenGL sub in #IF 0 / #ENDIF and use this instead:

DECLARE SUB glPushMatrix LIB "OPENGL32.DLL" ALIAS "glPushMatrix" ()
DECLARE SUB glPopMatrix LIB "OPENGL32.DLL" ALIAS "glPopMatrix" ()
DECLARE SUB glTranslated LIB "OPENGL32.DLL" ALIAS "glTranslated" ( BYVAL DOUBLE, BYVAL DOUBLE, BYVAL DOUBLE )

%GL_LINES                          = &H0001???
  SUB RenderElement( BYVAL x AS DOUBLE, BYVAL y AS DOUBLE, BYVAL z AS DOUBLE, r1 AS BYTE, g1 AS BYTE, b1 AS BYTE, r2 AS BYTE, g2 AS BYTE, b2 AS BYTE )

    glBegin %GL_LINES

      glColor3ub r1, g1, b1
      glVertex3d  x, -y, -z
      glColor3ub r2, g2, b2
      glVertex3d  x, -y,  z

      glColor3ub r1, g1, b1
      glVertex3d  x, -y, -z
      glColor3ub r2, g2, b2
      glVertex3d  x, -y,  z

    glEnd

  END SUB

  TYPE tColorBox
    length AS DOUBLE
    r1 AS BYTE
    g1 AS BYTE
    b1 AS BYTE
    r2 AS BYTE
    g2 AS BYTE
    b2 AS BYTE
  END TYPE

SUB RenderOpenGL(BYVAL glCtrl AS LONG)
    LOCAL OkL, OkR, C, K, nLevel, nLpeak, nRpeak, nLValue, nRValue, glDC, hDC, nCell, CellW, CellH, x, y, RGBColor AS LONG
    LOCAL pulse AS DOUBLE, R1, G1, B1, R2, G2, B2 AS BYTE
    STATIC rXangle, rYangle, rZangle AS DOUBLE
    STATIC LastTime AS DOUBLE
    DIM PulseMemory(0 TO 128) AS STATIC tColorBox
    LOCAL PulseMemorySample AS tColorBox

    LOCAL rc AS RECT

    glDC = GetDC(glCtrl)

    IF glRC THEN

       nLevel = BassChannelGetLevel()

       nLpeak = SolvePeak(LO(WORD, nLevel), 128)
       nRpeak = SolvePeak(HI(WORD, nLevel), 128)

       nLValue = (nLpeak / 700)
       nRValue = (nRpeak / 768)

       rXangle = rXangle + 0.3 '// grDXangle
       rYangle = rYangle + 0.5 '// grDYangle
       rZangle = rZangle + 0.7 '// grDZangle

       pulse = MAX(nLValue, nRValue) / 7

       '// Pulsating section
       CALL glMatrixMode(%GL_PROJECTION)
       CALL glLoadIdentity()
       CALL gluPerspective(35.0 - pulse, 1.25, 0.1, 150.0)

       CALL glMatrixMode(%GL_MODELVIEW)
       '// Velocity section
       pulse = ABS(pulse / 4)
       rXangle = rXangle + pulse '// grDXangle
       rYangle = rYangle + pulse '// grDYangle
       rZangle = rZangle + pulse '// grDZangle

       '// Very important we must reassign glRC to the new glDC
       '// Note: don't use permanent DC, this produce better and smoother display
       CALL wglMakeCurrent(glDC, glRC)

       CALL glClear(%GL_COLOR_BUFFER_BIT OR %GL_DEPTH_BUFFER_BIT)
       CALL glLoadIdentity()
       CALL gluLookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0)

       '// Draw Visualistation
       RGBColor = LevelColr(nLValue)
       R2 = zGetRValue(RGBColor)
       G2 = zGetGValue(RGBColor)
       B2 = zGetBValue(RGBColor)

       RGBColor = LevelColr(nRValue)
       R1 = zGetRValue(RGBColor)
       G1 = zGetGValue(RGBColor)
       B1 = zGetBValue(RGBColor)

       PulseMemorySample.r1 = r1
       PulseMemorySample.g1 = g1
       PulseMemorySample.b1 = b1
       PulseMemorySample.r2 = r2
       PulseMemorySample.g2 = g2
       PulseMemorySample.b2 = b2
       PulseMemorySample.length = pulse
       
       IF TIMER - LastTime > 0.02 THEN ' Not more frequent than 50 Hz
         ARRAY INSERT PulseMemory(LBOUND(PulseMemory)), PulseMemorySample
         LastTime = TIMER
       END IF
       
       LOCAL i AS LONG

      FOR i = LBOUND(PulseMemory) TO UBOUND(PulseMemory)

          glPushMatrix
            glTranslated 0, 0, -i/10
            glRotated i*3,0,0,1

            RenderElement(0.25*(1+pulse), PulseMemory(i).length, PulseMemory(i).length, PulseMemory(i).r1, PulseMemory(i).g1, PulseMemory(i).b1, PulseMemory(i).r2, PulseMemory(i).g2, PulseMemory(i).b2 )

          glPopMatrix

          glPushMatrix
            glTranslated 0, 0, -i/10
            glRotated -i*3,0,0,1

            RenderElement(0.125, PulseMemory(i).length, PulseMemory(i).length, PulseMemory(i).r1, PulseMemory(i).g1, PulseMemory(i).b1, PulseMemory(i).r2, PulseMemory(i).g2, PulseMemory(i).b2 )

          glPopMatrix

      NEXT i

       '// Refresh display
       CALL SwapBuffers(glDC)
       CALL zUpdateWindow(glCtrl, 0)

'      //Start drawing the ViewMeter's LED directly onto the main window DC
     ' Compute both channel colors
       OkL = 0: OkR = 0
       nLpeak = nLpeak \ 320: nRpeak = nRpeak \ 320
       FOR K = 1 TO 100
           IF K <= nLpeak THEN
              C = K \ 3: gPeak(K,1) = gColor(C)
           ELSE
              IF gPeak(K,1) AND OkL& = 0 THEN
                 gPeak(K,1) = SetRGB(gPeak(K,1)): IF OkL = 0 AND gPeak(K,1) = 0 THEN OkL = K
              ELSE
                 gPeak(K,1) = 0
              END IF
           END IF
           IF K <= nRpeak THEN
              C = K \ 3: gPeak(K,2) = gColor(C)
           ELSE
              IF gPeak(K,2) AND OkR& = 0 THEN
                 gPeak(K,2) = SetRGB(gPeak(K,2)): IF OkR = 0 AND gPeak(K,2) = 0 THEN OkR = K
              ELSE
                 gPeak(K,2) = 0
              END IF
           END IF
       NEXT
     ' Draw both channels directly onto main window DC
       hDC = GetDC(zMainWindow(0))
       CALL GetClientRect(zMainWindow(0), rc)
       nCell = 13: CellH = 3: CellW = 32: x = rc.nRight - 137: Y = 54
       FOR K = nCell TO 1 STEP -1
           C = SolvePeak(K, nCell)
           CALL zPaintBrushBitmap(hDC, x, y, CellW, CellH, zColorARGB(220, gPeak(C,1)))
           CALL zPaintBrushBitmap(hDC, x + CellW + CellH , y, CellW, CellH, zColorARGB(220, gPeak(C,2)))
           y = y + CellH + 1
       NEXT
       CALL ReleaseDC(zMainWindow(0), hDC)
'      // End ViewMeter section

      CALL zSetTrackValue(zGetMainItem(%ID_TRACK_SEARCH), BassChannelGetPos())

    END IF
    CALL ReleaseDC(glCtrl, glDC)
END SUB


Best with faster, louder, overdrummed music :)


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

psch.thinbasic.com

Kent Sarikaya

Fun to see the new additions coming. Thanks for the new file support Patrice and of course scrub bar for the song!

Petr, that is a nice new visualization you came up with. It does work good with something with a strong beat, Cool stuff!!

Charles Pegge

Here's Another.

It's a modified BassBox.bas called BassBoxPoly, and a folder called ray.
To try them out, drop them into the bassbox_02 folder and compile BassBoxPoly.

The next step might be to set up some modulated lighting.

Petr Schreiber

Charles,

I knew your favourite geometry cannot miss :)
Looks really nice ! I like idea of constant color contours + changing areas.

I was playing with similar idea ( two "naked" orange (fruit) objects ), but I ended with lines I posted.

It would be nice if this visualisations could be each in one DLL, and user could pick one he likes.


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

psch.thinbasic.com

Patrice Terrier

Thank you very much both of you!

I am working on the BassBox visual section to let the user easily switch from one pluggin to another.

Keep them coming ;)

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

scott Stirling

Hi patrice

Amazing examples ;)

it seems though i have a problems running your BassBox demo with vista home premium (no problems with xp pro sp2),
1, the main problem is your spinning cube visual appears twice,
the one that appears outside the main window runs perfectly smooth
and is positioned in the top left corner of my screen and over laps the main window visual in the top left corner of the demo,
also the visual in the main demo window doesn't run smooth(stops every few seconds then starts again)
2, also, when i minimize the main window my mouse pointer flashes erratically and tooltips from other apps do the same (including the taskbar)

sorry if it helps i am running vista on a laptop with onboard graphics,
CPU:  core duo T2080 1.73ghz
RAM: 1024mb
GFX:  ?? Intel 943gml(calistoga) + ICH7 - M with up to 128mb shared memory supports GMA 950 ??
with a screen resolution of 1400-900

sorry i cant give any pointers, (been a while since i coded)

keep up the amazing work  ;D









Patrice Terrier

#22
I have added a plugin section into BassBox and radio buttons to select the visual effect:




zskin.inc has been enhanced with zRadioButton control.


The plugin section looks like this:

'      The visual plugin section
       SELECT CASE LONG gnUseVisualEffect
           CASE 1: CALL Render1 (glDC, glRC, nLpeak, nRpeak)
           CASE 2: CALL Render2 (glDC, glRC, nLpeak, nRpeak)
           CASE 2: CALL Render3 (glDC, glRC, nLpeak, nRpeak)
           etc.
       END SELECT

Charles,
it would be nice if ALL the plugin code could fit within a RenderX procedure.
Instead of the dedicated BassBoxPoly file  ;)

...


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

Patrice Terrier

#23
Scott,

Better to use VISTA with 2048 Mb and a true graphic card, 
shared memory is a NoNo with OpenGL ...

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

scott Stirling

#24
thanks patrice,

sort of guessed it would be a GFX problem my end,
and as soon as you post a reply you post another example including extra visuals :)
as i write this i have already hit the power button on my xp system so i can see it in action,
keep up the amazing work ;)

ps thanks for the tips been looking into express gfx cards and audio cards and the memory is on its way
thanks again

Charles Pegge

Patrice, do have a place where Opengl objects can be initialised, before running the render frames?

I inserted a #include and also a call to my gllist code in your InitOpenGL function. Is that the best place to call it or do you want to use another location to initialise the plugins?

Patrice Terrier

Charles

Perhaps the good place could be in the procedure RenderOpenGL like this:

SELECT CASE LONG gnUseVisualEffect
    CASE 1
            CALL InitTHERE
            CALL Render1(glDC, glRC, nLpeak, nRpeak)
    CASE 2
            CALL InitTHERE
            CALL Render2(glDC, glRC, nLpeak, nRpeak)
etc.

And remember that the USER must be able to switch from one visual pluging to another at anytime.

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

Petr Schreiber

#27
Hi,

first I am angry to see Intels make some problems :( If the same Intel works under XPs and not under Vista than it is weird.
I have Intel powered notebook at home so I can test at least on XP soon.

Regarding visualisation - I like new update with choice of them !

Just one idea I of course steal from somebody else :) - thinBASIC is designed very nicely to be enhanced using modules - you just need to keep name of DLLs in one format + use special ( but very easy to use ) SDK.

If we could create "visualisation" SDK, all could be contented. Charles could initialize as he needs, and visualisation would be loaded dynamicaly, just looking after "BASSBoxVisualisation_<namehere>.DLL" in Visualisations or Plugins directory.

But current way works nice too, but it is less open.
I know it is lot of work to invent quality SDK, but in this case just few parameters could be exchanged.


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

psch.thinbasic.com

Charles Pegge


Patrice,

Yes that will work. All we need is a static counter for allocating gllist numbers for different Opengl compiled objects, since these need to be persistent between frames, but each Plugin might require their own set of objects. Rather like issuing file handles.

Global Globjectcount as long

' only one function call per plugin would be required:
...

Static myGlobject as long
if myGlobject=0 then
 Incr GlobjectCount
 myGlobject=GlobjectCount
 initialise ...
end if
... renderiing frame


Petr,

The ultimate plugin would be the ability to drop DLLs into a folder and have them automatically recognised by Bassbox.


Patrice Terrier

#29
Have you seen this?

ZAP Visual Plugin

Note: the 10-band equalizer is high on my todo list for BassBox  8)
...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com