• Welcome to Theos PowerBasic Museum 2017.

News:

Attachments are only available to registered users.
Please register using your full, real name.

Main Menu

BassBox

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

Previous topic - Next topic

0 Members and 5 Guests are viewing this topic.

Patrice Terrier

See the section entitled "BassBox 2011" for the latest version 2.58.

...

Audio player based on BASS.DLL (aif, mp1, mp2, mp3, ogg, wav, wma) + 
OpenGL +
Exclusive skin design +
DirectX audio effects +
Drag & drop +
Dedicated Visual plugins +
Blur and Crystal AERO mode on VISTA+
SoundTracker audio modules +
CD-Audio


Note: This is the OLD version, you must >>>click here<<< to get the NEW one.

However you can read this thread, if you want to know the BassBox genesis...


History:
Dec 14, 2008 Added new Flashback plugin.
Jul 27, 2008  Enhanced to use the latest Skin Engine.
Apr 09, 2008  Last plugin being used is saved/retrieved between sessions.
Apr 06, 2008  Upgraded to work with Bass.dll version 2.4.
Dec 24, 2007  New plugin + media length.
Dec 23, 2007  Oscilloscope doesn't require anymore a multiplex audio card.
Dec 21, 2007  Added real time oscilloscope.
Dec 16, 2007  Unlimited number of visual plugins.
Dec 15, 2007  CD-Audio support.
Dec 09, 2007  New plugin with BassBox logo.
Nov 22, 2007  New plugins + the visual.dll can use any name.
Nov 17, 2007  Plugin's self detection.
Nov 16, 2007  Plugin's multi-texture support.
Nov 12, 2007  Start of this help file.
Nov 06, 2007  New visual plugin: "Sonic Circle".
Nov 04, 2007  Music Tracker support: it, xm, s3m, mtm, mod, umx, mo3.
Nov 03, 2007  Keyboard support for visual plugins.
Nov 03, 2007  New visual plugin: "Laser Borealis".
Nov 02, 2007  NET audio streaming capture, saved to the "NetCapture\" folder.
Nov 01, 2007  BBP playlist + URL audio streaming.
Oct 31, 2007  Audio FFT and mouse support for visual plugins.
Oct 30, 2007  Built-in plugin support for 32-bit ABGR OpenGL texture.
Oct 29, 2007  New visual plugin; "Fireworks".
Oct 26, 2007  Complete folder drag an drop allowed on the BassBox desktop icon.
Oct 25, 2007  New buttons to change the player's background.
Oct 24, 2007  New visual plugin: "PolyHedra".
Oct 23, 2007  PLUGIN format definition.
Oct 21, 2007  Drag and drop of single or embedded folders.
Oct 18, 2007  Player's image background support.
Oct 16, 2007  WMA audio support.
Oct 14, 2007  ID3 TAG support.
Oct 13, 2007  10-band equalizer.
Oct 12, 2007  New visual plugins: "Mikado" and "Stick Dance".
Oct 11, 2007  Search trackbar + audio format: ogg, wav, aif.
Oct 10, 2007  Stereo channel view metter with vanishing LEDs.



To make the things clear about the BassBox status:

This is a "participative project" (french definition: "projet participatif"), it means you can contribute with new plugins, new themes, code enhancements, documentations, feedback. And all contributions must be posted there for the benefit of the members of this forum.

Things that you are not allowed to do:
Change the name of the project, change the logo without prior agreement, alter a theme without prior agreement, produce any derivated audio player from this project.
And of course do not change or alter the copyright.


Vous trouverez des informations détaillées sur BassBox en français ici.

...

Patrice Terrier
www.zapsolution.com

Previously loaded 153 times.
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Patrice Terrier

#1
BassBox insight

You will find under this post the latest patch: bassbox_01.zip that is provided without any mp3 file.
This patch introduces new features like "interprocess communication" (see below WM_COPYDATA)


  • Latest zskin.inc (skin engine source code compatible VISTA / XP)
  • New AudioFX (add audio effects to BASS.dll from Ian Luck).
  • BassBox.mp3 (royalty free mp3 for demo purpose).


Using BassBox


  • BassBox is an audio player compatible with 2000, XP, and VISTA.
  • You can start it from the command line, providing the name of one or several audio files.
  • It accepts an unlimited number of files, or folders, when using drag and drop from the Explorer.
  • You can also drag file(s), or folders, directly onto the BassBox desktop shortcut if any, but then you are limited to the maximum lpCommand length size (something around 6000 bytes).
  • Use left and right arrow buttons to navigate the audio list (when multiple audio files are being used).
  • The Play button, starts playing or resume from pause, the "Pause" button pauses audio.
  • The VOL trackbar allows to setup the "local" application's audio volume.
  • DirectSound audio effects: reverberation, chorus, flanger, echo, sound rotation.


BASS.DLL

All the details about this fantastic audio library, from Ian Luck, can be found there:
www.un4seen.com


WM_COPYDATA

This message is very handy when you need to perform "interprocess communication", zskin.inc has two new functions, zSendPrivateMsg and zGetPrivateMsg, for this purpose:


TYPE COPYDATASTRUCT
    dwData AS DWORD
    cbData AS DWORD
    lpData AS DWORD
END TYPE

%ZM_STRINGDATA = 0

FUNCTION zSendPrivateMsg(BYVAL hFound AS LONG, BYVAL UseMsg AS LONG, BYVAL sBuff AS STRING) AS LONG

    LOCAL cds AS COPYDATASTRUCT, LenBuff AS LONG

    LenBuff = LEN(sBuff)
    REDIM Buf(LenBuff) AS BYTE
    POKE$ VARPTR(Buf(0)), sBuff
    cds.dwData = UseMsg
    cds.cbData = UBOUND(Buf) - LBOUND(Buf) + 1
    cds.lpData = VARPTR(Buf(0))
    FUNCTION = SendMessage(hFound, %WM_COPYDATA, LenBuff, VARPTR(cds))

END FUNCTION

FUNCTION zGetPrivateMsg(BYREF sPrivateMsg AS STRING, BYVAL wParam AS LONG, BYVAL lParam AS LONG) AS LONG

    LOCAL cds AS COPYDATASTRUCT

    REDIM Buf(wParam) AS BYTE
    CALL MoveMemory(cds, BYVAL lParam, SIZEOF(cds))
    CALL MoveMemory(buf(0), BYVAL cds.lpData, cds.cbData)
    sPrivateMsg = PEEK$(VARPTR(buf(0)), wParam)
    FUNCTION = cds.dwData

END FUNCTION


and the WM_COPYDATA that must be handled into the main winproc:


    CASE %WM_COPYDATA
       ' wParam holds the string length
       ' lParam holds the Byte array address
         dwData = zGetPrivateMsg(sDataString, wParam, lParam)
         IF dwData = %ZM_STRINGDATA THEN
            IF LEN(sDataString) THEN
               nCount = PARSECOUNT(sDataString, $zLim)
               hList = zGetMainItem(%ID_PlayList)
               CALL ListDeleteAll(hList)
               FOR K = 1 TO nCount
                   ListAdd(hList, PARSE$(sDataString, $zLim, K))
               NEXT
               CALL ListSelectPlus(hList, 1)
               gzAudioFile = ListGetText(hList, 1)
               CALL BassChannelPlay()
               IF nCount > 1 THEN
                  CALL EnableWindow(zGetMainItem(%ID_LEFTBUTTON), %TRUE)
                  CALL zUpdateWindow(zGetMainItem(%ID_LEFTBUTTON), 0)
                  CALL EnableWindow(zGetMainItem(%ID_RIGHTBUTTON), %TRUE)
                  CALL zUpdateWindow(zGetMainItem(%ID_RIGHTBUTTON), 0)
               ELSE
                  CALL EnableWindow(zGetMainItem(%ID_LEFTBUTTON), %FALSE)
                  CALL zUpdateWindow(zGetMainItem(%ID_LEFTBUTTON), 0)
                  CALL EnableWindow(zGetMainItem(%ID_RIGHTBUTTON), %FALSE)
                  CALL zUpdateWindow(zGetMainItem(%ID_RIGHTBUTTON), 0)
               END IF
            END IF
         END IF
         FUNCTION = 1: EXIT FUNCTION




OpenGL

This demo uses OpenGL to render graphicaly the stereo audio levels, everything is embedded into the provided source code (no need to use a third party OpenGL addon).

If you try it with VISTA you will see absolutly no difference with DirectX, performances are the same despite what some people say over the NET.

All the hard stuff to decode the audio channel is done there:


'// Init the color array
SUB ColorInit()
    DIM gColor(1 TO 33) AS LONG
    gColor(1)  = RGB(32,32,32)
    gColor(2)  = RGB(0,44,233)
    gColor(3)  = RGB(0,67,210)
    gColor(4)  = RGB(0,89,187)
    gColor(5)  = RGB(0,112,164)
    gColor(6)  = RGB(0,135,142)
    gColor(7)  = RGB(0,159,117)
    gColor(8)  = RGB(0,183,88)
    gColor(9)  = RGB(0,207,58)
    gColor(10) = RGB(0,231,29)
    gColor(11) = RGB(26,234,26)
    gColor(12) = RGB(52,237,23)
    gColor(13) = RGB(79,240,20)
    gColor(14) = RGB(105,243,17)
    gColor(15) = RGB(126,245,14)
    gColor(16) = RGB(147,248,11)
    gColor(17) = RGB(168,250,8)
    gColor(18) = RGB(189,253,5)
    gColor(19) = RGB(210,255,2)
    gColor(20) = RGB(233,255,0)
    gColor(21) = RGB(255,255,0)
    gColor(22) = RGB(255,251,0)
    gColor(23) = RGB(255,235,0)
    gColor(24) = RGB(255,215,0)
    gColor(25) = RGB(255,196,0)
    gColor(26) = RGB(255,176,0)
    gColor(27) = RGB(255,156,0)
    gColor(28) = RGB(253,137,0)
    gColor(29) = RGB(255,117,0)
    gColor(30) = RGB(255,97,0)
    gColor(31) = RGB(255,78,0)
    gColor(32) = RGB(255,58,0)
    gColor(33) = RGB(255,0,0)
END SUB

FUNCTION LevelColr(BYVAL nLevel AS LONG) AS LONG
    LOCAL nColor AS LONG
    nLevel = nLevel + 1: IF nLevel > 33 THEN nLevel = 33
    nColor = 0: IF nLevel > 0 THEN nColor = gColor(nLevel)
    FUNCTION = nColor
END FUNCTION

FUNCTION SolvePeak(BYVAL nValue AS LONG, BYVAL nTotal AS LONG) AS LONG
    LOCAL nRet AS LONG
    nRet = 0: IF nTotal THEN nRet = (nValue * 100) / nTotal
    FUNCTION = nRet
END FUNCTION

FUNCTION BassChannelGetLevel () AS LONG
    LOCAl nRet AS LONG
    IF gnAudioPause = %FALSE THEN
       IF gnAudioChannel THEN
          nRet = BASS_ChannelGetLevel(gnAudioChannel)
       END IF
    END IF
    FUNCTION = nRet
END FUNCTION


and the OpenGL drawing is done there:


SUB RenderOpenGL(BYVAL glCtrl AS LONG)
    LOCAL nLevel, nLValue, nRValue, glDC, RGBColor AS LONG
    LOCAL pulse AS DOUBLE, R1, G1, B1, R2, G2, B2 AS BYTE
    STATIC rXangle, rYangle, rZangle AS DOUBLE

    glDC = GetDC(glCtrl)

    IF glRC THEN

       nLevel = BassChannelGetLevel()
       nLValue = (SolvePeak(LO(WORD, nLevel), 128) / 700)
       nRValue = (SolvePeak(HI(WORD, nLevel), 128) / 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)
       CALL glRotated(rXangle, 1.0, 0.0, 0.0)
       CALL glRotated(rYangle, 0.0, 1.0, 0.0)
       CALL glRotated(rZangle, 0.0, 0.0, 1.0)

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

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

       '//Up
       CALL glBegin(%GL_TRIANGLE_FAN)
       CALL glColor3ub( R2, G2, B2): CALL glVertex3d( 0.0, 1.414, 0.0)
       CALL glColor3ub( R1, G1, B1): CALL glVertex3d( 1.0, 0.0, 1.0)
       CALL glColor3ub( 0, 0, 0):    CALL glVertex3d( 1.0, 0.0,-1.0)

       CALL glColor3ub( R1, G1, B1): CALL glVertex3d(-1.0, 0.0,-1.0)
       CALL glColor3ub( 0, 0, 0):    CALL glVertex3d(-1.0, 0.0, 1.0)
       CALL glColor3ub( R1, G1, B1): CALL glVertex3d( 1.0, 0.0, 1.0)
       CALL glEnd()

       '//Down
       CALL glBegin( %GL_TRIANGLE_FAN)
       CALL glColor3ub( R2, G2, B2): CALL glVertex3d( 0.0,-1.414, 0.0)
       CALL glColor3ub( R1, G1, B1): CALL glVertex3d( 1.0, 0.0, 1.0)
       CALL glColor3ub( 64, 64, 64): CALL glVertex3d(-1.0, 0.0, 1.0)

       CALL glColor3ub( R1, G1, B1): CALL glVertex3d(-1.0, 0.0,-1.0)
       CALL glColor3ub( 64, 64, 64): CALL glVertex3d( 1.0, 0.0,-1.0)
       CALL glColor3ub( R1, G1, B1): CALL glVertex3d( 1.0, 0.0, 1.0)
       CALL glEnd()

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

    END IF
    CALL ReleaseDC(glCtrl, glDC)
END SUB


When used on VISTA it is very important to perform a zUpdateWindow after SwapBuffers to force DWM to refresh its internal buffer (or the OpenGL display seems to crawl).

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


Smooth animation

I am using my TIMER technic to perform smooth animation without using the common message pump that hogs the CPU:

          CALL SetTimer(hMain, %OPENGL_TIMER, 0, %NULL)
          WHILE GetMessage(Msg, %NULL, 0, 0)  ' SK_MILLISECOND
               IF IsDialogMessage(hMain, Msg) = %FALSE THEN
                   CALL TranslateMessage(Msg)
                   CALL DispatchMessage(Msg)
               END IF
          WEND
          CALL KillTimer(hMain, %OPENGL_TIMER)


Patrice Terrier
www.zapsolution.com

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

Petr Schreiber

Patrice,

thanks for this perfect player.
It is nice to just drop file on rotating cube to play it :)

The postprocess effects are very interesting too !


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

psch.thinbasic.com

Kent Sarikaya

Patrice very very nice. Thanks for another exciting program putting together many compilcated elements together in a very nice interface.

Patrice Terrier

Kent,

Thanks for the feedback.

I am trying from my best to post only high quality source code there, to keep this forum's level as high as possible.

This is my way to say thanks to José for all his hard work, and generous contributions to the PowerBASIC's community in general, and SDK coders in particular.  ;)


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

Patrice Terrier

#5
This new version has a real time stereo channel view meter, with vanishing LEDs.

This code is responsible for the drawing of the LEDs directly onto the main window DC, using ARGB color to be compatible with the zSkin VISTA BLUR and CRYSTAL mode.

'      //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



The realtime LED dissolve effect is computed there:


FUNCTION SetRGB(BYVAL colorRGB AS DWORD) AS LONG
    LOCAL R, G, B AS BYTE
    R = (colorRGB AND &H000000FF???): IF R > 31 THEN R = R - 32 ELSE R = 0
    SHIFT RIGHT colorRGB, 8
    G = (colorRGB??? AND &H000000FF???): IF G > 31 THEN G = G - 32 ELSE G = 0
    SHIFT RIGHT colorRGB, 8
    B = (colorRGB AND &H000000FF???): IF B > 31 THEN B = B - 32 ELSE B = 0
    FUNCTION = RGB(R,G,B)
END FUNCTION


The provided zSkin.inc fixes a small problem when switching from Crystal to Standard mode, the opacity was not properly restored because the region was still active.

I would be very pleased if somebody else could write another OpenGL visual effect for BassBox...

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

Petr Schreiber

Hi Patrice,

perfect sample, I cannot promise but if I will have at least some time free I will try to add alternative visualisation.

One tip - could you please stop writing fast programs :D
On my PC it runs so fast I can see "tearing" - effect when v-sync is off ( more frames per second than Hz of device ). It can be solved using wglSwapIntervalEXT.

I will try to implement it when I will have more time.


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

psch.thinbasic.com

Patrice Terrier

If you want to increase the LED's dissolve delay then try playing with bStep like this:

FUNCTION SetRGB(BYVAL colorRGB AS DWORD) AS LONG
    LOCAL R, G, B, bStep AS BYTE
    bStep = 4 ' 32
    R = (colorRGB AND &H000000FF???): IF R > bStep - 1 THEN R = R - bStep ELSE R = 0
    SHIFT RIGHT colorRGB, 8
    G = (colorRGB??? AND &H000000FF???): IF G > bStep - 1 THEN G = G - bStep ELSE G = 0
    SHIFT RIGHT colorRGB, 8
    B = (colorRGB AND &H000000FF???): IF B > bStep - 1 THEN B = B - bStep ELSE B = 0
    FUNCTION = RGB(R,G,B)
END FUNCTION


A value of 24 or 32 makes it more responsive.
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Kent Sarikaya

I like the new LED bars a nice visual addition to the fascinating glowing mineral look of the main pyramid. It looks like it is glowing with energy with the cool coloring setup, really neat effect!!

Patrice Terrier

#9
I have added a search trackbar (seek tracker) to fast move forward/backward the playing audio file.


Screen shot from my VISTA laptop:




zSkin.inc has been updated with a new progresscolor property.

The Last_Patch.zip below is updated

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

Charles Pegge

Patrice,

I am fascinated by your creations.

will Bassbox support other audio formats: I am thinking of MIDI in particular, (picking up from the soft synth etc), also WMA and WAV.

I would like to try some  polyhedra. These would be better suited as GLISTs since they may contain 100s of faces.
They can be placed one inside the other and rolled, permutating the shading with the music. Can DirectAudio provide frequency data as well as amplitude?

Patrice Terrier

Charles

I have them ALL already in my commercial projects, that have been broken by all the changes done to the low level audio API in VISTA.

BassBox is a kind of laboratory to experiment with VISTA...

So far the current player should/is already able to play WAV PCM files, as well as OGG VORBIS and AIFF, with minor modification(s).

For MIDI file, Rafaelo posted some very nice PB examples that you can find in POFF, or I can send them to you if you can't find them.

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

Charles Pegge

Thanks Patrice.

I am certainly worried about Vista.

How deeply has Vista broken the low level interfaces for Midi and Wav. Is it still possible to set up a WAV buffer and feed it WAV bytes or send individual midi commands to the on-board MIDI ?

Patrice Terrier

Charles,

The main VISTA issue is with the MIXER API, not with PCM audio (wave).

...


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

Patrice Terrier

#14
Under request of Charles

This new BassBox patch, allows you to play: mp1, mp2, mp3, ogg, wav, aif (apple).

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