See the section entitled "BassBox 2011 (http://www.jose.it-berater.org/smfforum/index.php?topic=2975.0)" 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 (http://www.jose.it-berater.org/smfforum/index.php?topic=2975.0)<<< 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. (http://www.vbfrance.com/codes/BASSBOX-AUDIO-OPENGL-VISUAL-PLUGINS_44975.aspx)
...
Patrice Terrier
www.zapsolution.com
Previously loaded 153 times.
BassBox insightYou 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.DLLAll the details about this fantastic audio library, from
Ian Luck, can be found there:
www.un4seen.com (http://www.un4seen.com)WM_COPYDATAThis 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
OpenGLThis 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 animationI 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,
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
Patrice very very nice. Thanks for another exciting program putting together many compilcated elements together in a very nice interface.
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. ;)
...
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...
...
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
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.
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!!
I have added a search trackbar (seek tracker) to fast move forward/backward the playing audio file.
Screen shot from my VISTA laptop:
(http://www.zapsolution.com/pictures/sdk/bassbox_track.jpg)
zSkin.inc has been updated with a new progresscolor property.
The Last_Patch.zip below is updated
...
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?
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.
...
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 ?
Charles,
The main VISTA issue is with the MIXER API, not with PCM audio (wave).
...
Under request of Charles
This new BassBox patch, allows you to play: mp1, mp2, mp3, ogg, wav, aif (apple).
...
Thanks Patrice!
It looks especially good with slow jazz.
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
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!!
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.
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
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 ;)
...
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
I have added a plugin section into BassBox and radio buttons to select the visual effect:
(http://www.zapsolution.com/pictures/sdk/bassbox_plugin.jpg)
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 ;)
...
Scott,
Better to use VISTA with 2048 Mb and a true graphic card,
shared memory is a NoNo with OpenGL ...
...
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
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?
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.
...
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
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.
Have you seen this?
ZAP Visual Plugin (http://www.zapsolution.com/zvpus.htm)
Note: the 10-band equalizer is high on my todo list for BassBox 8)
...
Wow, that is cool, plug-ins, simple click and change visual effects, very cool job guys.
Charles, loved seeing your cool dome structures visualization too!
BassBox now has a 10-band equalizer!
VISTA screenshot:
(http://www.zapsolution.com/pictures/sdk/bassbox_equ.jpg)
The Equalizer setup is saved/restored from registry using this couple of new functions:
' Returns a registry string
FUNCTION zsGetReg ALIAS "zsGetReg" (BYVAL hLocation AS DWORD, zSubKeys AS ASCIIZ, zValueName AS ASCIIZ) EXPORT AS STRING
LOCAL hKey AS DWORD, zRegVal AS ASCIIZ * %MAX_PATH, dwType AS DWORD, dwSize AS DWORD
IF hLocation = 0 THEN hLocation = %HKEY_CURRENT_USER
IF (RegOpenKeyEx(hLocation, TRIM$(zSubKeys, $Anti), 0, %KEY_READ, hKey) = 0) THEN
dwType = %REG_SZ
' Set length of buffer...
dwSize = SIZEOF(zRegVal)
CALL RegQueryValueEx(hKey, zValueName, 0, dwType, zRegVal, dwSize)
CALL RegCloseKey(hKey)
END IF
FUNCTION = zRegVal
END FUNCTION
' Saves a string value to the registry, returns nonzero if successful
FUNCTION zsSetReg ALIAS "zsSetReg" (BYVAL hLocation AS DWORD, zSubKeys AS ASCIIZ, zRegName AS ASCIIZ, zRegVal AS ASCIIZ) EXPORT AS LONG
LOCAL hKey AS DWORD, dwType AS DWORD, dwSize AS DWORD
nRet& = 0
IF hLocation = 0 THEN hLocation = %HKEY_CURRENT_USER
IF RegCreateKeyEx(hLocation, TRIM$(zSubKeys, $Anti), 0, "", 0, %KEY_WRITE, BYVAL %Null, hKey, BYVAL %Null) = 0 THEN
' Set length of data...
dwSize = LEN(zRegVal)
dwType = %REG_SZ
IF RegSetValueEx(hKey, zRegName, 0, dwType, zRegVal, dwSize) = 0 THEN nRet& = %True
RegCloseKey hKey
END IF
FUNCTION = nRet&
END FUNCTION
As you can see, when you master "low level SDK programming" there is nothing you can't do with an interface, imagination is your limit. ;D
And you know what?... finaly I think, I start to like VISTA :o
...
:)
New equalizer works perfectly, nice to see how different setup can totally change sound of songs.
In combination with "Flanger" effects it is easy to create terrible sound of old VHS movie :)
Thanks,
Petr
I have added ID3 TAG support (version 1.0 et 1.1)
'// So far this version decodes only ID3 TAG Version 1.0 et 1.1
FUNCTION BassGetID3TAG(zFileName AS ASCIIZ) AS LONG
LOCAL So, nSuccess, hFile AS LONG, sComment, sTrack, sFileName, sB, sTag AS STRING
LOCAL sTitle, sArtist, sAlbum, sYear, sType AS STRING
nSuccess = 0
CALL ShowWindow(zGetMainItem(%ID_TAG_TITLE), %SW_HIDE)
CALL ShowWindow(zGetMainItem(%ID_TAG_ALBUM), %SW_HIDE)
CALL ShowWindow(zGetMainItem(%ID_TAG_ARTIST), %SW_HIDE)
CALL ShowWindow(zGetMainItem(%ID_TAG_TYPE), %SW_HIDE)
CALL ShowWindow(zGetMainItem(%ID_TAG_EMPTY), %SW_HIDE)
IF zsFOpen(zFileName, 0, 2, hFile) = 0 THEN
CALL zSplitN (zFileName, "", sFileName)
So = INSTR(-1, sFileName, $Dot)
IF So THEN sFileName = LEFT$(sFileName, So)
sTag = SPACE$(128)
IF zsFGetAt(hFile, zsFlof(hFile) - 128, sTag) = 0 THEN
IF LEFT$(sTag, 3) = "TAG" THEN
REDIM sTagItem(1 TO 7) AS STRING
sB = CHR$(32,0)
sTag = RIGHT$(sTag, 125)
sTitle = TRIM$(MID$(sTag, 1, 30), ANY sB)
IF UCASE$(sTitle) = LEFT$(UCASE$(sFileName), LEN(sTitle)) THEN sTitle = sFileName
sArtist = RTRIM$(MID$(sTag, 31, 30), ANY sB)
IF UCASE$(sArtist) = "ARTIST" THEN sArtist = ""
sAlbum = RTRIM$(MID$(sTag, 61, 30), ANY sB)
IF UCASE$(sAlbum) = "TITLE" THEN sAlbum = ""
sYear = RTRIM$(MID$(sTag, 91, 4), ANY sB)
sComment = MID$(sTag, 95, 30)
IF ASC(sComment, 29) = 0 THEN
sTrack = LTRIM$(STR$(ASC(MID$(sComment, 30, 1))))
IF ASC(sTrack) > 0 THEN sTrack = "#" + sTrack
sComment = LEFT$(sComment, 28)
END IF
sComment = RTRIM$(sComment, ANY sB)
sType = PARSE$("Blues,Classic Rock,Country,Dance,Disco,Funk,Grunge,Hip-Hop,Jazz,Metal,New Age,Oldies," + _
"Other,Pop,R&B,Rap,Reggae,Rock,Techno,Industrial,Alternative,Ska,Death Metal,Pranks," + _
"Soundtrack,Euro-Techno,Ambient,Trip-Hop,Vocal,Jazz+Funk,Fusion,Trance,Classical," + _
"Instrumental,Acid,House,Game,Sound Clip,Gospel,Noise,Alternative Rock,Bass,Soul," + _
"Punk,Space,Meditative,Instrumental Pop,Instrumental Rock,Ethnic,Gothic,Darkwave," + _
"Techno-Industrial,Electronic,Pop-Folk,Eurodance,Dream,Southern Rock,Comedy,Cult," + _
"Gangsta,Top 40,Christian Rap,Pop/Funk,Jungle,Native US,Cabaret,New Wave,Psychadelic," + _
"Rave,Showtunes,Trailer,Lo-Fi,Tribal,Acid Punk,Acid Jazz,Polka,Retro,Musical,Rock & Roll," + _
"Hard Rock,Folk,Folk-Rock,National Folk,Swing,Fast Fusion,Bebob,Latin,Revival,Celtic," + _
"Bluegrass,Avantgarde,Gothic Rock,Progressive Rock,Psychedelic Rock,Symphonic Rock," + _
"Slow Rock,Big Band,Chorus,Easy Listening,Acoustic,Humour,Speech,Chanson,Opera,Chamber Music," + _
"Sonata,Symphony,Booty Bass,Primus,Porn Groove,Satire,Slow Jam,Club,Tango,Samba,Folklore," + _
"Ballad,Power Ballad,Rhytmic Soul,Freestyle,Duet,Punk Rock,Drum Solo,Acapella,Euro-House," + _
"Dance Hall,Goa,Drum & Bass,Club-House,Hardcore,Terror,Indie,BritPop,Negerpunk,Polsk Punk," + _
"Beat,Christian Gangsta Rap,Heavy Metal,Black Metal,Crossover,Contemporary Christian," + _
"Christian Rock,Merengue,Salsa,Trash Metal,Anime,Jpop,Synthpop", ASC(sTag, 125) + 1)
sTag = ""
nSuccess = -1
END IF
END IF
CALL zsFClose(hfile)
END IF
IF nSuccess THEN
zSetCTLText(zGetMainItem(%ID_TAG_TITLE), (UCASE$(sTitle)))
IF LEN(sYear) THEN sYear = " (" + sYear + ")"
zSetCTLText(zGetMainItem(%ID_TAG_ALBUM), (TRIM$(sAlbum + sYear)))
zSetCTLText(zGetMainItem(%ID_TAG_ARTIST), (sArtist))
zSetCTLText(zGetMainItem(%ID_TAG_TYPE), (sType))
CALL ShowWindow(zGetMainItem(%ID_TAG_TITLE), %SW_SHOW)
CALL ShowWindow(zGetMainItem(%ID_TAG_ALBUM), %SW_SHOW)
CALL ShowWindow(zGetMainItem(%ID_TAG_ARTIST), %SW_SHOW)
CALL ShowWindow(zGetMainItem(%ID_TAG_TYPE), %SW_SHOW)
ELSE
CALL zSetCTLText(zGetMainItem(%ID_TAG_EMPTY), (UCASE$(sFileName)))
CALL ShowWindow(zGetMainItem(%ID_TAG_EMPTY), %SW_SHOW)
END IF
FUNCTION = nSuccess
END FUNCTION
The latest ZIP is attached under this message
...
Thanks,
works great over here :)
Petr
Charles, (and others as well)
You asked for it...
This new version is able to play WMA audio files (it requires the provided BassWma.dll) and WMA audio support must already be available (it comes along with Windows Media Player).
If you don't plan to use Windows Media Player and only want the audio CODEC then use this redistribution file:
wmfdist.exe (http://www.un4seen.com/download.php?wmfdist.exe)
Note: I have also added the BassTags.dll to decode ID3 TAG for all the supported audio files.
So far: mp1, mp2, mp3, wav, ogg, aif, wma.
There is also a new Bass.dll file that is smaller than the previous one, because it uses the Windows built-in mp3 support that is free.
Thanks Patrice, It's looking (and sounding) very good!
If you are using Media Player infrastructure, can it also support MIDI or does that come by a different route?
As well as Midi, one particular interest I have at the moment is in real-time wave synthesis, which computes sounds in frame-based time slices and inserts them into a looping audio buffer. Ideal for computer games because they do not need to be distributed with sound files, and this technique also enables ambient sound generation without repetition. There does not seem to be much about this on the web. While I am not averse to reinventing the wheel it would be nice to see if there are any other synth projects like this in the public domain.
Charles you might be interested in this: http://supercollider.sourceforge.net/videos?MoodleSessionscsite=9c6ea0afe3e166d5500a5bf08586bfc2
I have not used it, but the program is now 10 years old and opensource.
Thanks Patrice, each patch just gets better and better!
Thanks Kent, interesting project, but the examples, well let's just say they are meagre, which suggests a lack of progress over ten years. I think many Video games use minimalist composition very effectively, but there are real musicians behind that.
At the moment I am trying to understand how the wave audio buffers work. I seem to be getting very large delays in the callback generated when a buffer is empty and needs topping up. But the Wave generation side is working fine.
Little variation on the same theme...
See attached CrystalPsource.zip
(I am doing that one, to post it on CrystalXP)
Thanks Patrice,
now it looks even more futuristic :)
Petr
Oh, I really like this version. Very very nice looking and sleek!! Excellent Patrice, you keep surpassing yourself!!!
Real Panache. I'd love to develop some choreographed forms for this. Can we implement a simple plug-in along the lines we discussed earlier?
One thing you will need to check . I think there is a memory leak - In XP it will crash after a substantial number of replays. >10 maybe.
Charles
I found myself a problem with the BASS.dll free mp3 version, may be it is the same.
Thus I switched back to the plain version that I have attached to this message for your conveniance.
QuoteCan we implement a simple plug-in along the lines we discussed earlier?
Sure, please go ahead, I would like very much to add more plug-in effects.
By the way I have a question about using
glGenTexture() I am unsure of the best place to use
glDeleteTexture() with it, could you give me some insight?
I am doing this myself to create textures:
FUNCTION ZI_SetGLTextureFromFile ALIAS "ZI_SetGLTextureFromFile" (zFullName AS ASCIIZ) EXPORT AS LONG
DIM Texture(0) AS LONG, Ret AS LONG
REDIM PixelArray(0) AS BYTE
IF ZI_CreateGLTextureFromFile(zFullName, xSize&, ySize&, PixelArray()) THEN
CALL glGenTextures(1, Texture(0)): Ret = glGetError
IF Ret& = 0 THEN CALL glBindTexture(%GL_TEXTURE_2D, Texture(0)): Ret = glGetError
IF Ret& = 0 THEN CALL glTexParameteri(%GL_TEXTURE_2D, %GL_TEXTURE_MAG_FILTER, %GL_LINEAR): Ret = glGetError
IF Ret& = 0 THEN CALL glTexParameteri(%GL_TEXTURE_2D, %GL_TEXTURE_MIN_FILTER, %GL_LINEAR): Ret = glGetError
IF Ret& = 0 THEN CALL glTexImage2D(%GL_TEXTURE_2D, 0, 3, xSize&, ySize&, 0, %GL_RGB, %GL_UNSIGNED_BYTE, PixelArray(0)): Ret = glGetError
FUNCTION = Ret&
END IF
END FUNCTION
FUNCTION ZI_CreateGLTextureFromFile ALIAS "ZI_CreateGLTextureFromFile" (zFullPath AS ASCIIZ, xSize AS LONG, ySize AS LONG, PixelArray() AS BYTE) EXPORT AS LONG
LOCAL bi AS MYBITMAPINFO
LOCAL pBits AS BYTE PTR
LOCAL hIC AS LONG, hTmpDC AS LONG, hBitmap AS LONG
xSize = 0: ySize = 0
CALL ZI_GetImageSizeFromFile(zFullPath, bmW&, bmH&)
DIM P(1 TO 11) AS LONG
P(1)= 2: P(2) = 4: P(3) = 8: P(4) = 16: P(5) = 32: P(6) = 64: P(7) = 128: P(8)= 256: P(9) = 512: P(10) = 1024: P(11) = 2048
FOR K& = UBOUND(P) TO LBOUND(P) STEP -1
IF xSize = 0 AND bmW& > P(K&) - 1 THEN xSize = P(K&)
IF ySize = 0 AND bmH& > P(K&) - 1 THEN ySize = P(K&)
NEXT
IF DoNotSquareTexture(0,0) THEN
CALL DoNotSquareTexture(0, 1)
ELSE
xSize = MAX&(xSize, ySize): ySize = xSize
END IF
hBitmap = ZI_FitImageFromFile(zFullPath, xSize, ySize)
IF hBitmap THEN
hIC = zDisplayDC()
hTmpDC = CreateCompatibleDC(hIC)
CALL SelectObject(hTmpDC, hBitmap)
bi.bmiHeader.biSize = SIZEOF(bi.bmiHeader)
bi.bmiHeader.biWidth = xSize
bi.bmiHeader.biHeight = ySize
bi.bmiHeader.biPlanes = 1
bi.bmiHeader.biBitCount = 24
bi.bmiHeader.biCompression = %BI_RGB
REDIM PixelArray(0 TO xSize * ySize * 3 - 1) AS BYTE
IF GetDIBits(hTmpDC, hBitmap, 0, ySize, PixelArray(0), BYVAL VarPtr(bi), %DIB_RGB_COLORS) THEN
' Perform Red and Green permutation
pBits = VARPTR(PixelArray(0))
FOR K& = (xSize * ySize) TO 1 STEP - 1
R? = @pBits[2]: @pBits[2] = @pBits[0]: @pBits[0] = R?: pBits = pBits + 3
NEXT
FUNCTION = -1
END IF
CALL DeleteDC(hIC)
CALL DeleteDC(hTmpDC)
CALL DeleteObject(hBitmap)
END IF
END FUNCTION
If I want to replace an existing texture by a new one where is the best place to put the
glDeleteTexture() to avoid memory leak?
Hi Patrice,
I think you should use it like that:
Quote
FUNCTION ZI_SetGLTextureFromFile ALIAS "ZI_SetGLTextureFromFile" (zFullName AS ASCIIZ) EXPORT AS LONG
DIM Texture(0) AS LONG, Ret AS LONG
REDIM PixelArray(0) AS BYTE
IF ZI_CreateGLTextureFromFile(zFullName, xSize&, ySize&, PixelArray()) THEN
CALL glDeleteTextures(1, Texture(0))
CALL glGenTextures(1, Texture(0)): Ret = glGetError
IF Ret& = 0 THEN CALL glBindTexture(%GL_TEXTURE_2D, Texture(0)): Ret = glGetError
IF Ret& = 0 THEN CALL glTexParameteri(%GL_TEXTURE_2D, %GL_TEXTURE_MAG_FILTER, %GL_LINEAR): Ret = glGetError
IF Ret& = 0 THEN CALL glTexParameteri(%GL_TEXTURE_2D, %GL_TEXTURE_MIN_FILTER, %GL_LINEAR): Ret = glGetError
IF Ret& = 0 THEN CALL glTexImage2D(%GL_TEXTURE_2D, 0, 3, xSize&, ySize&, 0, %GL_RGB, %GL_UNSIGNED_BYTE, PixelArray(0)): Ret = glGetError
FUNCTION = Ret&
END IF
END FUNCTION
... and then when you destroy window of course.
In case there is not texture yet in Texture() global array, glDeleteTextures will simply do nothing according to specification:
Quote
glDeleteTextures silently ignores 0's and names that do not
correspond to existing textures.
... so you do not have to take care of deleting textures only when there are some.
Bye,
Petr
What if Texture() is not a global array :)
Does there is an OpenGL function to retrieve existing textures without using a global array ?
Hi Patrice,
you can test if index is used textured "name" using glIsTexture( indexHere ).
On all implementations I have seen, first call to
Quote
glGenTextures 2, Textures(0)
will result in Textures(0) = 1, Textures(1) = 2.
But this is sadly not guaranteed by specification.I will check for more info.
Petr
P.S. Good OpenGL reference is http://www.opengl.org/sdk/docs/man/
Patrice, I checked through my opengl projects and found that I have never used glDeleteTexture. It has never caused any trouble to other applications or itself. So I presume these are taken care of at the end of the GL context. But I have not used large numbers of textures, at any one time so far.
I find dynamic strings are good for holding the pixel images as they are so disposable.
Charles,
not releasing textures using glDeleteTextures caused quite noticable leaks on Win9x/ME systems, so better to not ignore it :)
I did not do it too in my 3D editor for example, but after few run/close cycles it could lead to very suspicious behaviour of system.
Petr
Patrice,
do you think it would be possible to drop directory on the player window and it would add the media files according to automatic search ? :-[
I like this feature a lot in WinAmp - but there I have to choose directory in classic way, not so nice as just throwing files on window :)
Petr
I have taken your advice to heart Petr, and patched the glDeleteTextures into my shutdown procedure. And that link is very useful. No excuses for ignorance now :)
To do a fully fledged plugin for Bassbox, we will need to have setup, play and shutdown notification, so that the plugin can manage its own list items and textures. But there are huge possibilities. You could for example, have an interactive plugin with simple games, something related to the rhythm of the music
I didn't use myself glDeleteTexture and have never had troubles until a C# programmer start changing them in sequence in GDImage and found that is causes memory leak.
Quote
do you think it would be possible to drop directory on the player window and it would add the media files according to automatic search ?
Petr,
Do you mean droping a whole directory, that could have embedded subfolders, and peform recursive search to find if there are audio files in them?
Charles
what are the parameters you will need to call the plug-ins, or perhaps we could define a BBPLUGIN structure like this:
TYPE BBPLUGIN
bbParentWindow AS LONG
bbDC AS LONG
bbRC AS LONG
bbLeftPeak AS WORD
BBRightPeak AS WORD
etc.
END TYPE
Note:
I could add new features like internet streaming.
I could do also audio capture in realtime of any sound beeing played on the computer (requires a multiplex audio board) and display the audio wave graphicaly.
And what about a multichannel audio mixer ;)
Audio capture screen shot:
(http://www.zapsolution.com/pictures/sdk/audiocapture.jpg)
All I can say is this is cool stuff, as I sit back and watch you gurus do magic!
Quote
Petr,
Do you mean droping a whole directory, that could have embedded subfolders, and peform recursive search to find if there are audio files in them?
Exactly. I know it could take some time, but I have music organised in subfolders under one "Music" folder, so this way I could throw directory on BassBox, and then do some coding while listening to music with no more care :)
Internet streaming sounds very nice as well as realtime capture!
Regarding glDeleteTextures - I didn't new they exist at all for long time, then I started to check behaviour of my app ;D
Bye,
Petr
Patrice,
I think a DLL plugin would be ideal. Something BassBox could recognise if it was dropped into the plugins folder.
Using your data structure BassBoxData, The DLL functions could look like this:
WhatAreYou() as long
Setup(BassBoxData)
PlayFrame(BassBoxData)
Shutdown(BassBoxData)
As an experiment, I should be able to decouple my Viewer Software from the Windows loop and turn it into such a DLL.
Charles
I shall come back to you tomorrow, now it is too late :-[
Here is my suggestion to create plugins for BassBox:
MACRO CONST = MACRO
CONST BB_INIT = %WM_CREATE
CONST BB_PAINT = %WM_PAINT
CONST BB_DESTROY = %WM_DESTROY
CONST BB_SUCCESS = 0
CONST BB_ERROR = -1
TYPE BBPLUGIN
Msg AS LONG '// The plugin's message (see above constant list)
ParentWindow AS LONG '// The parent window handle
DC AS LONG '// The parent window DC (while in play mode)
RC AS LONG '// The parent OpenGL RC (while in play mode)
LeftPeak AS WORD '// The left audio channel peak value (while in play mode)
RightPeak AS WORD '// The right audio channel peak value (while in play mode)
Title AS ASCIIZ * 32 '// Plugin's name or title.
Author AS ASCIIZ * 32 '// Plugin's author name
Version AS DWORD '// LOWRD major, HIWRD minor
END TYPE
'// Use a dedicated "bbp" DLL extension: MyPlugin.bbp to ease the plugin's detection
'// Use a generic "BBPLUGIN" folder that would store all the bbp plugins,
'// each one could have its own embedded subfolders inside of "BBPLUGIN" to store local resources.
'// The main exported plugin's function would be bbProc, like this:
FUNCTION bbProc ALIAS "bbProc" (BYREF BB AS BBPLUGIN) EXPORT AS LONG
LOCAL nRet AS LONG
nRet = BB_SUCCESS
SELECT CASE LONG BB.Msg
CASE BB_INIT
'// Do your code initialisation there
BB.Title = "My BB plugin"
BB.Author = "My Name"
BB.Version = MAKDWRD(1, 0) '// Version 1.0"
CASE BB_PAINT
'// Draw the scene there using BB.LeftPeak and BB.RightPeak
CASE BB_DESTROY
'// Free up your resources there
CASE ELSE
nRet = BB_ERROR
END SELECT
FUNCTION = nRet
END FUNCTION
Yes I think this will work very well Patrice. I was just wondering whether other audio data as well as left and right peak might be available. I dont know what MS audio offers us, but frequency spectral info would be very interesting to visualise.
And can we assume that GDIplus will always be online in BassBox as well as Opengl?
Charles ? ? ?
Then here is my new suggestion
See new constants: BB_GDIPLUS, BB_OPENGL, BB_DIRECTX and how to use them in the BB_INIT message.
See also the new RenderTo member in the BBPLUGIN structure.
MACRO CONST = MACRO
CONST BB_INIT = %WM_CREATE
CONST BB_PLAY = %WM_PAINT
CONST BB_DESTROY = %WM_DESTROY
CONST BB_GDIPLUS = 0 '// GDImage GDIPLUS compatible mode
CONST BB_OPENGL = 1 '// OpenGL mode
CONST BB_DIRECTX = 2 '// DirectX mode (for future extension)
CONST BB_SUCCESS = 0
CONST BB_ERROR = -1
TYPE BBPLUGIN
Msg AS LONG '// The plugin's message (see above constant list)
ParentWindow AS LONG '// The parent window handle
DC AS LONG '// The parent window DC (while in play mode)
RC AS LONG '// The parent OpenGL RC (while in play mode)
LeftPeak AS WORD '// The left audio channel peak value (while in play mode)
RightPeak AS WORD '// The right audio channel peak value (while in play mode)
Title AS ASCIIZ * 32 '// Plugin's name or title.
Author AS ASCIIZ * 32 '// Plugin's author name
Version AS DWORD '// LOWRD major, HIWRD minor
RenderTo AS LONG '// BB_GDIPLUS, BB_OPENGL, BB DIRECTX
END TYPE
'// Use a dedicated "bbp" DLL extension: MyPlugin.bbp to ease the plugin's detection
'// Use a generic "BBPLUGIN" folder that would store all the bbp plugins,
'// each one could have its own embedded subfolders inside of "BBPLUGIN" to store local resources.
'// The main exported plugin's function would be bbProc, like this:
FUNCTION bbProc ALIAS "bbProc" (BYREF BB AS BBPLUGIN) EXPORT AS LONG
LOCAL nRet AS LONG
nRet = BB_SUCCESS
SELECT CASE LONG BB.Msg
CASE BB_INIT
'// Do your code initialisation there
BB.Title = "My BB plugin"
BB.Author = "My Name"
BB.Version = MAKDWRD(1, 0) '// Version 1.0"
BB.RenderTo = BB_OPENGL '// or BB_GDIPLUS, or BB_DIRECTX
CASE BB_PLAY
'// Draw the scene using BB.LeftPeak and BB.RightPeak
CASE BB_DESTROY
'// Free up your resources there
CASE ELSE
nRet = BB_ERROR
END SELECT
FUNCTION = nRet
END FUNCTION
About FFT and audiogram, let me think of it (this would be more related to the WAVE API being used to grab audio sounds)
Petr,
QuoteExactly. I know it could take some time, but I have music organised in subfolders under one "Music" folder, so this way I could throw directory on BassBox, and then do some coding while listening to music with no more care
Then I did it... ;D
Now you can drag a complete folder! BassBox detects recursively all embedded audio files and adds them to its hidden play list.
FUNCTION DetectAudio (BYVAL FullName$, BYVAL hList AS LONG) AS LONG
LOCAL szFileName AS ASCIIZ * %MAX_PATH
LOCAL sDetect AS STRING
LOCAL nCount AS LONG
IF LEN(FullName$) THEN
CALL zSplitN (FullName$, PathName$, FilterName$)
sDetect = DIR$(FullName$, 39) ' %NORMAL + %READONLY + %HIDDEN + %SYSTEM + %ARCHIVE
DO WHILE LEN(sDetect)
szFileName = LCASE$(PathName$ + sDetect)
IF BassCheckExtension(szFileName) THEN
IF ListAdd(hList, szFileName) > -1 THEN INCR nCount
END IF
sDetect = DIR$
LOOP
END IF
FUNCTION = nCount
END FUNCTION
FUNCTION RecursiveSearch(szFileName AS ASCIIZ, BYVAL hList AS LONG) AS LONG
LOCAL nCount AS LONG
REDIM DirName$(0)
Path$ = RTRIM$(szFileName, $Anti) + $Anti
DirName$(0) = Path$
CALL ReadDirs(Path$, DirName$())
FOR K& = LBOUND(DirName$) TO UBOUND(DirName$)
nCount = nCount + DetectAudio(DirName$(K&) + "*.*", hList)
NEXT
FUNCTION = nCount
END FUNCTION
SUB ReadDirs(BYVAL Path$, DirName$())
LOCAL fd AS WIN32_FIND_DATA
LOCAL hFind AS LONG, zPath AS ASCIIZ * %MAX_PATH
zPath = Path$ + "*"
hFind = FindFirstFile(zPath, fd)
IF hFind <> %INVALID_HANDLE_VALUE THEN
DO
IF (fd.dwFileAttributes AND 16) THEN ' If directory bit (16) is set
IF (ASC(fd.cFileName) = 46) = 0 THEN ' Not . or ..
N& = MAX&(UBOUND(DirName$) + 1, 1)
REDIM PRESERVE DirName$(N&)
DirName$(N&) = Path$ + RTRIM$(fd.cFileName, CHR$(0)) + $Anti
' We have a subdir, call function again to find others
' Each recursive call gets its own place on the stack
CALL ReadDirs(DirName$(N&), DirName$())
END IF
END IF
LOOP WHILE FindNextFile(hFind, fd)
CALL FindClose(hFind)
END IF
END SUB
CASE %WM_DROPFILES '// Drag & drop
nFilesDropped = DragQueryFile(wParam, -1, "", 0)
szFileName = ""
nCount = 0
IF nFilesDropped > 0 THEN
hList = zGetMainItem(%ID_PlayList)
CALL ListDeleteAll(hList)
FOR K = 0 TO nFilesDropped - 1
CALL DragQueryFile(wParam, K, szFileName, %MAX_PATH)
szFileName = LCASE$(szFileName)
IF BassCheckExtension(szFileName) THEN
IF ListAdd(hList, szFileName) > -1 THEN INCR nCount
ELSE
nCount = nCount + RecursiveSearch(szFileName, hList) ' <-------- Recursive search is done there
END IF
NEXT
END IF
The new
LastPatch.zip is attached below
Hi Patrice,
thanks a lot lot lot.
It works perfectly, except situation when I get GPF :(
It is weird, sometimes I throw folder and can go through all tracks, but sometimes ( with same folder ) it will GPF when clicking next button.
But it is quite rare, I cannot isolate section in which it occurs now :(. I suspect BassChannelPlay, but not sure.
Thanks,
Petr
Make sure that the overall length of the full path name doesn't exceed %MAX_LENGTH, I don't check this.
If this occures try to convert to short name (but perhaps it is something else).
Anyway you have the full source code, thus try to check what could be wrong with your CZ config ;)
I am unable to reproduce it there, but I don't have many embedded subfolders.
Also try to enlarge the stack in case there is huge recursivity.
Thanks for the tips,
when I will find solution I will post here :)
Fact is that I cannot replicate it now, maybe it was somehow influenced by apps running before.
Petr
Here is the plugin version.
As you can imagine I have done many changes in it, so please check it thoroughly ;)
All plugins must be stored in the "BBPugin\" child folder.
Each plugin must be named "PLUG001.dll", "PLUG002.dll", "PLUG003.dll", etc.
in sequence.
Use the provided examples as template to write your own.
If have done a few cosmetic to the interface as well:
- New system buttons
- Animated moving blue led, just to show that the player is active.
- The Play button, flashes at startup to let the user know he could play already the default audio (BassBox.mp3).
Petr,
I have given the title of "Mikado" to your plugin, but of course feel free to change it 8)
And here is the new BBP API:
FUNCTION BBP_ProcHandle(BYVAL hProc AS DWORD, BYVAL RW AS LONG) AS DWORD
STATIC WasHproc AS DWORD
IF RW THEN WasHproc = hProc
FUNCTION = WasHproc
END FUNCTION
'// Detached plugin
SUB BBP_Detached(BYREF hLibModule AS DWORD)
LOCAL BBP AS BBPLUGIN
IF hLibModule THEN
BBP.Msg = %BBP_DESTROY
BBP.ParentWindow = zGetMainItem(%ID_OpenGL)
CALL BBP_Plugin(BBP)
CALL BBP_ProcHandle(0, 1): CALL FreeLibrary(hLibModule): hLibModule = 0
END IF
END SUB
'// Load/unload plugin DLL to/from memory
SUB BBP_LoadPlugin(zPlugin AS ASCIIZ)
STATIC hLibModule AS DWORD
LOCAL hProc AS DWORD, sLastPlugin AS STRING
IF LEN(zPlugin) AND zPlugin <> sLastPlugin THEN
IF zsExist(zPlugin) THEN
CALL BBP_Detached(hLibModule)
hLibModule = LoadLibrary(zPlugin)
IF hLibModule THEN
hProc = GetProcAddress(hLibModule, "BBProc")
IF hProc THEN
CALL BBP_ProcHandle(hProc, 1)
sLastPlugin = zPlugin
END IF
END IF
END IF
ELSEIF LEN(zPlugin) = 0 THEN
CALL BBP_Detached(hLibModule)
END IF
END SUB
'// Send/recept message to/from plugin
FUNCTION BBP_Plugin(BYREF BBP AS BBPLUGIN) AS LONG
LOCAL hProc AS DWORD, nRet AS LONG
nRet = %BBP_ERROR
IF glRC THEN
hProc = BBP_ProcHandle(0, 0): IF hProc THEN CALL DWORD hProc USING BBP_Plugin(BBP) TO nRet
END IF
FUNCTION = nRet
END FUNCTION
'// Return full qualified path to the plugin folder
FUNCTION BBP_Path() AS STRING
FUNCTION = zsExePath() + $BBP_PLUGIN_FOLDER
END FUNCTION
BassBox plugin version
updated with a new plugin from Charles Pegge:
PolyHedra
Hi Patrice,
thanks for new version,
looks nice !
Mikado name is ok :D
I still have some work to do, but I have idea what to create when I will have time ;)
Petr
Thanks Patrice! I am going to try converting my Viewer6 code into a compatible plugin. Then there will be lighting, keyboard and mouse interactions available. It will be feasible to support the plugins as a syncronised project.
Under some conditions, GPFs occur. It does not happen very often, so I have not been able to reproduce the crashes yet but they occur when dragging individual music files onto BassBox, maybe from different folders.
Ian Luck's BASS.dll,
is probably the best audio lib available world-wide, however it could GPF when it encounters an audio file corrupted or using a mismatched header.
This also could occured with some small wave files, like those being used by the OS.
For example, try with the small wave files attached below.
And here is what is detected by the VISUAL STUDIO debuger:
> 00000002()
Bass.dll!1000109f()
[Les frames ci-dessous sont peut-être incorrects et/ou manquants, aucun symbole chargé pour Bass.dll]
kernel32.dll!76fa6c6d()
kernel32.dll!76fa6c63()
ntdll.dll!777a0dfd()
ntdll.dll!777a06a0()
kernel32.dll!76fc77d4()
kernel32.dll!76fa9f16()
Bass.dll!1001d149()
msvcrt.dll!773ef471()
msvcrt.dll!773ef450()
kernel32.dll!76fc3833()
ntdll.dll!7777a9bd()
I could check for small WAVE file and ignore them, or perhaps add a small latency between each audio file, just to make sure that there is enough time to free up resources.
What do you think?
Most of the pieces, I have been trying this evening are ogg files, but the point of failure cannot be predicted - once in the middle of playing one file, without drag and drop. But I hope a pattern will eventually emerge. I dont mind extra music listening duties.
I think I have found a solution for the problem of playing very small wave files.
Instead of using BASS_StreamFree I am using BASS_ChannelStop, and the small wave files do not cause anymore a GPF.
This occures most of the time when dragging a whole hard disk, for example "C:\" (including the OS folder that do have many small wave files)
Below is the patch that solves the GPF problem that could occure when playing small wave files.
...
I really love the new player. Being able to drop folders, have quick access to various plugins and of course all the effects and equalization. Patrice, since this is very close to being an ulitmate player... it would be nice to have presets for the equalizer too. I was playing with it today and tried to set it to how I have my equalizer set in my sound card. When I did this, I got distortion, even though I turned off the eq on my sound card. Did anyone else have this sort of problem?
I've tried my best to crash BassBox but that patch seems to have fixed the GPF problem Patrice. It might have been trying to play a stream that had ceased to exist, so stopping it first makes sense.
Starting from now: october 25, 2007
I will always attached the latest patch version, with publication's date, to the first post of this thread, as well as in the new message.
Then it would be easier for you to detect that you are using the latest patch or not.
...
In this patch, I have greatly improved audio detection!
Now files like these:
c:\windows\winsxs\x86_microsoft-windows-mmsys_31bf3856ad364e35_6.0.6000.16386_none_5c390844e2400bf9\dts.wav
c:\windows\winsxs\x86_microsoft-windows-mmsys_31bf3856ad364e35_6.0.6000.16386_none_5c390844e2400bf9\ac3.wav
that would cause havoc, even in Windows Media Player are properly detected and handled by BassBox.
I have also removed from the hidden list any audio files that would be stored in "recycle.bin".
This version should not GPF anymore on bad audio files ::)
...
BassBox has a new feature!
Try this:
(http://www.zapsolution.com/pictures/sdk/bbbackgnd.jpg)
That is a really sweet addition Patrice!!
Kent,
Glad you like it ;)
Indeed the new "Background\" folder allows you to store jpg files, that you can use to customize the BassBox background while in standard mode (of course they are ignored in Blur and Crystal VISTA mode).
The hidden background list is updated there:
'// Fill the bakground listbox
'// Warning: Currently only JPG files!
SUB DetectBackground()
LOCAL hList, WashFind, hFind, BackgroundCount, nSelected AS LONG
LOCAL fd AS WIN32_FIND_DATA
LOCAL zTmp AS ASCIIZ * %MAX_PATH
LOCAL zBackground AS ASCIIZ * %MAX_PATH
LOCAL sBackgroundPath AS STRING
LOCAL nActiveBackgroundSize AS QUAD
LOCAL nItemSize AS QUAD
' // Size of the current active background image
nActiveBackgroundSize = zsFileSize((SK_CENTERFORM()))
sBackgroundPath = zsExePath() + "Background\"
hList = zGetMainItem(%ID_Background)
CALL ListDeleteAll(hList)
WashFind = FindFirstFile((sBackgroundPath + "*.*"), fd)
hFind = WashFind
DO WHILE hFind > 0
IF ASC(fd.cFileName) <> 46 THEN
IF INSTR(CHR$(0,1,32,33,128), CHR$(fd.dwFileAttributes)) THEN
zTmp = sBackgroundPath + fd.cFileName: CALL CharLower(zTmp)
IF INSTR(".jpg.", RIGHT$(zTmp, 4) + ".") THEN
nItemSize = MAK(QUAD, fd.nFileSizeLow, fd.nFileSizeHigh)
IF ListAdd(hList, zTmp) > -1 THEN
INCR BackgroundCount
' // If same size, then we assume it is our current background...
IF nItemSize = nActiveBackgroundSize THEN zBackground = zTmp
END IF
END IF
END IF
END IF
hFind = FindNextFile(WashFind, fd)
LOOP
CALL FindClose(WashFind)
nSelected = ListFindString(hList, zBackground)
CALL ListSelectPlus(hList, nSelected)
IF BackgroundCount < 2 THEN
CALL ShowWindow(zGetMainItem(%ID_BTN_BACKL), %SW_HIDE)
CALL ShowWindow(zGetMainItem(%ID_BTN_BACKR), %SW_HIDE)
END IF
END SUB
And to perform the copy of the selected background I have added a couple of new API to zSkin.inc:
FUNCTION zsFileOperation(BYVAL hDlg AS LONG, zSrce AS ASCIIZ, zTarget AS ASCIIZ, zTitle AS ASCIIZ, BYVAL FlagDialog AS LONG, BYVAL wFunc AS LONG) AS LONG
LOCAL ErrCode AS LONG
DIM Sh AS SHFILEOPSTRUCT
IF zsExist(zSrce) THEN
Sh.hWnd = hDlg&
Sh.wFunc = wFunc
Sh.pFrom = VARPTR(zSrce)
Sh.pTo = VARPTR(zTarget)
Sh.fFlags = %FOF_SILENT OR %FOF_NOCONFIRMATION OR %FOF_NOCONFIRMMKDIR
IF FlagDialog THEN
Sh.lpszProgressTitle = VARPTR(zTitle)
Sh.fFlags = %FOF_NOCONFIRMATION OR %FOF_NOCONFIRMMKDIR OR %FOF_SIMPLEPROGRESS
END IF
ErrCode = SHFileOperation(Sh)
ELSE
ErrCode = 2 ' The system cannot find the file specified
END IF
FUNCTION = ErrCode
END FUNCTION
FUNCTION zsFileCopy(BYVAL hDlg AS LONG, zSrce AS ASCIIZ, zTarget AS ASCIIZ, zTitle AS ASCIIZ, BYVAL FlagDialog AS LONG) AS LONG
FUNCTION = zsFileOperation (hDlg, zSrce, zTarget, zTitle, FlagDialog, %FO_COPY)
END FUNCTION
FUNCTION zsFileMove(BYVAL hDlg AS LONG, zSrce AS ASCIIZ, zTarget AS ASCIIZ, zTitle AS ASCIIZ, BYVAL FlagDialog AS LONG) AS LONG
FUNCTION = zsFileOperation (hDlg, zSrce, zTarget, zTitle, FlagDialog, %FO_MOVE)
END FUNCTION
Thanks Patrice,
really nice addition !
Petr
Now you can drag a complete folder directly onto the BassBox desktop icon if any :
(http://www.zapsolution.com/pictures/sdk/dragfolder.jpg)
...
Thanks Patrice, I love trying out different backgrounds, I think it will be a very popular feature. but one thing to watch out for with the new icon ability: dropping music folders and files onto the BassBox icon, when BassBox is not running, results in a GPF.
Quotedropping music folders and files onto the BassBox icon, when BassBox is not running, results in a GPF.
Well I am unable to reproduce it myself (on VISTA).
When I drag a folder while BassBox is not running, then it starts it, before playing.
Anybody else has the same problem than Charles?
Charles
You must be aware that the command line size is limited, this means if you have slected several files instead of using just the folder name, then the overall length of the joined file names could very fast exceed the size of the command line.
And this depending on the Windows version could (perhaps) cause the gpf.
On my computer in such a case when command$ is overflooded, then it is just ignored and it comes empty...
You may find this link instructive about command line size limitation:
http://blogs.msdn.com/oldnewthing/archive/2003/12/10/56028.aspx
I am using XP on an HP Pavillion Desktop, Patrice. I ran a few more tests after a reboot, with BassBox.mp3 and bluecube.ogg. The ogg file did not cause a gpf but only the visual part of BassBox was working. There were no controls or sound and it set my wave audio volume to zero. (at system level) .
Charles
In the short link property, did you select "start in" ---> the same folder holding BassBox and the various Bass.dll ?
Anyway I shall test it tomorrow on my XP computer, to see what is different than on VISTA.
I hate these differences between OS of the same provider ;)
Very interesting! I created a shortcut to BassBox, moved it to the desktop then dragged music files onto the shortcut. It works perfectly!
Being able to drag to a shortcut and get that kind of functionality is really cool stuff. First class abilities Patrice!!
I did check on XP and I have been able to reproduce the GPF.
It occures in TAGS_Read (inside GetTag).
I shall check the TAGS_Read declaration for the BassTags.dll, something must be wrong there.
-- Kent,
Yes I think, that being able to drag a whole folder on a short cut, is a nice feature addition.
Patrice, I am experimenting with lighting and shading in Bassbox. To make this work for the plugins it has been necessary to alter the pixel format definition (pfd) structure and introduce more opengl commands into the bassbox kernel. I think this sort of thing can only be done once on anOpengl context, so it cant be set by individual plugins, but being able to control lighting, alpha blending etc dramatically enhances what can be done by the plugins. I will send you my hacks ASAP, so you can decide whether to incorporate them or not.
Ok charles,
I will look at it, as soon as you send it to me ;).
So far I have been able to fix the GPF that could occure on XP, adding
PEEK$(ASCIIZ, So, 128) in GetTag.
(because the VC6 BassTag.DLL is returning an ASCIIZ PTR)
and using PEEK$ without the "ASCIIZ" clause, causes the GPF ...
Now I am going to bed, I shall send the fix tomorrow.
Here is the version that fix the GPF that could occure on XP while reading ID3 tags
Here is the new GetTag function with the ASCIIZ clause:
'// Use BassTags.dll to decode the ID3 TAG for all supported audio files
FUNCTION GetTag(zItem AS ASCIIZ) AS STRING
LOCAL So AS LONG, sItem AS STRING
So = TAGS_Read(gnAudioChannel, zItem)
IF So THEN FUNCTION = TRIM$(PEEK$(ASCIIZ, So, 128))
END FUNCTIONI did also a minor change into the WinMain section, there:
' // Let the user know that he can play audio already
IF IsWindowVisible(GetDlgItem(hMain, %ID_BTN_Play)) THEN
CALL SetFocus(GetDlgItem(hMain, %ID_BTN_Play))
CALL SetTimer(hMain, %BLINK_TIMER, 333, %NULL)
END IF
QuotePatrice, I am experimenting with lighting and shading in Bassbox. To make this work for the plugins it has been necessary to alter the pixel format definition (pfd) structure and introduce more opengl commands into the bassbox kernel. I think this sort of thing can only be done once on an Opengl context, so it cant be set by individual plugins, but being able to control lighting, alpha blending etc dramatically enhances what can be done by the plugins. I will send you my hacks ASAP, so you can decide whether to incorporate them or not.
--
Charles,
I did not get anything ???
...
Patrice, I am getting good results but there is some instability caused by the lighting, which needs to be pinpointed. In the main program, I have only needed to change the pixel format definition so far. Everything else is in the plugin.
Another idea is to make the mouse and keyboard states available to the plugin. This could open all sorts of possibilities - such as the ability to react to a drag-and drop operation and create various interactive toys. Even games!
What I would like to do myself is to map a video hover a moving object as WPF does ;)
The plugin model is already very flexible, thus we could easily add other messages like various WM_MOUSE messages, and assynchrone keyboard support as well (this is what I am doing already in GDImage).
In GDImage each sprite objet as a wealth of properties like these:
' Internal GDImage structure being used to store details about each sprite object.
%METADATA_SIZE = 2048 '//See it in GDImage.inc
TYPE ZOBJECT
hWnd AS LONG
objType AS LONG
metacount AS LONG
metadata AS STRING * %METADATA_SIZE
useFont AS ASCIIZ * 128
useSize AS LONG
fontFam AS LONG
curFont AS LONG
strFormat AS LONG
useARGB AS LONG
use3D AS LONG
x1 AS LONG ' x top coordinate
y1 AS LONG ' y top coordinate
x2 AS LONG ' object bound width
y2 AS LONG ' object bound height
visible AS LONG
order AS LONG
locked AS BYTE
ID AS LONG
Style AS LONG
Bitmap AS LONG
Region AS LONG
objLabel AS STRING * 64
xCapture AS WORD
yCapture AS WORD
opacity AS BYTE ' PNG variable opacity
scale AS SINGLE '//2.10
clone AS LONG '//2.10
xP AS WORD '//2.11
yP AS WORD '//2.11
angle AS WORD '//2.11
quality AS BYTE '//2.11
flipmode AS BYTE '//3.00
userotate AS BYTE '//3.00
selected AS BYTE '//3.02
hidden AS BYTE '//3.56
reserved AS STRING * 27' 28 ' 26
END TYPE ' 2368 bytes
This version uses a new plugin's kernell.
BBP_TITLE has been changed to BBP_CREATE.
Now it is the responsability of the plugin's author to tell the kernell which rendering mode He will be using during the BBP_CREATE message:
CASE %BBP_CREATE
'// Retrieve plugin details
BBP.Title = "Magic diamond"
BBP.Author = "Patrice Terrier"
BBP.Version = MAKDWD(1, 0) '// Version 1.0"
BBP.RenderTo = %BBP_OPENGL '// or %BBP_GDIPLUS, or %BBP
The kernell will use BBP.RenderTo to reset OpenGL, while switching from one plugin to another, and before it sends the BBP_INIT message.
'// Reset OpenGL plugin
SUB BBP_Reset()
LOCAL BBP AS BBPLUGIN
BBP.Msg = %BBP_CREATE
CALL BBP_Plugin(BBP)
IF BBP.RenderTo = %BBP_OPENGL THEN
CALL glDisable(%GL_BLEND)
CALL glDisable(%GL_TEXTURE_2D)
CALL glDisable(%GL_DEPTH_TEST)
END IF
END SUB
This is to avoid previous settings from one plugin to impact the others, for example with textures or blending mode etc.
I have added a new visual plugin that is very realistic...
It is an adaptation of a Delphi code written by Jan Horn (http://www.sulaco.co.za), the hard thing was to find a good way to synchronize the effect with audio. I hoppe you will like the result.
...
Beautiful Patrice!,
really nice and very smooth.
Just one question - which plugin sources use for Bass plugin creation now ?
Is First BassBox plugin (insight) (http://www.jose.it-berater.org/smfforum/index.php?topic=1389.msg4006#msg4006) still way to go ?
Thanks,
Petr
QuoteJust one question - which plugin sources use for Bass plugin creation now ?
The changes mainly concerned
BassBox itself, the plugins themselves are almost same.
Just use the lattest
BBPlugin.inc and tell BassBox that your plugin is for OpenGL using
BBP_RenderTo during the
BBP_CREATE message.
Quotereally nice and very smooth.
It looks even better when played full screen, I am using a dual monitor display and while BassBox is playing full screen on the 22", I feel like in a night club ;)
Try Firework with different type of audio files and see how it reacts to them, I would like to have more like this one :)
Very nice Patrice, I like the fireworks!!
Patrice,
Your new version has resolved the instability I was getting with the shaded polyhedra I am working on. And I am using your current Pixel Format Definition without any mods. There is a minor problem which happens when switching from fireworks to polyhedra. The polyhedra take on a fireworks texture!
I think this is a texture problem since my current model does not enable or disable textures, but does specify tex coordinates, so it is evidently grabbing onto the fireworks for some reason.
My visiting nine year old IT consultants think BassBox is very cool 8)
I've resolved the above problem - in my plugin:
BBP.RenderTo = %BBP_OPENGL '// or %BBP_GDIPLUS, or %BBP_DIRECTX
But BassBox was generating a GPF whenever it was terminated with my plugin. I traced the problem down to the %WM_DESTROY procedure in BassBox.bas and I think the safest fix is to ensure the Plugin is detached before the other resources are taken down and the Window destroyed.
CASE %WM_DESTROY
' // Detached active plugin
CALL BBP_LoadPlugin("")
...
One curious effect:
If you press the Alt key, the child controls on the BassBox are replaced with blank white spaces. This persists until a refresh is forced by covering BassBox with another window and then exposing it again. But After this is done, the Alt key effect does not re-occur.
Charles,
QuoteIf you press the Alt key, the child controls on the BassBox are replaced with blank white spaces.
I am very glad you found this one!(because I had the same problem on XP with PhotoComposer, that is a commercial project)
As usual
VISTA and
XP do not react the same, in such case.
When pressing
ALT key first time (and
only the first time)
VISTA just redraw a doted line arround the control that has the focus,
while
XP redraw all the child controls using the current XP style hover our nice skinned buttons.
Until I post a new patch,
here is the fix:
In
zSkin.inc add the constant: %WM_UPDATEUISTATE = &H0128
then in the
zImageButProc procedure add the %WM_UPDATEUISTATE message like this:
CASE %WM_UPDATEUISTATE
' // Avoid the defaut procedure to paint standard button window hover our skinned control
EXIT FUNCTION
That should solve the problem.
This is another good example showing that we must always check with different Windows version.
With Windows never assume that something working fine on a version will work the same on another ;)
...
This patch comprises the changes to fix the ALT key problem reported by Charles,
plus a few more backgrounds to play with :)
See below the attached BassPatch30.zip
...
This is an update for Plugin003.
It includes PLUGIN003.DLL and source code PLUGIN003a.bas and a folder containing a full set of Opengl INCLUDEs with MACROised constants. All of these go in the BBPLUGIN folder, overwriting the current PLUGIN003.DLL only.
As you will see, shading makes a big difference to the solidity of the polyhedra
I eventually traced the source of the instability I've encountered over the past few days to an Array boundary error in the lighting setup function. One of those bugs that lurk undetected in the code only to make their presence felt several programs later, causing strange and seemingly unrelated bugs.
The next stage is to introduce modulation of the lighting rather than the color of the objects, to get more subtle effects.
Charles,
Great work, thank you very much for this new version!!!
Right now, I am writing a generic BBP_CreateGLTextureFromFile to create on the fly, OpenGL compatible texture, from any of these graphic formats: BMP, DIB, GIF, ICO, JPG, JPEG, PNG, TIF (and whatever the size of the original file is).
Each texture will use full 32-bit ABGR color to support variable opacity like with PNG files.
...
Thanks Patrice.
This might be useful to you. It is the module I have been using on my other Opengl progs. As you can see I take a 256x256 thumbnail of the image and use that as the basis of the texture. This works fine for smallish areas. And you can also carry out any preprocessing of the colors at the same time as you do the RB pixel swap.
I use an array of dynamic strings mapref() to hold each of the converted pixmaps.
' ========================================================================================
' Retrieves the path of the calling process.
' ========================================================================================
TYPE colorARGB32
blue AS BYTE
green AS BYTE
red AS BYTE
alpha AS BYTE
END TYPE
UNION pix4
whole AS LONG
colors AS colorARGB32
END UNION
' ========================================================================================
FUNCTION SetTexture(biwidth AS LONG , biHeight AS LONG, ref AS LONG) AS LONG
DIM p AS BYTE PTR
p=STRPTR(pixmap(ref))
glBindTexture GL_TEXTURE_2D, mapref(ref) ' Bind Texture
glTexParameterf GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR
glTexParameterf GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_NEAREST
' target level components width height border format datatype ptr to image data
glTexImage2D GL_TEXTURE_2D, 0, 4, biWidth, biHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, @p
END FUNCTION
FUNCTION GDIP_GetTexMap (img AS STRING, ref AS LONG ) AS LONG
LOCAL hStatus AS LONG
LOCAL pBitmap AS LONG
LOCAL pStream AS LONG
LOCAL pStreamo AS LONG
LOCAL pThumb AS LONG
LOCAL strFileName AS STRING
LOCAL pix AS pix4
DIM thumf AS STRING:thumf=UCODE$("thumb.png")
DIM cParamList AS EncoderParameters
DIM cParam AS EncoderParameter
cParamList.Count=0
strFileName = UCODE$(img)
hStatus = GdipLoadImageFromFile(strFileName, pBitmap)
hStatus = GdipGetImageThumbnail ( pBitMap, 256, 256, pThumb, 0, 0 )
hStatus = GdipImageRotateFlip(pThumb,%RotateNoneFlipY) 'invert
DIM w AS LONG PTR
pixmap(ref)=NUL$(4*256*256)
w=STRPTR(pixmap(ref))
DIM x AS LONG, y AS LONG
FOR y=0 TO 255
FOR x=0 TO 255
GdipBitmapGetPixel(pThumb, x, y, pix.whole)
SWAP pix.colors.red, pix.colors.blue
@w=pix.whole: INCR w
NEXT
NEXT
SetTexture(256,256,ref)
IF pBitmap THEN GdipDisposeImage(pBitmap)
IF pThumb THEN GdipDisposeImage(pThumb)
FUNCTION = 1
END FUNCTION
Thank you Charles,
The one I have done (same as in GDImage) is able to use a picture from any size and create a texture of a specific square or rectangular size:
Note: The function below is not the final version, thus please wait until I post a new patch.
FUNCTION BBP_CreateGLTextureFromFile (zFullName AS ASCIIZ, Xin AS LONG, Yin AS LONG, PixelArray() AS BYTE)
LOCAL bi AS MYBITMAPINFO
LOCAL bm AS BITMAP
LOCAL fd AS WIN32_FIND_DATA
LOCAL pBits AS BYTE PTR
LOCAL hFind, So, K, hIC, hDC, hTmpDC, Img, imgW, imgH, xP, yP, xS, yS, hDIB, ARGBcolor AS LONG
LOCAL A, R, G, B AS BYTE, scale AS SINGLE, sDot AS STRING, graphics AS LONG
Xin = 0: Yin = 0: imgW = 0: imgH = 0
sDot = "."
' Check if file exist
So = INSTR(-1, zFullName, sDot)
IF So THEN
IF LEN(zFullName) THEN
hFind = FindFirstFile(zFullName, fd)
IF hFind <> -1 THEN
CALL FindClose(hFind)
ELSE
So = 0
END IF
END IF
END IF
IF So THEN
ImgType$ = UCASE$(MID$(zFullName, So)) + sDot
ImageType& = INSTR(".BMP.DIB.GIF.ICO.JPG.JPEG.PNG.TIF.TIFF.", ImgType$)
IF ImageType& THEN
' Load the image
IF GdipLoadImageFromFile((UCODE$(zFullName)), Img) = 0 THEN
' Get the image height and width
CALL GdipGetImageWidth(Img, imgW)
CALL GdipGetImageHeight(Img, imgH)
DIM P(1 TO 11) AS LONG
P(1)= 2: P(2) = 4: P(3) = 8: P(4) = 16: P(5) = 32: P(6) = 64: P(7) = 128: P(8)= 256: P(9) = 512: P(10) = 1024: P(11) = 2048
FOR K = UBOUND(P) TO LBOUND(P) STEP -1
IF Xin = 0 AND imgW > P(K) - 1 THEN Xin = P(K)
IF Yin = 0 AND imgH > P(K) - 1 THEN Yin = P(K)
NEXT
'IF DoNotSquareTexture(0,0) THEN
' CALL DoNotSquareTexture(0, 1)
'ELSE
' Xin = MAX&(Xin, Yin): Yin = Xin
'END IF
' Perform scale adjustment (zIconise(imgW, imgH, Xin, Yin, xP, yP, xS, yS))
' ------------------------------------------------------------------------
IF imgW THEN scale = Xin / imgW
IF scale > 1 THEN scale = 1
xS = imgW * scale: yS = imgH * scale
' In case Height > Yin compute new scale factor
IF yS > Yin THEN
IF imgH THEN scale = Yin / imgH
xS = imgW * scale: yS = imgH * scale
END IF
xP = (Xin - xS) \ 2: yP = (Yin - yS) \ 2
' ------------------------------------------------------------------------
hIC = CreateIC("DISPLAY", BYVAL 0, BYVAL 0, BYVAL 0)
hDC = CreateCompatibleDC(hIC)
bi.bmiHeader.biSize = SIZEOF(bi.bmiHeader)
bi.bmiHeader.biWidth = Xin
bi.bmiHeader.biHeight = Yin
bi.bmiHeader.biPlanes = 1
bi.bmiHeader.biBitCount = 32
bi.bmiHeader.biCompression = 0 ' %BI_RGB
hDIB = MyCreateDIBSection(hDC, bi, %DIB_RGB_COLORS, 0, 0, 0)
CALL SelectObject(hDC, hDIB)
' Draw image
IF GdipCreateFromHDC(hDC, graphics) = 0 THEN
' Set up stretching QualityMode
CALL GdipSetInterpolationMode(graphics, 2)
' Fill the background with color of pixel(0,0)
CALL GdipBitmapGetPixel(img, 0, 0, ARGBcolor)
CALL BBP_SplitColorARGB(ARGBcolor, A, R, G, B)
CALL GetObject(hDIB, SIZEOF(bm), bm)
pBits = bm.bmBits
FOR K = (Xin * Yin) TO 1 STEP - 1
@pBits[3] = A
@pBits[2] = R
@pBits[1] = G
@pBits[0] = B
pBits = pBits + 4
NEXT
' Draw image
IF GdipDrawImageRectRectI(graphics, img, _
xP, yP, xS, yS, _
0, 0, imgW, imgH, %UnitPixel, _
0) = 0 THEN ' This is an optional parameter
REDIM PixelArray(0 TO Xin * Yin * 4 - 1) AS BYTE
IF GetDIBits(hTmpDC, hDIB, 0, Yin, PixelArray(0), BYVAL VarPtr(bi), 0) THEN
' Perform Red and Green permutation
pBits = VARPTR(PixelArray(0))
FOR K& = (Xin * Yin) TO 1 STEP - 1
R? = @pBits[2]: @pBits[2] = @pBits[0]: @pBits[0] = R?: pBits = pBits + 4
NEXT
FUNCTION = -1 '// All went fine
END IF
END IF
' Cleanup
CALL GdipDeleteGraphics(graphics)
END IF
CALL GdipDisposeImage(img): img = 0
CALL DeleteObject(hDIB)
IF hDC THEN CALL DeleteDC(hDC)
IF hIC THEN CALL DeleteDC(hIC)
END IF
END IF
END IF
END FUNCTION
Hi,
new version of plugin looks very cool, good work !
Petr
Well I've got another one hear which uses light modulation, and several sources of light. Per object illumination its very useful to provide highlights.
The zip below contains PLUGIN003.DLL which overwrites the previous plgin003. Source code is also included as PLUGIN003b.bas but the opengl macro folder is not included this time, being the same as the previous.
Even better,
thanks for sharing!
Petr
This patch introduces a new
BBPlugin.inc with built-in
32-bit ABGR OpenGL texture builder.
The structure of the
BBPlugin folder now includes two special folders:
- BBPlugin\Include (put all include files there)
- BBPlugin\Texture (put all texture files there)
32-bit ABGR OpenGL textureBBPlugin.inc has a new procedure:
BBP_CreateGLTextureFromFile to create full 32-bit ABGR texture from any
.BMP .DIB .GIF .ICO .JPG. JPEG .PNG .TIF .TIFFif the size of the graphic source file doesn't match a ^2, then the procedure adjusts it, to match OpenGL requirement.
FUNCTION BBP_CreateGLTextureFromFile ( _zFullPath AS ASCIIZ, _ '// The graphic file that wil be used to create the texture.
BYREF Xin AS LONG, _ '// Return the width of the new texture
BYREF Yin AS LONG, _ '// Return the height of the new texture.
PixelArray() AS BYTE, _ '// Byte array that will store the new texture.
BYVAL SquareTexture AS LONG _'// %TRUE if you want to force texture creation to a square size.
) AS LONG
FUNCTION BBP_CreateGLTextureFromFile (zFullPath AS ASCIIZ, Xin AS LONG, Yin AS LONG, PixelArray() AS BYTE, BYVAL SquareTexture AS LONG) AS LONG
LOCAL bi AS MYBITMAPINFO, bm AS BITMAP
LOCAL pBits AS BYTE PTR, scale AS SINGLE
LOCAL K, xP, yP, xS, yS, So, hDIB, hFind, hIC, hDC, Img, imgW, imgH, ImgAttr AS LONG
LOCAL sImgName, sPathName AS STRING
LOCAL ARGBcolor AS LONG, A, R, G, B AS BYTE
Xin = 0: Yin = 0: imgW = 0: imgH = 0
' Make sure that a full path is being used.
sImgName = zFullPath
CALL BBP_SplitN(BBP_ExeName, sPathName, "")
IF INSTR(sImgName, sPathName) = 0 THEN sImgName = sPathName + sImgName
So = INSTR(-1, sImgName, $Dot)
IF So AND NOT BBP_Exist((sImgName)) THEN So = 0
IF So THEN
ImgType$ = UCASE$(MID$(sImgName, So)) + $Dot
ImageType& = INSTR(".BMP.DIB.GIF.ICO.JPG.JPEG.PNG.TIF.TIFF.", ImgType$)
IF ImageType& THEN
' Load the image
IF GdipLoadImageFromFile((UCODE$(sImgName)), Img) = 0 THEN
' Get the image height and width
CALL GdipGetImageWidth(Img, imgW)
CALL GdipGetImageHeight(Img, imgH)
DIM P(1 TO 11) AS LONG
P(1)= 2: P(2) = 4: P(3) = 8: P(4) = 16: P(5) = 32: P(6) = 64: P(7) = 128: P(8)= 256: P(9) = 512: P(10) = 1024: P(11) = 2048
FOR K& = UBOUND(P) TO LBOUND(P) STEP -1
IF Xin = 0 AND ImgW > P(K&) - 1 THEN Xin = P(K&)
IF Yin = 0 AND ImgH > P(K&) - 1 THEN Yin = P(K&)
NEXT
IF SquareTexture AND Xin <> Yin THEN
Xin = MAX&(Xin, Yin): Yin = Xin
ELSE
SquareTexture = 0
END IF
' Perform scale adjustment (zIconise(imgW, imgH, Xin, Yin, xP, yP, xS, yS))
' ------------------------------------------------------------------------
IF imgW THEN scale = Xin / imgW
IF scale > 1 THEN scale = 1
xS = imgW * scale: yS = imgH * scale
' In case Height > Yin compute new scale factor
IF yS > Yin THEN
IF imgH THEN scale = Yin / imgH
xS = imgW * scale: yS = imgH * scale
END IF
xP = (Xin - xS) \ 2: yP = (Yin - yS) \ 2
' ------------------------------------------------------------------------
hIC = CreateIC("DISPLAY", BYVAL 0, BYVAL 0, BYVAL 0)
hDC = CreateCompatibleDC(hIC)
bi.bmiHeader.biSize = SIZEOF(bi.bmiHeader)
bi.bmiHeader.biWidth = Xin
bi.bmiHeader.biHeight = Yin
bi.bmiHeader.biPlanes = 1
bi.bmiHeader.biBitCount = 32
bi.bmiHeader.biCompression = 0 ' %BI_RGB
hDIB = MyCreateDIBSection(hDC, bi, 0, 0, 0, 0)
CALL SelectObject(hDC, hDIB)
' Draw image
IF GdipCreateFromHDC(hDC, graphics&) = 0 THEN
' Set up stretching QualityMode
CALL GdipSetInterpolationMode(graphics&, 2)
' Fill the background with color of pixel(0,0)
IF SquareTexture THEN
CALL GdipBitmapGetPixel(img, 0, 0, ARGBcolor)
CALL BBP_SplitColorARGB(ARGBcolor, A, R, G, B)
CALL GetObject(hDIB, SIZEOF(bm), bm)
pBits = bm.bmBits
FOR K = (Xin * Yin) TO 1 STEP - 1
@pBits[3] = A
@pBits[2] = R
@pBits[1] = G
@pBits[0] = B
pBits = pBits + 4
NEXT
END IF
' We remove the magenta transparent color
'IF GdipCreateImageAttributes(ImgAttr) = 0 THEN
' DIM map(0 TO 1) AS COLORMAP
' map(0).cmFrom = %ZI_MAPCOLORFROM ' ZD_ColorARGB(255, RGB(128,127,128))
' map(0).cmTo = %ZI_MAPCOLORTO ' ZD_ColorARGB(255, RGB(128,128,128))
' map(1).cmFrom = ZD_ColorARGB(255, %ZD_TRANSCOLOR) ' &HFFFF00FF
' map(1).cmTo = ZD_ColorARGB(0, %ZD_TRANSCOLOR)
' CALL GdipSetImageAttributesRemapTable (ImgAttr, %ColorAdjustTypeBitmap, %TRUE, 2, map(0))
'END IF
' Draw image
IF GdipDrawImageRectRectI(graphics&, Img, _
xP, yP, xS, yS, _
0, 0, ImgW, ImgH, %UnitPixel, _
ImgAttr) = 0 THEN ' This is an optional parameter
bi.bmiHeader.biSize = SIZEOF(bi.bmiHeader)
bi.bmiHeader.biWidth = Xin
bi.bmiHeader.biHeight = Yin
bi.bmiHeader.biPlanes = 1
bi.bmiHeader.biBitCount = 32
bi.bmiHeader.biCompression = 0 ' %BI_RGB
REDIM PixelArray(0 TO Xin * Yin * 4 - 1) AS BYTE
IF GetDIBits(hDC, hDIB, 0, Yin, PixelArray(0), BYVAL VARPTR(bi), 0) THEN
' Perform Red and Green permutation
pBits = VARPTR(PixelArray(0))
FOR K = (Xin * Yin) TO 1 STEP - 1
R = @pBits[2]: @pBits[2] = @pBits[0]: @pBits[0] = R: pBits = pBits + 4
NEXT
FUNCTION = -1
END IF
END IF
' Cleanup
'IF ImgAttr THEN CALL GdipDisposeImageAttributes(ImgAttr)
CALL GdipDeleteGraphics(graphics&)
END IF
CALL DeleteObject(hDIB)
IF hDC THEN CALL DeleteDC(hDC)
IF hIC THEN CALL DeleteDC(hIC)
END IF
CALL GdipDisposeImage(Img): Img = 0
END IF
END IF
END FUNCTION
Note: A texture is not limited to square size, you can
create a rectangular one as well.
Texture width and height can be any combination of these (in pixel):
2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048.Because the texture are 32-bit ABGR (Alpha, Blue, Green, Red) they can be used to produce progressive opacity,
Thus I am looking forward to see more plugins using it ;)
The latest PolyHedra which uses light modulation has been added as plugin #5. (Thank you Charles!)
See below
BassPatch31.zip...
Gets better and betters guys, thanks for all the work!!
This version of BassBox brings up two new important features:
1 - FFT support
FFT is widely used to perform visual audio sound representation, and BassBox makes it simple to use.
In the BBPLUGIN structure there are two new members for that purpose:
FFTdata AS DWORD '// DWORD pointer to the FFT() AS SINGLE array.
FFTsize AS WORD '// Size of the FFT array.
and to use it inside of your plugin, you just need to get the data during the %BBP_RENDER message, like this:
'// This is where the magic happens:
'// BBP.FFTsize returns a pointer to an area of memory containing an array of 256 singles.
'// This is then mapped to the fft() array where it can be accessed.
DIM fft(BBP.FFTsize) AS SINGLE AT BBP.FFTdata
DIM SoundBuffer(BBP.FFTsize) AS SINGLE
2 - Mouse support
BassBox, allows you handle ALL the mouse messages occuring inside of the OpenGL control.
In the BBPLUGIN structure there are three new members for that purpose:
WinMsg AS LONG '// True Windows message.
wParam AS LONG '// wParam
lParam AS LONG '// lParam
And there is a new %BBP_MOUSE message that you handle in your plugin like this:
CASE %BBP_MOUSE
'// Handle all Windows mouse messages there
Msg = BBP.WinMsg: wParam = BBP.wParam: lParam = BBP.lParam
SELECT CASE LONG Msg
CASE %WM_MOUSEMOVE
x = LO(WORD, lParam): y = HI(WORD, lParam)
IF MDown = %MK_LBUTTON THEN
Cy = Cy + (x - Mx)
Cx = Cx + (y - My)
IF Cy < -90 THEN Cy = -90
IF Cy > 90 THEN Cy = 90
ELSEIF MDown = %MK_RBUTTON THEN
Cy = Cy + (x - Mx)
Cz = Cz + (y - My)
END IF
Mx = x: My = y
CASE %WM_LBUTTONDOWN, %WM_RBUTTONDOWN ', %WM_MBUTTONDOWN, %WM_XBUTTONDOWN
Mx = LO(WORD, lParam): My = HI(WORD, lParam)
IF wParam = %MK_LBUTTON OR wParam = %MK_RBUTTON THEN MDown = wParam
CASE %WM_LBUTTONUP, %WM_RBUTTONUP ', %WM_MBUTTONUP, %WM_XBUTTONUP
MDown = 0
'CASE %WM_LBUTTONDBLCLK, %WM_RBUTTONDBLCLK ', %WM_MBUTTONDBLCLK, %WM_XBUTTONDBLCLK
'CASE %WM_MOUSEWHEEL
END SELECT
And to show you everything in context, I have added a new visual plugin: Magic spectrum
Magic spectrum uses the left mouse button to change the camera angle, and the right mouse button to zoom in out.
Screen shot:
(http://www.zapsolution.com/pictures/sdk/bassbox.jpg)
And YES, it is always coming better ;D
See below BassPatch32.zip
...
I don't know what to say,
this is very cool again ;D
Just one issue - when I select one of Charles's plugins and move mouse to area where visualisation is rendered, that objects immediately disappear.
Bye,
Petr
QuoteJust one issue - when I select one of Charles's plugins and move mouse to area where visualisation is rendered, that objects immediately disappear.
This is because
I forget to recompile Charles's ;)
The solution: either
recompile the plugins yourself or
download the zip file again (it has been updated).
...
Patrice, Here is an updated plugin005 that maintains the correct aspect ratio when BassBox is stretched. It also contains a replacement for plugin 003 (003c) which uses the wood texture included.
The new 003, as you will see causes a slight problen with your excellent fireworks and fft plugins. It causes the particle textures to become enlarged, and is triggered when I setup the texture for 003 just after getting the the image. Some of the texture parameters seem to persist, and may not be respecified when your plugins bind their textures.
Charles,
Please use "\" anti-slash instead of slash "/" to specify the folder name path, because I am using "\" to parse them, thank you.
I don't know what is the OpenGL parameter you are using that is causing havoc with other plugins.
The solution would be to reset everything to default, when switching from one plugin to another, however I don't know all the OpenGL settings that should be turned off.
Could you help on this?
The place where to reset the code in BassBox is there:
'// Reset OpenGL plugin
SUB BBP_Reset()
LOCAL BBP AS BBPLUGIN
BBP.Msg = %BBP_CREATE
CALL BBP_Plugin(BBP)
IF BBP.RenderTo = %BBP_OPENGL THEN
CALL glDisable(%GL_BLEND)
CALL glDisable(%GL_TEXTURE_2D)
CALL glDisable(%GL_DEPTH_TEST)
END IF
END SUB
Star Orion plays nicely and looks great with the newest plugin, really nice, thanks!!
Hi Patrice,
No, reseting those things did not work. And I have also made my texture binding identical to yours - using the same Opengl calls and settings
It's something quite subtle - corruption of texture mapping in some way. If I dont delete my texture, it shows up in your fireworks, so you get panels of wood instead of starry particles. But since you delete your texture ref before generating the texture, that should not happen anyway. But clicking a second time on 004 clears the problem.
A good night's sleep is needed.
Enjoyed Star Orion v. much. Great music.
Got it!
By pretending to go to bed, I caught the Gremlins off guard.
It seems you are getting a spurious error when you bind the texture. (I think you can disregard these errors except for diagnostics during coding).
This is my hack for PLUG004 and PLUG006, but you may want to leave off the error checking completely.
SUB MakeFireworksTexture
LOCAL nRet AS LONG
DIM Texture(0) AS STATIC LONG
REDIM PixelArray(0) AS BYTE
IF BBP_CreateGLTextureFromFile($BBP_PLUGIN_FOLDER + "Texture\particle.bmp", xSize&, ySize&, PixelArray(), 1) THEN
CALL glDeleteTextures(1, Texture(0))
CALL glGenTextures(1, Texture(0)): nRet = glGetError()
IF nRet = 0 THEN CALL glBindTexture(%GL_TEXTURE_2D, Texture(0)): nRet = glGetError()
nret=0 ' SUPPRESS THIS ERROR
IF nRet = 0 THEN CALL glTexParameteri(%GL_TEXTURE_2D, %GL_TEXTURE_MAG_FILTER, %GL_LINEAR): nRet = glGetError()
IF nRet = 0 THEN CALL glTexParameteri(%GL_TEXTURE_2D, %GL_TEXTURE_MIN_FILTER, %GL_LINEAR): nRet = glGetError()
IF nRet = 0 THEN CALL glTexImage2D(%GL_TEXTURE_2D, 0, 4, xSize&, ySize&, 0, %GL_RGBA, %GL_UNSIGNED_BYTE, PixelArray(0)): nRet = glGetError()
END IF
END SUB
This version allows you to create audio play list using the reserved ".bbp" extension.
A "bbp" play list is just a standard ascii text file where each line does match a specific audio file name (must be a full qualified path name).
As an extra bonus you can embed streaming audio URL into a "bbp" play list.
There is an example of bbp file into the BassBox folder and its name is "BassBox.bbp"
http://media.audiofanzine.com/compos/176294/spookyman-Summer_Games.mp3
http://media.audiofanzine.com/compos/322635/daniga-Astral_Motion.mp3
http://samueldequidt.free.fr/SOLARIS/SOLARIS.mp3
http://media.audiofanzine.com/compos/51433/Magic_Pascal-Magik_Sound.mp3
http://media.audiofanzine.com/compos/353134/peaktrance-ElectronicMusic.mp3
Note: You can mix URL and local audio files altogether into the same play list.
When using URL it is better to use a fast DSL connection to avoid lags while playing audio.
In the provided play list "SUMMER GAMES PART.1" is my favorite audio file, better to play it with the "Magic spectrum"
And if you are good guys, then, perhaps, I will add another extra function to save the result of the streamed audio file into a local folder, perhaps ;)
See below BassPatch32.zip
...
Patrice that is great, I just dragged the playlist bpp file and away we go, sights, sound and eye candy, thanks really really nice!!
-- Charles,QuoteBy pretending to go to bed, I caught the Gremlins off guard.
I found myself that in "plug003c.bas" removing
glDisable(GL_TEXTURE) and
glEnable(GL_TEXTURE) and using only
glDisable(GL_TEXTURE_2D) and
glEnable(GL_TEXTURE_2D) solved the problem.
Also it would be better to use this procedure to create the texture:
SUB MakeTexture(zPathToTexture AS ASCIIZ)
LOCAL nRet, xSize, ySize AS LONG
DIM Texture(0) AS STATIC LONG
REDIM PixelArray(0) AS BYTE
IF BBP_CreateGLTextureFromFile(zPathToTexture, xSize, ySize, PixelArray(), 1) THEN
CALL glDeleteTextures(1, Texture(0))
CALL glGenTextures(1, Texture(0)): nRet = glGetError()
IF nRet = 0 THEN
CALL glBindTexture(GL_TEXTURE_2D, Texture(0))
CALL glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
CALL glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
CALL glTexImage2D(GL_TEXTURE_2D, 0, 4, xSize, ySize, 0, GL_RGBA, GL_UNSIGNED_BYTE, PixelArray(0))
END IF
END IF
END SUB
And change your
plug003c.bas source code to this (while removing glDisable(GL_TEXTURE))
CASE %BBP_INIT
CALL BBP_SplitColorARGB(BBP.BackARGB, A?, R?, G?, B?)
Alpha! = A? + 1: Red! = R? + 1: Green! = G? + 1: Blue! = B? + 1
CALL glClearColor(Red! / 256, Green! /256, Blue! / 256, Alpha! / 256)
CALL setup_polyhedron_povray (1, "BBPlugin\Include\geo.inc", 1)
' default material
DIM ambi(3) AS STATIC GLfloat: ambi(0)=0.5:ambi(1)=0.5:ambi(2)=0.5:ambi(3)=1.0
DIM diff(3) AS STATIC GLfloat: diff(0)=1.0:diff(1)=1.0:diff(2)=1.0:diff(3)=1.0
DIM spec(3) AS STATIC GLfloat: spec(0)=1.0:spec(1)=1.0:spec(2)=1.0:spec(3)=1.0
DIM emis(3) AS STATIC GLfloat: emis(0)=1.0:emis(1)=1.0:emis(2)=1.0:emis(3)=1.0
DIM shine(0) AS STATIC GLfloat: shine(0)=0 ' larger number = smaller more concentrated
glShadeModel GL_SMOOTH 'Enable Smooth Shading
glClearDepth 1.0 'Depth Buffer Setup
glEnable GL_DEPTH_TEST 'Enables Depth Testing
glDepthFunc GL_LEQUAL 'The Type Of Depth Testing To Do
glHint GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST 'Really Nice Perspective Calculations
'glEnable GL_LIGHTING 'Enable Lighting
glEnable GL_COLOR_MATERIAL 'Enable Coloring Of Material
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) 'Enable Alpha Blending
glEnable(GL_BLEND) 'Enable Blending
glEnable(GL_ALPHA_TEST) 'Enable Alpha Testing
glAlphaFunc(GL_ALWAYS,0.0) 'Set Alpha Testing
'glEnable(GL_CULL_FACE) 'Remove front or Back Face
CALL ColorInit()
glEnable GL_TEXTURE_2D
CALL MakeTexture ($BBP_PLUGIN_FOLDER + "Texture\mask72.jpg")
I forget to tell you that when you perform audio streaming, you can use either "http://" or "ftp://" and the next patch will also handle the use of either "\" or "/" to parse the full path name ( hello Charles ;) ).
In the next patch I plan also to add a new folder named "NetCapture" where audio files streamed from the Internet will be saved while you play them on line. They will be saved under the same name as the original streamed audio file, using the same audio format file extension.
Then you will be further able to play them without lags, if you are using a low rate SDL connection.
Hi Patrice,
this news sound exciting again.
After long period I had time to look in detail how plugin SDK is done for BassBox, and I must say it is exactly what I think is needed.
I have two ideas for plugin now, so hope I will get time to realise them :D
Petr
Many thanks Patrice, using GL_TEXTURE_2D instead of GL_TEXTURE to enable and disable textures, has resolved another problem I was having with spinning flares, where the texture is temporarily disabled.
I'll be using several textures so I can adopt and adapt ypur CreateGLTextureFromFile procedure, assuming it's ok to leave the textures in place until they are redefined.
As for accommodating "/" as well as "\", you are half way to Linux. :)
The FFT data is very exciting, I would like to create a sonic landscape, but that is going to be quite an intricate thing to do well.
Petr I look forward to seeing some more of your creations.
Here is the BassBox NET capture version that saves streamed audio files into the new "NetCapture\" folder.
See below last BassPatch34.zip
...
--Charles
Suggestion for multiple textures creation:
TYPE ZGLTEXTURE
ID AS LONG
FullName AS ASCIIZ * 260
Texture AS LONG
END TYPE
FUNCTION SetMutipleGLTexture (BYVAL ztp AS ZGLTEXTURE PTR, BYVAL N AS LONG) EXPORT AS LONG
LOCAL mtCount, K, Ret, nCount AS LONG
'*'STATIC sTexture AS STRING
DIM mt(1 TO N) AS ZGLTEXTURE AT ztp
mtCount = UBOUND(mt()) - LBOUND(mt()) + 1
IF mtCount THEN
'*'IF LEN(sTexture) THEN
'*' nCount = PARSECOUNT(sTexture)
'*' DIM T(1 TO nCount) AS LONG
'*' FOR K = 1 TO nCount: T(K) = VAL(PARSE$(sTexture, K)): NEXT
'*' CALL glDeleteTextures(nCount, T(1))
'*' ERASE T()
'*'END IF
DIM Texture(1 TO mtCount) AS LONG
CALL glGenTextures(mtCount, Texture(1)): Ret = glGetError
'*'sTexture = ""
IF Ret& = 0 THEN
FOR K = 1 TO mtCount
REDIM PixelArray(0) AS BYTE
IF BBP_CreateGLTextureFromFile(zPathToTexture, xSize, ySize, PixelArray(), 1) THEN
mt(k).Texture = Texture(K)
'*'sTexture = sTexture + LTRIM$(STR$(Texture(K))) + ","
CALL glBindTexture(%GL_TEXTURE_2D, Texture(K)): Ret = glGetError
IF Ret& = 0 THEN CALL glTexParameteri(%GL_TEXTURE_2D, %GL_TEXTURE_MAG_FILTER, %GL_LINEAR): Ret = glGetError
IF Ret& = 0 THEN CALL glTexParameteri(%GL_TEXTURE_2D, %GL_TEXTURE_MIN_FILTER, %GL_LINEAR): Ret = glGetError
IF Ret& = 0 THEN CALL glTexImage2D(%GL_TEXTURE_2D, 0, 4, xSize&, ySize&, 0, %GL_RGBA, %GL_UNSIGNED_BYTE, PixelArray(0)): Ret = glGetError
FUNCTION = Ret&
END IF
NEXT
END IF
END IF
END FUNCTION
Quote from: Patrice Terrier on November 01, 2007, 09:58:17 PM
This version allows you to create audio play list using the reserved ".bbp" extension.
Wikipedia (http://en.wikipedia.org/wiki/Alphabetical_list_of_file_extensions) just heard that, and File Extension Seeker (http://file-extension.net/seeker) too! :)
http://file-extension.net/seeker/file_extension_bbp
Bye!
Patrice
Re: Suggestion for multiple textures creation:
I think it may be better to keep our options open and handle Opengl directly, for max flexibility. I find that creating 3d scenes is more like painting than coding. So most of it gets developed inline and functions / subroutines are only deployed to avoid repetition, and keep the code to a manageable size. The coding style is almost the opposite of systems programming.
If most of the code is in pure Opengl it is easier to transfer and share, even between different host languages, which is why I am using a MACROised Opengl header to avoid '%' markers everywhere.
--Marco
I know you wont miss that one :)
--Charles
As I said, it was just a suggestion, but of course do it as you are more comfortable with.
Here is a new BassBox plugin entitled "Laser borealis".
This one is also FFT based, it comes along with a new BBPlugin.inc, that provides support for OpenGL fonts.
FUNCTION BBP_DefaultFont() AS LONG
STATIC hDefault AS LONG
IF hDefault = 0 THEN hDefault = GetStockObject(12) ' %ANSI_VAR_FONT
FUNCTION = hDefault
END FUNCTION
SUB BBP_BuildGLfont (BYVAL hDC AS LONG, UseFont AS ZGLFONT)
LOCAL OldFont AS LONG, lpSize AS SIZEL, hFont AS LONG, LenFontName AS LONG
UseFont.charStart = 32
UseFont.charNum = 96
UseFont.fontBase = glGenLists(UseFont.charNum) ' Storage For 96 Characters
LenFontName = LEN(UseFont.fontName)
IF hDC = 0 THEN LenFontName = 0
IF LenFontName THEN
IF UseFont.fontHeight < 1 THEN UseFont.fontHeight = 10
UseFont.fontHeight = -1 * (UseFont.fontHeight * GetDeviceCaps(hDC, 90)) \ 72
IF UseFont.fontWeight = 0 THEN UseFont.fontWeight = %FW_BOLD
hFont = CreateFont(UseFont.fontHeight, _ ' Height Of Font
0, _ ' Width Of Font
0, _ ' Angle Of Escapement
0, _ ' Orientation Angle
UseFont.fontWeight, _ ' Font Weight
0, _ ' Italic
0, _ ' Underline
0, _ ' Strikeout
0, _ ' %ANSI_CHARSET Character Set Identifier
%OUT_TT_PRECIS, _ ' Output Precision
0, _ ' %CLIP_DEFAULT_PRECIS Clipping Precision
%ANTIALIASED_QUALITY, _ ' Output Quality
0, _ ' %FF_DONTCARE OR %DEFAULT_PITCH Family And Pitch
UseFont.fontName) ' Font Name
ELSE
hFont = BBP_DefaultFont()
END IF
IF hFont THEN
OldFont = SelectObject(hDC, hFont) ' Selects our font
' Builds 96 Characters Starting At Character 32
CALL wglUseFontBitmaps(hDC, UseFont.charStart, UseFont.charNum, UseFont.fontBase)
' Get font height
CALL GetTextExtentPoint32(hDC, "W", 1, lpSize)
UseFont.fontHeight = lpSize.cy
CALL SelectObject(hDC, oldfont) ' Restore previous selected font
IF LenFontName THEN UseFont.fontHandle = hFont ' Save the Win32 font handle
END IF
END SUB
SUB BBP_DeleteGLFont (UseFont AS ZGLFONT)
IF UseFont.fontBase THEN
CALL glDeleteLists(UseFont.fontBase, UseFont.charNum) ' Delete All 96 Characters
IF UseFont.fontHandle THEN DeleteObject(UseFont.fontHandle) ' The Win32 font handle
END IF
END SUB
SUB BBP_DrawGLText (BYVAL glWnd AS LONG, UseFont AS ZGLFONT, BYVAL x AS LONG, BYVAL y AS LONG, zTxt AS ASCIIZ, BYVAL ARGB AS LONG)
LOCAL rc AS RECT, A, R, G, B AS BYTE, Alpha, Red, Green, Blue AS SINGLE, WasTexture, WasLighting AS LONG
CALL GetClientRect(glWnd, rc)
WasTexture = glIsEnabled(%GL_TEXTURE_2D)
IF WasTexture THEN CALL glDisable(%GL_TEXTURE_2D) ' Turn off textures, didn't want our text textured
WasLighting = glIsEnabled(%GL_LIGHTING)
IF WasLighting THEN CALL glDisable(%GL_LIGHTING) ' Disable Lighting
CALL glMatrixMode(%GL_PROJECTION)
CALL glPushMatrix()
CALL glLoadIdentity()
CALL glOrtho(0.0, rc.nRight, 0.0, rc.nBottom, -1.0, 1.0)
CALL glMatrixMode(%GL_MODELVIEW)
CALL glPushMatrix()
CALL glLoadIdentity()
' Set color
CALL BBP_SplitColorARGB(ARGB, A, R, G, B)
Alpha = A + 1: Red = R + 1: Green = G + 1: Blue = B + 1
CALL glColor3f(Red / 256, Green / 256, Blue / 256)
' Set X,Y location
CALL glRasterPos2i(x, rc.nBottom - (UseFont.fontHeight - 4) - y)
' Draw the text
CALL glPushAttrib(%GL_LIST_BIT) ' Pushes The Display List Bits
CALL glListBase(UseFont.fontBase - UseFont.charStart)' Sets The Base Character to 0
CALL glCallLists(LEN(zTxt), %GL_UNSIGNED_BYTE, zTxt) ' Draws The Display List Text
CALL glPopAttrib() ' Pops The Display List Bits
CALL glPopMatrix()
CALL glMatrixMode(%GL_PROJECTION)
CALL glPopMatrix()
CALL glMatrixMode(%GL_MODELVIEW)
IF WasTexture THEN CALL glEnable(%GL_TEXTURE_2D) ' Enable texture mode
IF WasLighting THEN CALL glEnable(%GL_LIGHTING) ' Enable Lighting
CALL glColor3f(1, 1, 1) ' Back to default color
END SUB
To use the OpenGL font in your own plugin, add this at the end of the BBP.Init section:
UseFont.fontName = "Arial"
UseFont.fontHeight = 10
UseFont.fontWeight = %FW_BOLD
CALL BBP_BuildGLfont(BBP.DC, UseFont) ' Build OpenGL font for our OpenGL window
A few minor changes have also been done into BassBox itself, to accommodate the use of OpenGL fonts.
Note: in order to play "Laser borealis" in full screen, you must have a good grahic card and enable the OpenGL wait for vertical retrace mode.
Try this plugin with different audio style to see how it renders each of them.
Also try with these CX, CY, CZ values:
CX -316, CY -176, CZ -2
CX -143, CY -577, CZ -8
The default value is: CX -128, CY -235, CZ -18
Enjoy 8)
See below BassPatch35.zip
...
Patrice, how about making the keyboard available to Plugins, like the BBmouse. All we need is the WM_KEYDOWN and WM_KEYUP messages. This will allow the Plugin to capture any combination of key states into a table as well as detecting individual keystrokes.
-- Charles
Keyboard is already on my list, but because it is easy for me to add it, I did first the hard things ;)
...
Patrice,
that is cool plugin again!
I attach here slightly tweaked version - why ask users to bother with driver and turn V-Sync on manually ? ;)
We can do it via extension ( but safely ). When plugin is de-initialized it will turn V-Sync off again.
wglGetProcAddress will give us the magic key ( pointer to proc ) to wglSwapIntervalEXT. It is safe to use, as implemented even on very old systems. In worst case it simply won't turn V-Sync on, if hardware/OS fails to support it.
It is fact plugin 007 is quite fillrate killer, I would not like to see it on Intel onboard beasts :-X
As the rendering is blending based, you really need faster card. But major slow down should be noticable only in case you look at angle, when all particles are in row.
Bye,
Petr
Stick Dance
Here is a replacement for PLUG003 including a wood texture to drop into the Texture file.
Petr,
Thank you for the tip!
I didn't know it.
...
--Charles
Thank you for the update of plug003, it will be put in the next patch, the one with Keyboard support ;)
Nice Charles,
it is hypnotizing scene!
Petr
I don't know why, but the new plug003 makes me think to alloween, perhaps related to this period of the year ;D
Thank you both. Already there is a wealth of material in all the plugins, so I hope we will be able to establish some interesting cross-breeds and encourage others to join in.
This is the BassBox version with Plugin keyboard support.
BassBox kernell GLWindowProc
FUNCTION GLWindowProc (BYVAL hWnd AS LONG, BYVAL Msg AS LONG, BYVAL wParam AS LONG, BYVAL lParam AS LONG) EXPORT AS LONG
LOCAL hResource AS LONG, ps AS PAINTSTRUCT, rc AS RECT
LOCAL BBP AS BBPLUGIN
SELECT CASE LONG Msg
CASE %WM_ERASEBKGND
FUNCTION = 1: EXIT FUNCTION
CASE %WM_KEYDOWN TO %WM_UNICHAR
BBP.Msg = %BBP_KEYBOARD
BBP.WinMsg = Msg
BBP.wParam = wParam
BBP.lParam = lParam
CALL BBP_Plugin(BBP)
CASE %WM_MOUSEMOVE TO %WM_XBUTTONDBLCLK
BBP.Msg = %BBP_MOUSE
BBP.WinMsg = Msg
BBP.wParam = wParam
BBP.lParam = lParam
CALL BBP_Plugin(BBP)
CASE %WM_PAINT
CALL BeginPaint(hWnd, ps)
CALL EndPaint(hWnd, ps)
FUNCTION = 0: EXIT FUNCTION
END SELECT
FUNCTION = DefWindowProc (hWnd, Msg, wParam, lParam)
END FUNCTION
And it is up to you to handle the %BBP_KEYBOARD message in your plugin.
CASE %BBP_KEYBOARD
'// Handle all Windows keyboard messages there
Msg = BBP.WinMsg: wParam = BBP.wParam: lParam = BBP.lParam
SELECT CASE LONG Msg
CASE %WM_KEYDOWN
CASE %WM_KEYUP
END SELECT
See below BassPatch36.zip
...
I love seeing all these updates, thanks Guys great Job !!!
I hope someday to add a plug in, but still got a lot to learn. Till then really enjoy what all you guys are doing.
Do you remember AMIGA's time?
Then you will enjoy this new version of BassBox that provides full support for SoundTracker audio files:
IT / XM / S3M / MTM / MOD / UMX / MO3
To try it, drag the provided "BackToRoots.mod" either on the BassBox desktop icon or on the player if it is already running.
If anyone here has a server with some free space on it, then I could upload my private SoundTracker collection there?
By the way you can find many places over the NET where you can download mega bytes of them.
See below the attached BassPatch37.zip
...
The mod format is so nice, perfect for size to quality. I don't know why we don't see it being used these days. I still think it is more than adequate as a music file format for so many situations. Do any of you guys recommend a good Mod Creation program? I want to make music for use in games and even compared to mp3's you can get so much music for so little space.
--Kent
Search for MODPlug Tracker
http://downloads.sourceforge.net/modplug/OpenMPT-1.17.02.48.zip?modtime=1180288977&big_mirror=0 (http://downloads.sourceforge.net/modplug/OpenMPT-1.17.02.48.zip?modtime=1180288977&big_mirror=0)
...
Here is a replacement for Plugin005, making use of Patrice' mouse, keyboard and fft extensions.
Use the mouse to change the orientation (left button) and distance (right button) of the circles.
The space bar will reset the orientation of the circles. (PS: but only on single tracks so I'll use another key next time)
--Charles,
Please use the MakeTexture procedure below, to create the texture and to be more cooperative with other plugins.
SUB MakeTexture(zPathToTexture AS ASCIIZ)
LOCAL nRet, xSize, ySize AS LONG
DIM Texture(0) AS STATIC LONG
REDIM PixelArray(0) AS BYTE
IF BBP_CreateGLTextureFromFile(zPathToTexture, xSize, ySize, PixelArray(), 1) THEN
CALL glDeleteTextures(1, Texture(0))
CALL glGenTextures(1, Texture(0)): nRet = glGetError()
IF nRet = 0 THEN
CALL glBindTexture(GL_TEXTURE_2D, Texture(0))
CALL glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
CALL glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
CALL glTexImage2D(GL_TEXTURE_2D, 0, 4, xSize, ySize, 0, GL_RGBA, GL_UNSIGNED_BYTE, PixelArray(0))
END IF
END IF
END SUB
and use it like this is the %BBP_INIT message
CALL ColorInit()
glEnable GL_TEXTURE_2D
CALL MakeTexture ($BBP_PLUGIN_FOLDER + "Texture\mask72.jpg")
And if you want to handle keyboard messages, then you should put the focus onto the OpenGL control, when the user click on the left mouse button, because the Kernell doesn't do it.
[PseudoCode]
IF LeftMouseButtonDown and GetFocus <> BBP.ParentWindow THEN SetFocus(BBP.ParentWindow)
[/PseudoCode]
Patrice,
I will adopt the technique of pre-deleting the texture list before setting up new ones. Like you do. But in this case the disturbance was caused by using
glTexParameteri GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_NEAREST
putting it back to:
glTexParameteri GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR
fixes the problem but you get more texture scaling artefacts.
None of the keyboard messages seem to be getting through to the %BBP_KEYBOARD, though the spacebar will sometimes reinitialise the Plugin (which gave me the impression it was working). I will trace through the message processing to see where the blockage might be. I have tried SETFOCUS as you suggested but I don't think that is the problem.
Very interesting:
I find that %WM_KEYDOWN is correctly received in the WINMAIN message loop but does not get passed to WNDPROC.
One reason is because it is treated as a dialog message and skips.
But to remove this obstacle is not enough to reach GLWindowProc. So I think its getting lost somewhere in the Bassbox/zskin architecture.
PS: the %WM_KEYDOWN message does noy reach WNDPROC either.
WHILE GetMessage(Msg, %NULL, 0, 0) ' SK_MILLISECOND
'IF IsDialogMessage(hMain, Msg) = %FALSE THEN
IsDialogMessage(hMain, Msg)
if Msg.message=%WM_KEYDOWN then msgbox "keydown"
CALL TranslateMessage(Msg)
CALL DispatchMessage(Msg)
'END IF
WEND
-- Charles
I shall take care of this into the next build.
First I will put the focus myself onto the OpenGL control, each time the user select a new plugin, and I shall also restore the focus in case of WM_LBUTTONDOWN if it is not set already.
All keyboard messages are now redirected to the Plugin control when it has the focus.
hCtrl = zGetMainItem(%ID_OpenGL)
CALL SetTimer(hMain, %OPENGL_TIMER, 0, %NULL)
WHILE GetMessage(Msg, %NULL, 0, 0) ' SK_MILLISECOND
IF GetFocus() = hCtrl AND (Msg.message > 255 AND Msg.message < 266) THEN
CALL TranslateMessage(Msg)
CALL DispatchMessage(Msg)
ELSE
IF IsDialogMessage(hMain, Msg) = %FALSE THEN
CALL TranslateMessage(Msg)
CALL DispatchMessage(Msg)
END IF
END IF
WEND
CALL KillTimer(hMain, %OPENGL_TIMER)
See below attached BassPatch38.zip
...
Hi guys,
few tips on texture quality - mipmaps look good, but with LINEAR in both parameters, like this:
Quote
glTexParameteri %GL_TEXTURE_2D, %GL_TEXTURE_MAG_FILTER, %GL_LINEAR
glTexParameteri %GL_TEXTURE_2D, %GL_TEXTURE_MIN_FILTER, %GL_LINEAR_MIPMAP_LINEAR
gluBuild2DMipmaps %GL_TEXTURE_2D, dataType, xSize, ySize, %GL_RGBA, %GL_UNSIGNED_BYTE, PixelArray(0)
This kind of mipmapping is often ( I think a bit oddly ) called "trilinear filtering". It is the best you can get from old graphic cards.
And that means there must be some better way ? Of course - anisotropic filtering.
Mip mapping + linear filter is good, but kind of blur textures at sharp angles too much, thats because as a base it takes textures which are filtered linearly.
Anisotropic filtering keeps all relatively sharp, to eliminate "pixelisation" we will combine it with classic mipmapping to get the best filtering currently available.
So how to put that marvel on :D ?
Via extension again.
Use this in your initialisation:
Quote
GLOBAL texture_AnisotropyAllowed AS BYTE
GLOBAL texture_AnisotropyMax AS SINGLE
LOCAL OpenGLInfoPTR AS DWORD
LOCAL OpenGLExtensions AS STRING
' -- Get list of available extensions
OpenGLInfoPTR = glGetString(%GL_EXTENSIONS)
OpenGLExtensions = UCASE$(PEEK$(ASCIIZ, OpenGLInfoPTR, 262144))
' -- Test whether we can use it
IF INSTR( OpenGLExtensions, "GL_EXT_TEXTURE_FILTER_ANISOTROPIC " ) THEN
texture_AnisotropyAllowed = 1
' -- If yes, lets get maximum level of anisotrpy available
glGetFloatv(%GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, texture_AnisotropyMax )
ELSE
texture_AnisotropyAllowed = 0
texture_AnisotropyMax = 0
END IF
What is anisotropy level ? It is number determining number of samples involved in calculation - higher number, higher quality but more power demanding.
So when loading texture I do something like following for my TBGL thinBASIC module for graphics: if anisotropy is supported and I want it, go for it.
If not then do classic mipmapping, as it is best old hardware can do. Also good to check AnisoFactor does not exceed maximum level of anisotropy hardware offer.
Code for anisotropy is here:
Quote
glTexParameteri %GL_TEXTURE_2D, %GL_TEXTURE_MAG_FILTER, %GL_LINEAR
glTexParameteri %GL_TEXTURE_2D, %GL_TEXTURE_MIN_FILTER, %GL_LINEAR_MIPMAP_LINEAR
IF texture_AnisotropyAllowed THEN glTexParameterf(%GL_TEXTURE_2D, %GL_TEXTURE_MAX_ANISOTROPY_EXT, AnisoLevel)
gluBuild2DMipmaps %GL_TEXTURE_2D, dataType, xSize, ySize, %GL_RGBA, %GL_UNSIGNED_BYTE, PixelArray(0)
Where AnisoLevel could be 1, 4, 8, 16 ... up to
texture_AnisotropyAllowed .
As you can see, it is quite a mutant composed from linear, aniso and mipmap techniques, but it really looks good :)
I attached picture so you can see the diffffference ( as says G-Man from half life 2 :) ).
On static picture mipmapping looks like a terrible one, but first two filters cause quite disturbing noise in the picture when animated.
Bye,
Petr
Petr,
What about a working example?
;)
...
Just tried your new patch Patrice. Thanks. But keyboard messages of any sort are still not getting through. I think it may be a deeper seated problem than focus. When I press any key, it goes 'plunk'.
CASE %BBP_KEYBOARD
'// Handle all Windows keyboard messages there
Msg = BBP.WinMsg: wParam = BBP.wParam: lParam = BBP.lParam
SELECT CASE LONG Msg
MSGBOX HEX$(wParam)+" any"
CASE %WM_KEYDOWN
IF (wParam AND 255)=&h20 THEN ' '
Cx=15: Cy=0: Cz=0 ' reset object orientation
END IF
CASE %WM_KEYUP
MSGBOX HEX$(wParam)+" up"
END SELECT
PS: But this part works correctly
WHILE GetMessage(Msg, %NULL, 0, 0) ' SK_MILLISECOND
IF GetFocus() = hCtrl AND (Msg.message > 255 AND Msg.message < 266) THEN
IF msg.message=%wm_keydown THEN MSGBOX "keydown main"
CALL TranslateMessage(Msg)
CALL DispatchMessage(Msg)
ELSE
IF IsDialogMessage(hMain, Msg) = %FALSE THEN
CALL TranslateMessage(Msg)
CALL DispatchMessage(Msg)
END IF
END IF
WEND
Thanks for the info on MIP mapping and Anisotropics, Petr. I tried your MIP linear settings but Its interactions with light and color are different and I can no longer blend color with texture for some reason. I will have to do some more experimenting and study the Opengl manuals.
--Charles
Then the solution is quite simple, we will handle ourselves the message dispatching, like this:
- First, we REM OUT this in GLWindowProc
' CASE %WM_KEYDOWN TO %WM_UNICHAR
' BBP.Msg = %BBP_KEYBOARD
' BBP.WinMsg = Msg
' BBP.wParam = wParam
' BBP.lParam = lParam
' CALL BBP_Plugin(BBP)
- Second, add this to the main message pump
LOCAL BBP AS BBPLUGIN
hCtrl = zGetMainItem(%ID_OpenGL)
CALL SetTimer(hMain, %OPENGL_TIMER, 0, %NULL)
WHILE GetMessage(Msg, %NULL, 0, 0) ' SK_MILLISECOND
IF GetFocus() = hCtrl AND (Msg.message > 255 AND Msg.message < 266) THEN
BBP.Msg = %BBP_KEYBOARD ' <---
BBP.WinMsg = Msg.message ' <---
BBP.wParam = Msg.wParam ' <---
BBP.lParam = Msg.lParam ' <---
CALL BBP_Plugin(BBP) ' <---
CALL TranslateMessage(Msg)
CALL DispatchMessage(Msg)
ELSE
IF IsDialogMessage(hMain, Msg) = %FALSE THEN
CALL TranslateMessage(Msg)
CALL DispatchMessage(Msg)
END IF
END IF
WEND
CALL KillTimer(hMain, %OPENGL_TIMER)
...
Patrice, This works when hctrl is ignored.
Using the keyboard generates %WM_KEYDOWN (&h100)
but after using the mouse, the keyboard message then becomes %WM_SYSKEYDOWN (&h104).
The next key pressed after this will revert to %WM_KEYDOWN (&h100)
WHILE GetMessage(Msg, %NULL, 0, 0) ' SK_MILLISECOND
'IF GetFocus() = hCtrl AND
IF (Msg.message > 255 AND Msg.message < 266) THEN
'IF msg.message=%wm_keydown THEN MSGBOX "keydown main"
'IF msg.message=%wm_syskeydown THEN MSGBOX "syskeydown main"
LOCAL BBP AS BBPLUGIN
BBP.Msg = %BBP_KEYBOARD
BBP.WinMsg = Msg.message
BBP.wParam = Msg.wParam
BBP.lParam = Msg.lParam
CALL BBP_Plugin(BBP)
CALL TranslateMessage(Msg)
CALL DispatchMessage(Msg)
ELSE
IF IsDialogMessage(hMain, Msg) = %FALSE THEN
CALL TranslateMessage(Msg)
CALL DispatchMessage(Msg)
END IF
END IF
WEND
--Charles,
QuoteUsing the keyboard generates %WM_KEYDOWN (&h100)
but after using the mouse, the keyboard message then becomes %WM_SYSKEYDOWN (&h104).
The next key pressed after this will revert to %WM_KEYDOWN (&h100)
Yes, this is because we are not using a dedicated "game message pump", but a full Windows message pump using the TranslateMessage API to be compatible with the other child controls of the BassBox window.
See details on MSDN there:
http://msdn2.microsoft.com/en-us/library/ms644955.aspx (http://msdn2.microsoft.com/en-us/library/ms644955.aspx)
That's fine Patrice. I have disabled the hctrl focus condition in the Winmain message loop. But is there a way to stop it 'plunk'ing when a key is pressed.
Sonic Circles
This update is well behaved, easier on the eye and visualises more sonic data.
--Charles
BBP_CreateGLTextureFromFile ("BBPlugin\Texture\wood.jpg",tsc,tsc,pix(),0)
You improperly use the BBP_CreateGLTextureFromFile API. (please look at the source code in BBPlugin.inc)
No need for you to first DIM the array, juste use REDIM pix(0) AS BYTE, because the real size of the array is computed inside of the API.
And using BBPlugin\Texture\wood.jpg",tsc,tsc,pix(),0) is a NoNo, because the texture could fit into a rectangle and not necessarily into a square, moreover the size is rounded to the best 2^, and not to the size YOU specify.
This is because BBP_CreateGLTextureFromFile is able to create a texture form any picture size, and from any GDIPLUS graphic format.
Here is how to use it:
SUB MakeTexture(zPathToTexture AS ASCIIZ)
LOCAL nRet, xSize, ySize AS LONG
DIM Texture(0) AS STATIC LONG
REDIM PixelArray(0) AS BYTE
IF BBP_CreateGLTextureFromFile(zPathToTexture, xSize, ySize, PixelArray(), 1) THEN
CALL glDeleteTextures(1, Texture(0))
CALL glGenTextures(1, Texture(0)): nRet = glGetError()
IF nRet = 0 THEN
CALL glBindTexture(%GL_TEXTURE_2D, Texture(0))
CALL glTexParameteri(%GL_TEXTURE_2D, %GL_TEXTURE_MAG_FILTER, %GL_LINEAR)
CALL glTexParameteri(%GL_TEXTURE_2D, %GL_TEXTURE_MIN_FILTER, %GL_LINEAR)
CALL glTexImage2D(%GL_TEXTURE_2D, 0, 4, xSize, ySize, 0, %GL_RGBA, %GL_UNSIGNED_BYTE, PixelArray(0))
END IF
END IF
END SUB
The important part is:
REDIM PixelArray(0) AS BYTE
IF BBP_CreateGLTextureFromFile(zPathToTexture, BYREF xSize, BYREF ySize, PixelArray(), 1) THEN
...
Patrice, I may need a bit more flexibility - to be able to grab pieces of an image, at varying resolutions, twiddle the pixels etc. The GDIplus Thumbnail was fine for this. Some images may be used at very low resolutions for diffuse effects. I want to use images like Jackson Pollock uses paint :)
One idea I am pursuing at the moment is to be able to construct the scene, then capture this as a texture and use it in the next frame so you get an infinite recursion of the image - like a hall of mirrors.
So you see, keeping close to the lower levels of the interface has its benefits.
--Charles
I have no problem with flexibility, I am just focusing your attention on the way the current BBP_CreateGLTextureFromFile works.
Of course feel free to use your own procedure to perform texture creation as long as it is well behaved with the others plugins.
About the focus everything is done by the kernell (BassBox), thus no need to do it in the plugin.
I have edited, and checked all the enclosed plugins to make sure they work well with the current BassBox version.
There is a new texture: Mask72.jpg that looks also good with what you have done.
The current plug005 version makes me think to "Stonehenge" perhaps we could use menhirs and dolmens instead of the wooden pieces and it would become very celtic... ;)
Hi,
thanks for the perfect updates, it really looks cool.
I am sorry, but I am afraid there won't be any complete code from me for some time, as I am running too much paralel processes while having single core brain :D
Bye,
Petr
Thanks Patrice. The Celtic theme is an excellent idea. Will need to find some convincing stones. Celtic patterns are interesting too.
By the way, Patch39 contains my 2 previous bas versions of PLUG005 but not the latest source, though you have included the compiled DLL of it.
Petr, there is only one solution to single core brain syndrome, and that is to combine all your projects into one big project.
This patch applies to BassBox BBplugin.inc.
There are two new procedures: BBP_GetReg and BBP_SetReg.
They are being used in PLUG007.BAS to save CX, CY, CZ coordinates to retrieve the current settings between sessions or while switching from one plugin to another.
In the BBP.Init message:
' // Retrieve CX, CY, CZ from registry
sDataString = BBP_GetReg(0, $RegistryKey, $RegistryPluginCXYZ)
IF PARSECOUNT(sDataString) = 3 THEN
Cx = VAL(PARSE$(sDataString, 1))
Cy = VAL(PARSE$(sDataString, 2))
Cz = VAL(PARSE$(sDataString, 3))
ELSE
Cx = -499: Cy = -180: Cz = -23
END IF
In the BBP.Destroy message:
'// Save CX, CY, CZ to registry
IF CX OR CY OR CZ THEN
sDataString = STR$(CINT(CX)) + "," + STR$(CINT(CY)) + "," + STR$(CINT(CZ))
CALL BBP_SetReg(0, $RegistryKey, $RegistryPluginCXYZ, (sDataString))
END IF
Like in PLUG005, now you can reset PLUG007 CX, CY, CZ to their default values, using the "space bar".
See below the attached BassPatch40.zip
...
Downloaded and enjoying the latest version, thanks guys.
I was wondering, is it better to store things in the registry or in an ini file where the main app is located? I was just wondering how you determine when to use which.
--Kent
Using the registry, then no need to check first if we are running from a writable media (CD/DVD).
As an alternative you could use the "temp" folder for that purpose (because "temp" folder is always on a writable media).
...
Thanks Patrice, never thought about writable media or not to save... learn something new each day, thanks.
Picking individual objects in space is fundamental to computer games and 3D CAD. Because the relationship between the projected image in pixels and the spatial co-ordinates of objects is so complex, Opengl provides a special rendering mode to collect the names of objects whose surfaces project onto the mouse pointer position. In the case of overlapping objects, we choose the one which has a surface with the smallest z distance from the view plane.
When the left mouse button is clicked, the x y position is stored and a flag is set to initiate this special render, which is executed on the next rendering. Nothing gets written to the frame buffer until the normal rendering mode is restored, and the view construction procedes in the normal way.
If an object has been succesfully picked the the mouse movements are used to alter its rotational or translational displacement.
You can pick the forground objects on move them in various ways with the mouse.
By clicking anywhere in the scene, rotation can be started and stopped.
By dragging on the backgoround all the forground objects move together.
-- Charles,
That's a very interresting OpenGL feature, I didn't know it.
Thank you.
...
Patrice, It is possible to implement a complete GUI within Opengl, with all 3D components - even the individual characters in a text can be identified with this technique, so one could, if so desired, design a complete word processor, as well as innumerable varieties of switches, levers, dials and joysticks.
This is stuff I need to really brush up on, thanks Charles!
--Charles
Indeed I knowed already that we could do amazing things with OpenGL, this is the reason why I have asked
Ryan Cross if he would like to join the fun 8)
He is a great designer and he does already a complete GUI written entirely in OpenGL, as you can see it there:
Quote
I do a lot of 2D graphics in OpenGL, I have never used DirectX.
To render sprites in OpenGL you draw them as textured quads, so its a little different than using GDI. OpenGL does not have its own native functions to load any type of image format. You must either write your own or use a compatible library. I wrote my own function that loads 32-bit alpha blended PNGs (I got some help from Patrice on it).
I used to use GDI(+) for a lot of my graphics, but ever since I switched to OpenGL I have never looked back. Blazing fast compared to GDI.
(Please note: this is a work in progress and is for a full touch screen application, many of the icons are place holders)
Some screen shot examples of what he is currently working on:
(http://www.interfear.com/images/opengl/ryancross_opengl_01.jpg)
(http://www.interfear.com/images/opengl/ryancross_opengl_02.jpg)
(http://www.interfear.com/images/opengl/ryancross_opengl_03.jpg)
(http://www.interfear.com/images/opengl/ryancross_opengl_04.jpg)
(http://www.interfear.com/images/opengl/ryancross_opengl_05.jpg)
(http://www.interfear.com/images/opengl/ryancross_opengl_06.jpg)
Hi Charles,
very nice ! It is also possible to pick object using less comfortable way ( but without need to enter special mode ).
- Store somewhere clickable objects position and bounding volume parameters ( in UDT for example )
- use glReadPixels and gluUnproject to get clicked 3D coordinate:
Quote
glReadPixels( winX, winY, 1, 1, %GL_DEPTH_COMPONENT, %GL_FLOAT, winz ) ' -- WinZ will be retrieved BYREF
' -- Get OpenGL matrices
glGetIntegerv(%GL_VIEWPORT, viewport(0) )
glGetDoublev (%GL_MODELVIEW_MATRIX, mvmatrix(0))
glGetDoublev (%GL_PROJECTION_MATRIX, projmatrix(0))
' -- Unproject coordinate to BYREFed dX, dY, dZ
gluUnProject (winX, winY, winZ, mvmatrix(0), projmatrix(0), viewport(0), dX, dY, dZ )';
- Then test is picked point( dx, dy, dz ) is inside bounding volume
Patrice, Ryan Cross's OpenGL GUI looks very tasty, really best I have seen so far. Did he accepted the invitation ?
Bye,
Petr
Patrice, The Ryan Cross controls are superb. They not only look good but also have great visual clarity. The controls have soft edges that allow the eye to focus on the essential content at the centre of each control.
With textures, you can resolve many of the jagged edge problems that often occur using color and vertices alone.
Thanks Petr, that is computationally less expensive. The advantage of the named objects method is that you are not dependent on evaluating a bounding volume to identify the object. Even if you have several spaghetti monsters fighting each other, you will be able to pick one from the others, assuming you can catch one of its tendrils.
Petr has been telling me about making GUI's with openGL, and even made nice examples. I will need to listen to him more :)
Those pictures of the gl gui are very very nice and motivational.
Charles and Petr, Ok, which system of picking should I use? Let's have a battle of the picking systems demo :)
Not to fool you, most of the drawing are done with PhotoShop then saved as PNG files and translated into OpenGL texture to be used as background or textured sprite objects.
...
Kent,
Petr's method returns positional information. This is fine if you know which control is where in space, but if the spaghetti monster steals your hypertransport console, taunting you by waving it about in the air, it is going to be very complicated to work out the spatial position. Its tentacles gyrate through several rotation, translation and scaling transforms, and unless you have done all the calculations yourself, only Opengl knows where your console is. If it gets swallowed, Opengl will also know that it is now located inside the monster and is no longer accessible to you, even if you can accurately point to where it has gone.
I like that description a lot Charles and that sort of accuracy is something else :)
Hi Charles,
Quote
This is fine if you know which control is where in space, but if the spaghetti monster steals your hypertransport console, taunting you by waving it about in the air, it is going to be very complicated to work out the spatial position. Its tentacles gyrate through several rotation, translation and scaling transforms, and unless you have done all the calculations yourself, only Opengl knows where your console is.
;D Nice scene
You are right. For this reason I created some functions bound to entity system in thinBASIC TBGL module - you can track points on those tentacles at any time, so no problems with calculating where the hell the console is ( no problem for user, I almost failed when composing the functions :D ).
But fact is using your approach you must not rely on such a functions and you can just ask OpenGL to do the job for you. On other side mine approach could be better for general ( very lazy ) collision detection, where mouse clicking is not involved.
I think it is good to know we have choice of approach to reach this task :)
Bye,
Petr
I have been advised by a member of the Un4seen forum of a "small bug" in BassBox :-[
http://www.un4seen.com/forum/?topic=7768.msg53080#msg53080 (http://www.un4seen.com/forum/?topic=7768.msg53080#msg53080)
Being an old dog, I never start my application like this using Explorer (I am still using the prompt a lot).
Anyway the solution is quite simple:
' // Load SKIN components and create SYS buttons
CALL zInitSkin(hMain, zsExePath() + "BassBox.zsk")
zsExePath() was missing, thus the skin components were not found, this is because in such a case the active directory remains the source folder holding the audio files and not the EXE's.
...
--Charles
There is the same problem with your plugins, I shall fix it either, but better to let you know for the future.
Conclusion: we must always use full qualified path.
Note: I could change the active folder in BassBox, but I won't do it, to keep the Windows's default and avoid to cause havoc to the end user.
Here is the patch to fix the bug that was reported on the Un4seen forum.
See below BassPatch41.zip
...
Thanks Patrice,
Here is an update for Plugin005, with some new functions for generating geodesic polyhedra. Octasphere is a 4 branch recursive function so for every increment in n, there will be 4 times as many triangles so be careful!
The corners of each triangle are snipped to expose squares and hexagons. The hexagon voids are not quite coplanar (flat) so this will be refined in due course.
--Charles
Nice additions!
Note: The icon located on the top left corner of BassBox is now a button. I plan to use it to display a help file.
I am thinking of using HTLM help file (using the freeware HelpMaker) or "read only RTF", your thought?
I favour HTML every time Patrice, unless you want to freeze a version. HTML makes it very easy for multiple contributors.
Petr, I am looking at another method for obtaining spatial data: glRenderMode GL_FEEDBACK instead of GL_SELECT.
I have not tried it yet, but potentially it can yield the x y z coordinates of every single visible vertex, and supports primitive labelling with glPassThrough. It is very efficient if you need to get the positions of large numbers of vertices. The problems with it that I can see is that it may generate too much data, and it does not return culled vertices (outside the viewport, so it may not be sufficient for CAD purposes,
Charles,
sounds exciting!
I am not sure if I get it, but using glPassThrough you need to render twice in case you want picture and coordinates at the same time ?
In any case, this is very exciting part of OpenGL I have not fully discovered yet.
It could result in very challenging plugins - imagine shelf with different things, and you can choose which of them will represent music :)
Bye,
Petr
P.S. That recursive geometry looks good !
GlPassThrough is a rather misleading term. It performs a similar function to the glLoadName in GL_SELECT mode, by allowing you to insert any of your own tokens into the feedback buffer, along with the vertex tokens. You can use them as markers so you know which group of vertices belongs to which object in the scene.
Yes great idea. How about assembling a musical instrument with a selection of bodies, arms, fret boards, keys and horns.
Charles,
thanks for the info on glPassThrough.
I like a lot idea of musical multi-instrument, have you seen ATi Animusic Demo (http://ati.amd.com/developer/demos/r9700.html) ?
Bye,
Petr
Watched the video, very impressive combination of music,physics and plumbing. I wonder how many man hours it took to create that demo.
This version introduces a help file named BassBox.chm that is created with the freeware HelpMaker.
All the HTML files are embedded into the "_tmphhp" subfolder, and the Helpmaker project is named BassBox.sh6.
I have added a new visual plugin: "Bumper".
Some minor changes have been done to zSkin.inc, BassBox.bas, plug007.bas.
See below BassPatch42.zip
...
I have downloaded and installed the ATI demo...
on my Vista NVidia GeForce Go 7600, and it works just fine with it!
Very very impressive demo.
...
I liked that demo a lot,
it was bundled with my ex-graphic card :D, Radeon 9600. I liked it a lot too.
One idea for the plugin SDK, maybe it is already there.
We can now detect how strong the sound is ( volume ), but it would be handy to get how high the "tone" is.
This way our multi-instrument could detect high tones and show flute playing, for deep ones bass for example.
Thanks,
Petr
--Petr
Quotebut it would be handy to get how high the "tone" is
This can be done already (see plug001)
...
Nothing new in this patch, except that the CHM help file has been updated and completed.
There is just the "programming section" that has not been written yet, however other chapters are almost done.
Of course being not a native english speaking guy, I may have done some typos, so please be kind enough to report them to me, when you encounter them ;)
See below BassPatch43.zip
...
Hi Patrice,
thanks, I will study plugin 001 more as I thought it is silent/loud based.
Thanks for new version, maybe CHM file could be launched from Bassbox using [F1] key too ?
Thanks,
Petr
Petr, this is how I used the FFT Audto spectrun data in 005. I adapted it from Patrice's 006.
I found that nearly all the activity was in the first 64 or so elements - (does mp3 ignore the higher frequency harmonics ? )
'// FFT MAGIC!
'// BBP.FFTsize returns a pointer to an area of memory containing an array of 256 singles.
'// This is then mapped to the fft() array where it can be accessed.
DIM fft(BBP.FFTsize) AS SINGLE AT BBP.FFTdata
'....
' frequency spectrum
LOCAL v AS SINGLE
glpushmatrix 'for audio spectrum
gltranslatef -6.4, 2.5, -dist*3
DO
IF i>=64 THEN EXIT DO
gltranslatef 0.2,0,0
v=fft(i)*32
glcolor3f v*.5,0,v*2
glcalllist 3 ' stick
INCR i
LOOP
glpopmatrix ' for audio spectrum
Another great update release. Thanks guys. Really impressive!
Hi Charles,
thanks a lot for sample code.
Regarding MP3s ... I am not sure but I think that cutting off the high frequences makes them what they are liked for - smaller size.
Thanks,
Petr
Petr
Yes audio compressor are cutting off most of the high frequencies, because anyway they are not audible by a human hear.
This is for the same reason that I have limited the equalizer range between 80Hz and 14Khz.
You can mix altogether FFT (plug006, 007, 008) and PEAK level detection (Plug001, 004)
When you get the PEAK Level info, it is the highest left or right channel audio level beeing played at this specific time.
In Plug001, the higher the peak level is, the faster the octaedre is moving and pulsating.
I have completed the CHM help file, and added the "F1" key as Petr suggested.
See below attached BassPatch44.zip
...
New visual plugin: "Boomer"
See below attached BassPatch45.zip
...
Patrice, thanks phenomenal work you are doing. The F1 help is great. The new plugin is cool. I like seeing speakers thump :)
QuoteResizing to larger an back to smallest for several times leaves artefacts in the right-upper corner and the left-bottom corner.
Here is the workaround to solve the XP artefacts problem reported by Hans and Charles .
There are two changes thay must be done in
zSkin.inc '// Create new Main form region on the fly
SUB zCreateFormRegion(BYVAL TransColor AS LONG)
...
IF hRgn1 THEN
IF IsWindowVisible(zMainWindow(0)) THEN bRedraw = %TRUE ELSE bRedraw = %FALSE CALL SetWindowRgn(zMainWindow(0), hRgn1,
bRedraw)
END IF
END SUB
'// Paint our custom background there
SUB zMoveBackground(BYVAL rwX AS LONG, BYVAL rwY AS LONG)
...
' // Paint GROUPBOX with respect of the z-order
'IF Vista() THEN CALL PaintGroupBox(hMain, graphics)
IF NOT zComposited() THEN CALL PaintGroupBox(hMain, graphics)
CALL GdipDeleteGraphics(graphics)
END IF
'// %BACK_PaintBitmap
hDCBack& = CreateCompatibleDC(hDC)
CALL SelectObject(hDCBack&, zGetBackBitmap(hMain))
CALL BitBlt(hDCBack&, 0, 0, rc.nRight, rc.nBottom, hDC, 0, 0, %SRCCOPY)
CALL DeleteDC(hDCBack&)
' // Paint caption text
CALL zGetCaptionXY(x, y)
CALL zDrawTextToDC(hDC, (zGetCTLText(hMain)), x, y, gColorCaption, SK_CAPTIONFONT(), SK_CAPTIONFONTHEIGHT(), -1, 0)
CALL DeleteDC(hIC)
END SUB
Please let me know if that solves the problem?
See below the attached
zSkin.incThanks
...
Yes Patrice, that has fixed it. You found the solution so quickly!
QuoteYes Patrice, that has fixed it. You found the solution so quickly!
Thanks for the feedback.
I was able to fix it quick, because I have spent so many years doing low level graphic programming, and I thought myself when I wrote the WinLIFT Skin Engine in the last decade of the twentieth century ::)
HAL is the first BassBox plugin using multi-texture.
See all details in Plug010.bas
SUB MakeMutipleTexture (BYVAL tp AS BBPTEXTURE PTR, BYVAL N AS LONG)
LOCAL mtCount, K, nRet, xSize, ySize AS LONG
DIM mt(1 TO N) AS BBPTEXTURE AT tp
mtCount = UBOUND(mt()) - LBOUND(mt()) + 1
IF mtCount THEN
DIM Texture(1 TO mtCount) AS LONG
CALL glDeleteTextures(mtCount, Texture(1))
CALL glGenTextures(mtCount, Texture(1)): nRet = glGetError()
IF nRet = 0 THEN
FOR K = 1 TO mtCount
REDIM PixelArray(0) AS BYTE
IF BBP_CreateGLTextureFromFile(mt(K).FullName, xSize, ySize, PixelArray(), mt(K).Square) THEN
mt(k).Texture = Texture(K)
CALL glBindTexture(%GL_TEXTURE_2D, Texture(K)): nRet = glGetError
IF nRet = 0 THEN
CALL glTexParameteri(%GL_TEXTURE_2D, %GL_TEXTURE_MAG_FILTER, %GL_LINEAR)
CALL glTexParameteri(%GL_TEXTURE_2D, %GL_TEXTURE_MIN_FILTER, %GL_LINEAR)
CALL glTexImage2D(%GL_TEXTURE_2D, 0, 4, xSize&, ySize&, 0, %GL_RGBA, %GL_UNSIGNED_BYTE, PixelArray(0))
END IF
END IF
NEXT
END IF
END IF
END SUB
HAL combine audio FFT, peak level, and pulse detection altogether.
Enjoy
See below attached BassPatch46.zip
Patrice that is just Sooooo Cooooooooooooooool !!!!!
Please guys make sure to get the Hal audio file too that Patrice put up... really clever mix of audio and effects. Thanks very very cool.
I feel like I have my own HAL!!
It GPFs when I try to activate the plugin 05. Works fine with the others.
Windows XP Professional SP2.
--José
Perhaps Charles's plugin 05 is using some OpenGL features that are not compatible with your graphic card.
Charles ?
...
José, do you get any image or background at all with 005?
PS:
It uses the same Opengl features as 003 plus picking using glrendermode GL_SELECT and also uses part of the bassbox fft data.
I did check Charles's plugin 05 on XP with an ATI RADEON X600 PRO with 256 MB, and all went fine on this computer.
The main difference I can see between VISTA and XP, is that on XP the mouse disapear while hover the OpenGL control, while it shows just fine on VISTA.
By the way if you know how to show the mouse with XP while hover an OpenGL control, please let me know.
...
Quote
José, do you get any image or background at all with 005?
No. It GPFs as soon as I click the number "05".
This version of BassBox now performs plugin's auto-detection.
No more need to edit the kernell's code, just add the new plugin, then restart BassBox to use it.
As a side effect of the auto-detection:
If you experience a problem with any of the provided plugin, just removed those causing havoc with your hardware configuration.
Then no more problem. ;)
The CHM help file has been updated to reflect the latest changes.
See below attached BassPatch47.zip
...
--Kent
QuotePlease guys make sure to get the Hal audio file too that Patrice put up... really clever mix of audio and effects. Thanks very very cool.
I feel like I have my own HAL!!
What about a black monolith floating around hover a stellar background while the sun rise-up behind the hearth?
...
Good idea Patrice, I was just about to suggest it. But have you a scheme for when we run out of space on the base bar at about Plugin020 ? :)
The only way to catch GPF errors on different hardware is to create a diagnostic / logging version of a plugin. 005 only uses very basic Opengl, and most Opengl errors are not that disruptive anyway.
QuoteBut have you a scheme for when we run out of space on the base bar at about Plugin020
No problem, just tell me when you have completed plug019.dll ;)
...
Quote
Hi Patrice,
May I tell you about a new (little) bug I found?
When you put on equalizer and add bass or treble, for example, then, when the song repeats itself, the equalizer is in a off state though the check box is still on.
You have to turn it off then on again to have equalization working again...
The same phenomenon happens when you launch BassBox.exe, turn equalizer on, then click play : sample mod is playing, but there is no equalization, put it off then on to have it working.
Regards,
Arthur.
Equalizer setup is now kept/restored properly while playing audio files en sequence or in loop mode.See below attached
BassFix.zip Warning the zip contains only
BassBox.bas and
BassBox.exe!
...
Hi Patrice,
great job! I like new version a lot!
I cannot confirm that mouse cursor disappears while moving over OpenGL control on XPs ???
One thing - I noticed lot of plugins ( including mine, heh ) use glVertex3d functions, which uses double precision.
Fact is, that according to more than one source, current 3D hardware still operates with single precision for vertices, so driver has to do some data type conversion. So maybe we can stick with glVertex3f ?
I know this could cause problems only in case of huge meshes...
I "managed" to accidentaly overwrite my new plugin, but it was not good so better it won't see the light :)
Idea with black monolith sounds good, I will try to start working on something, else I will get totally out of sync with BassBox developement which would be pity for me.
Bye,
Petr
Petr,
If you look at my own plugins, you will see that I am always using float/single most of the time ;)
I am looking forward for your new contribution, it would be too bad that you jump out of the band wagon :-\
I agree about the double precision Petr. This is useful for CAD or high-precision scientific visualisation, but for most purposes, it is unnecessary, and an additional overhead as far as the graphics hardware is concerned.
We could end up with quite a large number of functions, so keeping to single precision type will help to keep them consistent. I was wondering whether to start a separate inc file for geodesics and similar structures. Each form would have Coords, TexCoords and Normals, available to any plugins, 005 is getting very fat. I think the source code will be more useful than a DLL since coders will inevitably want to create their own variations.
Hi,
I don't want to leave wagon, I am taking mustang to catch the last train wagon and slowly crawl forward ( read: I started the plugin tonight, concept works, it just needs huge work on textures :D. Now it seems more of "Solaris" than "2000: Space Odyssey" )
Charles, if you mean codes for cylinders, boxes, spheres and others I think it is good idea! I can provide what I have in TBGL.
Bye,
Petr
Yes, I was thinking of all kinds of shapes, including ones which have been morphed: for instance: inflating a cube so it takes on a spherical shape; or the recursive octasphere. It's very open ended. Once you have a good set of basic shapes, it is easy to derive new ones.
Hi Charles,
nice ideas! But it will require all shapes to have same vertexcount to do morphing ?
Well, I had very long but entertaining night, so here is my "Solaris" plugin, I named it as plug011. Just unzip the files in BBPlugin directory.
Hope you will like it,
Petr
UPDATED PLUGIN DOWNLOAD
--Petr
Thank you very much for working a part of the night to provide us with this new plugin!
To make it even look better, please note that you must use mt(x).Square = 1, only when image source is not already a ^2.
In the case of texture "11_venusmap.jpg" the size being already 1024 * 512 then no need to use it.
Note: you can decrease the size down to 256 * 128 without problem, because it is being used to represent the sun instead of venus.
...
Hi Patrice,
thanks, I thought Square = 1 means it is square :) I know code is a bit ( a lot ;) ) messy, but I wanted to finally show something instead of promising something for months. I will further work on the plugin if I will have time.
I have updated the download with your suggestions.
I know it is not much evident, but it is not suposed to be sun, but "Solaris" - kind of planet with own inteligence ;)
It is featured in really good book by Stanislaw Lem. There were even movies done based on this book, first by Tarkovskij ( but I haven't seen this ) and second featuring George Clooney quite recently. Both movie and book are very good stuff, check it out when in mood :)
Thanks,
Petr
Hi Petr
I have reworked plug011.bas to produce that one
and added a new audio file to play with it.
Note: we could smoother the planet circle to make it even more realistic, however I am geting tired and need a good sleep either ;)
We are not that far from the monolith ...
...
Petr, Is it safe to land on this planet? Sunglasses and asbestos boots provided. Or maybe a close transit would be safer.
It is even more dangerous Charles,
everything on the surface is kind of weird which makes astronauts think they took LSD rather than classic cosmic food :)
Book will tell you more :)
Patrice, thanks for tuning the module, it looks much better now!
Petr
--Petr
I am still tuning the module to make it looks more realistic and brushing up the code.
I shall save it as Plug012.bas to not interfere with your initial work and it will be named "In the begining" this is because I want to create several scenes about the theme of Earth genesis.
This one would be the early stage, just before earth and heaven separation.
And guess you, what/who is working hard behind the globe emiting all these glowing lights ;)
...
--Charles, Petr
It is a bad idea to hard code the rAspect parameter of the gluPerspective procedure in the %BBP_RENDER section.
- First, because the aspect is never 1.25 but always the result of width / height.
- Second, all the computation is already done in the handling of the %BBP_SIZE message.
Thus all you have to do in %BBP_RENDER is just to call glLoadIdentity() to reset to default.
Then the aspect will always looks good, like in the HAL plugin.
Thank you
...
Here is new plugin "In the begining" derivated from Petr's original plug011 (Thanks Petr).
The code has been cleaned up, and it shows you how to use glut quadric object to create the embedded spheres. The aspect is correctly computed to work with any screen size resolution.
I have edited several textures before I could produce something that looks close to the reality.
I selected an infrared sky, because we are close to the begining of the universe. At this time the Monolith stands behind the Earth, working hard to make this jewel of our galaxy that is our little planet.
Next step would be to split the water and make earth ground coming visible, while the Monolith slowly emerges from behind the Earth, moving hover the scene ;)
See below attached PLUG012.ZIP + TheChamber.zip (audio theme)
...
Hi Patrice,
thanks for both perspective correction advice and new plugin!
Your plan sounds nice!
Petr
Wonderful textures, really enhance the scene. They might also appear elsewhere :)
Two more pieces of music that go well with the Space theme:
Face of Mars: mars.ogg
Vestige of Time: vestige.ogg
They are quite large so here is where they can be downloaded:
http://freaknet.org/martin/audio/csound/index.en.html
See there:
Mike Oldfield (http://www.mikeoldfield.com/)
I bought his album "The songs of Distant Earth", however he also has some other nice pieces of work ;)
...
Yes I've got it too. It is a very fine album.
Here is another plugin, inspired by the two previous pieces. It is a bit warmer here than planet Earth, a landing is not advised.
Patrice, please renumber this plugin if it interferes with your Genesis sequence.
José', I have removed most of the redundant code, but it is the progeny of 005. I wonder if it works on your PC.
Nice Charles,
really interesting shape!
I will check the source later today to see how it is done ;)
Petr
I am thinking that I will make a change to kernell as to let you use any name for your plugin.dll.
I shall check for all the DLL stored inside of the BBPlugin folder, and if they export a "BBProc" procedure then they will be added to the list.
Your thought?
Good idea. And if you sort the plugin list alphabetically, you can ensure that themed plugins are grouped together eg GenesisPT001 GenesisPT02 .. I think this will work well, at least for the first 100 plugins :)
Petr, the Cubeshere is useful because it has a good distribution of quads over its surface without excessive concentration at the poles. The vertices can then be varied to generate the rough terrain. But there are two main problems to deal with. One is stitching the terrains together seamlessly and the other is fitting spherical texture skins to this layout of vertices.
These layers of translucent texture - very subtle and fascinating Patrice. Brings the planet to life.
Well Vulcan gets some more heat treatment, but the occasional abyss into the interior can only be closed with the power of mathematics, and a good night's sleep.
There is a new BassBox version!
The ZIP file is attached to the first post of this thread.
Now you can give any name to your plugin, the kernell checks all the DLL stored in the "BBPlugin\" subfolder, if they export the "BBProc" procedure they are bounded to the kernell, else they are ignored.
I have renamed all the existing DLL with a name matching their Title.
__________________________
Special note for Charles:
"Vulcan.bas" and "StickDance.bas", at this moment, are only provided in source code format, because they both create a problem with the other plugins using textures, perhaps because they use a special mapping texture mode that is not reseted during the BBP_Destroy message.
To see the problem start BassBox selecting the "Vulcan" plugin then switch to "Day One", and look how the texture is mapped hover the globe (it is darker and uses tesselate by face mode).
It would be nice if you could turn off this feature in your plugin when it is detached. Or at least tell me what to do.
Thank you
...
Hi Patrice and Charles,
I think that problem which is caused by the Charles plugins is just that he defined other kind of blending ( glBlendFunc ), maybe something more ( light setup ).
New version is very nice ( especially Genesis ), but without Charles plugins not complete :'(
Hope we will find all reasons it causes troubles soon.
OpenGL works like state machine, so when you change something, it stays changed.
Bye,
Petr
The main difference from your render settings is that I use Lighting and also color_material which controls how the color interacts with light sources. My Plugins currently do not disable GL_COLOR_MATERIAL at the end of rendering.
Unfortunately, I can't reproduce the problem that you describe so I cant verify that this is the cause, but you may want to use these features in future plugins so it may be desirable to enable/disable them rather than assume they are always disabled. What do you think?
glEnable GL_LIGHTING
glEnable GL_COLOR_MATERIAL
render_settings:
glShadeModel GL_SMOOTH 'Enable Smooth Shading
'glClearColor cl(0,0), cl(1,0), cl(2,0), cl(3,0) 'Background
glClearDepth 1.0 'Depth Buffer Setup
glEnable GL_DEPTH_TEST 'Enables Depth Testing
glDepthFunc GL_LEQUAL 'The Type Of Depth Testing To Do
glHint GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST 'Really Nice Perspective Calculations
glEnable GL_LIGHTING 'Enable Lighting
glEnable GL_COLOR_MATERIAL 'Enable Coloring Of Material
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) 'Enable Alpha Blending
glEnable(GL_BLEND) 'Enable Blending
glEnable(GL_ALPHA_TEST) 'Enable Alpha Testing
glAlphaFunc(GL_ALWAYS,0.0) 'Set Alpha Testing
'glDisable(GL_CULL_FACE) 'Remove front or Back Face
RETURN
Guys, when I put the plugins into where i think they should go, they don't show up. Do I need to add anything to the bassbox code?
I haven't been able to view any of the recent new plugins and the screenshots look so good.
Kent, I think the best way to do it is unzip the new Bassbox into a new folder. If you want to see mine (StickDance Plug005 & Vulcan ) all you have to do is compile them in situ then rerun BassBox. I'd be interested to know if any of them interfere with the other plugins on your system.
Thanks Charles, I followed your instructions and got all of them working. All the plug-ins look fine. The only thing I notice, if any is that the first plugin with the blue world is sort of ghosted as Petr mentioned. I can't remember if it was like this before I added your plugins. I did notice some fading before I do remember that, but the extent is where I am fuzzy.
The other plugins all look ok as far as I can tell.
All I know is how nice these plugins and the player are. I really enjoy your guys talents and creativity!
I had a hard time to figure and suppress most plugin's interaction.
I think I solved everything, however so far I checked only on VISTA, but I am confident that you will check it also on XP ;)
I did several changes in the Kernell and in the plugin as well, so please do not overwrite what I have done.
Kernell change:
SUB BBP_Reset()
LOCAL BBP AS BBPLUGIN
BBP.Msg = %BBP_CREATE
CALL BBP_Plugin(BBP)
IF BBP.RenderTo = %BBP_OPENGL THEN
CALL glDisable(%GL_BLEND)
CALL glDisable(%GL_TEXTURE_2D)
CALL glDisable(%GL_DEPTH_TEST)
CALL glDisable(%GL_LIGHT0)
CALL glDisable(%GL_LIGHT1)
CALL glDisable(%GL_LIGHT2)
CALL glDisable(%GL_LIGHT3)
CALL glDisable(%GL_LIGHT4)
CALL glDisable(%GL_LIGHT5)
CALL glDisable(%GL_LIGHT6)
CALL glDisable(%GL_LIGHT7)
CALL glDisable(%GL_LIGHTING)
CALL glDisable(%GL_COLOR_MATERIAL)
CALL glDisable(%GL_ALPHA_TEST)
CALL glDisable(%GL_NORMALIZE)
'DIM No_Mat(3) AS SINGLE ' : ARRAY ASSIGN No_Mat() = 0.0, 0.0, 0.0, 0.0
'CALL glMaterialfv(%GL_FRONT_AND_BACK, %GL_DIFFUSE, No_Mat(0))
'CALL glMaterialfv(%GL_FRONT_AND_BACK, %GL_SPECULAR, No_Mat(0))
'CALL glMaterialfv(%GL_FRONT_AND_BACK, %GL_SHININESS, No_Mat(0))
'CALL glFlush()
END IF
END SUB
Plugins that have been edited:
Day1.bas, StickDance.bas, Vulcan.bas
The most important change was done in StickDance, there:
CASE %BBP_DESTROY
DIM No_Mat(3) AS SINGLE ' Dito ARRAY ASSIGN Dummy() = 0.0, 0.0, 0.0, 0.0
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, No_Mat(0))
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, No_Mat(0))
glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, No_Mat(0))
I suggest the use of ARRAY ASSIGN to simplify array affectation.
Looking forward for your feedback.
The ZIP file is attached to the first post of this thread.
...
Thanks Patrice. That looks like a comprehensive reset of Opengl states. I can see my prior version of 005 bleaches part of day0 and day1 so I presume this is due to not clearing glmaterial values.
Now let's see what other kinds of mischief can be wrought upon your system, shadows, antialiasing, vertex and fragment shaders.... ;)
Thanks for the update Patrice. Happy to report all seems to work fine here on XP that I can see!!
In VISTA (and XP as well), I would like to create a Desktop Window Manager (DWM) thumbnail, to reduce the size of the player in order to take less room on the desktop.
I know how to do this on VISTA (and XP as well) however the problem I have, is that OpenGL doesn't render the viewport if it is not shown on the desktop.
Do you know if there is a way to render OpenGL directly to a memory bitmap without showing it first to the screen?
You could try making a tiny tiny viewport of a few pixels, one pixel or maybe even zero pixels? But it would be interesting to see something on a micro screen.
Hi Patrice,
you know the answer is PBuffers. Now just how to get PBuffers to PB :D
Here are the extensions defined in C:
DECLARE_HANDLE(HPBUFFERARB);
HPBUFFERARB wglCreatePbufferARB(HDC hDC,
int iPixelFormat,
int iWidth,
int iHeight,
const int *piAttribList);
HDC wglGetPbufferDCARB(HPBUFFERARB hPbuffer);
int wglReleasePbufferDCARB(HPBUFFERARB hPbuffer,
HDC hDC);
BOOL wglDestroyPbufferARB(HPBUFFERARB hPbuffer);
BOOL wglQueryPbufferARB(HPBUFFERARB hPbuffer,
int iAttribute,
int *piValue);
Here is how I would translate them to PB ( no warranty, I am not José :( )
DECLARE FUNCTION prototype_wglCreatePbufferARB( BYVAL hDc as DWORD, BYVAL iPixelFormat AS LONG, BYVAL iWidth AS LONG, BYVAL iHeight AS LONG, BYVAL piAttribList AS DWORD ) AS DWORD
DECLARE FUNCTION prototype_wglGetPbufferDCARB( BYVAL hPbuffer as DWORD ) AS DWORD
DECLARE FUNCTION prototype_wglReleasePbufferDCARB( BYVAL hPbuffer as DWORD, BYVAL hDc as DWORD ) AS DWORD
DECLARE FUNCTION prototype_wglDestroyPbufferARB( BYVAL hPbuffer as DWORD ) AS BYTE
DECLARE FUNCTION prototype_wglQueryPbufferARB( BYVAL hPbuffer as DWORD, BYVAL iAttribute AS LONG, BYVAL piValue AS DWORD ) AS BYTE
Then you just need set of handles to those functions:
GLOBAL PwglCreatePbufferARB, PwglGetPbufferDCARB, PwglReleasePbufferDCARB, PwglDestroyPbufferARB, PwglQueryPbufferARB AS DWORD
And then you need to seek if those extensions are supported ( beware, case sensitive ! )
PwglCreatePbufferARB = wglGetProcAddress("wglCreatePbufferARB")
...
and finally call functions something like:
CALL DWORD PwglCreatePbufferARB USING prototype_wglCreatePbufferARB( ... )
I must say Eros made this much easier in thinBASIC, where you can set address to function declaration and no need for CALL DWORD fun. In PB could be calls encapsulated in MACRO like that:
MACRO wglCreatePbufferARB( hDc, iPixelFormat, iWidth, iHeight, piAttribList)
CALL DWORD ...
END MACRO
But those are just quick thoughts, I had no time to test whether it really works, so be careful :)
Bye,
Petr
Untested. Hope they work.
FUNCTION wglCreatePbufferARB( _
BYVAL hDc AS DWORD, _
BYVAL iPixelFormat AS LONG, _
BYVAL iWidth AS LONG, _
BYVAL iHeight AS LONG, _
BYREF piAttribList AS LONG _
) AS DWORD
LOCAL dwRes AS DWORD
LOCAL pProc AS DWORD
pProc = wglGetProcAddress("wglCreatePbufferARB")
IF pProc = %NULL THEN EXIT FUNCTION
CALL DWORD pProc USING wglCreatePbufferARB(hDc, iPixelFormat, iWidth, iHeight, piAttribList) TO dwRes
FUNCTION = dwRes
END FUNCTION
FUNCTION wglGetPbufferDCARB (BYVAL hPbuffer AS DWORD) AS DWORD
LOCAL dwRes AS DWORD
LOCAL pProc AS DWORD
pProc = wglGetProcAddress("wglGetPbufferDCARB")
IF pProc = %NULL THEN EXIT FUNCTION
CALL DWORD pProc USING wglGetPbufferDCARB(hPbuffer) TO dwRes
FUNCTION = dwRes
END FUNCTION
FUNCTION wglReleasePbufferDCARB (BYVAL hPbuffer AS DWORD, BYVAL hDc AS DWORD) AS LONG
LOCAL lRes AS LONG
LOCAL pProc AS DWORD
pProc = wglGetProcAddress("wglReleasePbufferDCARB")
IF pProc = %NULL THEN EXIT FUNCTION
CALL DWORD pProc USING wglReleasePbufferDCARB(hPbuffer, hDc) TO lRes
FUNCTION = lRes
END FUNCTION
FUNCTION wglDestroyPbufferARB (BYVAL hPbuffer AS DWORD) AS LONG
LOCAL lRes AS LONG
LOCAL pProc AS DWORD
pProc = wglGetProcAddress("wglDestroyPbufferARB")
IF pProc = %NULL THEN EXIT FUNCTION
CALL DWORD pProc USING wglDestroyPbufferARB(hPbuffer) TO lRes
FUNCTION = lRes
END FUNCTION
FUNCTION wglQueryPbufferARB ( _
BYVAL hPbuffer AS DWORD, _
BYVAL iAttribute AS LONG, _
BYREF piValue AS LONG _
) AS LONG
LOCAL lRes AS LONG
LOCAL pProc AS DWORD
pProc = wglGetProcAddress("wglQueryPbufferARB")
IF pProc = %NULL THEN EXIT FUNCTION
CALL DWORD pProc USING wglQueryPbufferARB(hPbuffer, iAttribute, piValue) TO lRes
FUNCTION = lRes
END FUNCTION
A new visual plugin has been added 8)
The ZIP file is attached to the first post of this thread.
...
Looks cool Patrice,
reminds me of one movie with 8), 8) and 8)
Petr
Super new plugin Patrice!! That is really great!!!
The hard thing, with this plugin, was to find the good algo to synchronize visual effects and audio altogether to produce something that looks good with most music genders.
Try the enclosed ZIP file with "The Matrix" plugin.
Warning this will stress both your graphic card and your audio card!
Sorry J.S.B. ;D
PS: Turn off the equalizer!
That does make all the plug-ins come alive :)
A new visual plugin has been added.
It tooks me a huge amount of work to create this new one.
I hope you will like it.
Try it with the XM SoundTracker file "Something out there" (audio section)
and play it full screen to see all the details.
The ZIP file is attached to the first post of this thread.
...
Patrice,
this is beautiful, really nice plugin!
Very optimistic, very cool. It really reflects the music well!
Thanks,
Petr
P.S. Patrice, the new track is nice, just one "trouble" - zipped file is named like "SOMETH~1.XM". So quite DOSsy :)
Oh Wow, I love the new track and plugin!! What a perfect match!! AWESOME!!!
BassBox has been posted on Code Project, in the hope to attract some more contributors ;)
See it there:
BassBox on code project (http://www.codeproject.com/useritems/BassBox.asp)
...
I love the flares on this ethereal object and the illusion of dazzle. Should we be wearing protective goggles to view it? 8)
I am at present marooned in close orbit around my rocky asteroid, which is now free of any craggy voids on its surface. But perhaps I could borrows some of those flares for propulsion.
Hope we get some visitors from Code Project. Will they want it in C++?
Quotethis ethereal object
I was half between "Close Encounter" and "The Abyss" when i did it.
...
I especially like your comment:
" ... Because i was tired of the OOP overhead and the bloated DotNET, I switched back to plain SDK programing style ... "
;D
Do you want to create your own night club?
Then try this new plugin.
and as usual see the audio section for the new "Blue star.mod" to play with it.
...
Thanks Patrice another nice mod track and matching plugin!!
I have been playing with the idea of a logo for BassBox, and this one is my first shot.
(I have also done some tests with the "Leornardo.png" that is in the "texture" folder)
See it in the updated SpotLights.zip
(Better to see it full screen)
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRReally clever design Patrice and NICE looking!!!
I love so many aspects of it and to throw in an effect into the logo, brilliant all ways around!!
Very nice logo Patrice,
also the plugin looks very good!
Thanks,
Petr
Continuing the space theme:
Cartesian Space
and update for Vulcan
Patrice,
You can remove Plugin005 from the BassBox distribution if you like. The most useful components will be recycled anyway. :)
PS:
Nice logo!
Charles,
very nice new plugins!
Modified Volcano looks very good and cartesian space reminds me of StarWars - when Luke Skywalker drops into the DeathStar canyon and looks into the navigation machine.
Bye,
Petr
Nice update and new one Charles. Petr I am so glad you said it reminded you of Luke's run on the DeathStar, ...I would have been like... it reminds me of something and been stuck on remembering what. It definitely has that feel to it!
--Charles
Thank you for your last post.
I have one suggestion that would make them looking more realistic.
For the star background, try using the OpenGL 2.0 sprite feature as shown in "Encounter" when drawing the etheral sphere, and use a pulsating white color instead of random colors.
Also because the main purpose of BassBox is playing audio, I think it would be better to redraw the fft in real time in your cartesian plugin. I could post an example showing how to represent a moving FFT in real time if you want.
Something very important to keep in mind when writing a plugin for BassBox: all the animated drawing must be done in real time. If the OpenGL effect computation is too long, it produces nasty sounds, because the player get out of synch, especialy when the host computer is not a dual core processor.
Thank you
...
Thanks for your comments Patrice.
CPU performance is a very interesting issue with animation. I have found that Windows Task Manager (CtrlpAltpDel) is a very useful way of getting feedback, and it usually shows that dynamically generating a mesh of any substantial size is a performance killer. Compiling meshes into glLists in advance delegates most of the work to the GPU. Here are some rough figures using my HP Desktop which is a dual core AMD64 / Nvidia setup. These measurements are for the default BassBox Window playing 'Blue Star'
PLUGIN CPU Load%
-----------------------
Cartesian 18
Day0 21
Day1 27
Encounter 35
Fireworks 4
Hal 15
Laser 21
Magic D 4
Matrix 6
Spectrum 4
Spotlights 6
Stick Dance 6
Tilt 15
Vulcan 28
Woofer 15
For 'Encounter' for instance, if you disable the gluquadrics (in the central axis) you will find that the CPU loading goes way down.
Similarly I found that removing the atmosphere from Vulcan reduced the CPU loading from 22% to 12%. And when the music is halted, this figure drops to 4% !
Realistic stars:
I have not looked at point sprites yet - I look forward to trying them out as you have used them. How about a Milky Way.
Real Time FFT:
We could put 'Cartesian into reverse gear and take a few more frame samples, it would then be more closely tied to the music. But my aspiration is to produce Sonic Landscapes - without imposing an excessive CPU load.
--Charles
The test you have done are very interresting.
I did the same on my VISTA Intel Core Duo 2, and here are my results:
USER Charles Patrice
CPU AMD 64 Intel Core Duo 2
GRAPHIC CARD NVIDIA Go 7600
OS XP VISTA
PLUGIN CPU Load% average%
---------------------------------------------
Cartesian 18 9
Day0 21 22
Day1 27 25
Encounter 35 34
Fireworks 4 4
Hal 15 14
Laser 21 14
Magic D 4 4
Matrix 6 5
Mikado 5
Spectrum 4 6
Spotlights 6 11
Stick Dance 6 6
Tilt 15 13
Vulcan 28 14
Woofer 15 15
While doing these tests, I found in BassBox.bas that changing in the procedure RenderOpenGL:
'// Refresh display
'CALL SwapBuffers(glDC)
'CALL zUpdateWindow(glCtrl, 0)
CALL wglSwapBuffers(glDC)
produces better performances with the VISTA DWM, thus my own test have been done using it.
...
In the "Encounter" plugin you can reduce the drawback of using quadric sphere object
changing from 48 to 3, that will indeed produce a very nice GEM effect and decrease CPU usage by a factor 3.
SUB DrawSphere(BYVAL Radius AS SINGLE)
LOCAL quadObj AS LONG
quadObj = gluNewQuadric() ' Pointer to the Quadric Object (Return 0 If No Memory))
IF quadObj THEN
CALL gluQuadricNormals(quadObj, %GLU_SMOOTH) ' Create Smooth Normals
CALL gluQuadricTexture(quadObj, %GL_TRUE) ' Create Texture Coords
CALL gluSphere(quadObj, Radius, 3, 3) ' 48, 48)
CALL gluDeleteQuadric(quadObj)
END IF
END SUB
Nice solution Patrice. I tried to put the gluspheres into a glList but found that the spheres would not scale properly with glScalef when they were glCalled. The only alternative would be to generate your own spheres.
It is interesting to see how the processing is distributed between the two CPU cores. Usually its one core or the other but sometimes they share the processing equally. One curious effect I found with Vulcan in full screen mode only, is that the CPU load goes into a long oscillation about 10 seconds frequency, varying between 25% and 55%. I would like to find out what causes this. - possibly some memory housekeeping but why?
Beautiful looking Patrice. One thing... it would be nice if the bassbox logo was smaller and sort of moved around in the black area at top allowing full viewing of it and beautiful colored spectrum cylinder bars.
Very Very nice!!
This is the new "Impulse" plugin, it has been reworked to achieve closer FFT accuracy and very sharp representation of the playing audio.
Because it is not obvious at the first look, i tell you that the histogramme part is not made of rectangles but pulsating cylinders.
Enjoy
...
Beautiful new version of Impulse Patrice, thanks.
Thank you Kent, i like it very much too ;)
Further mods: Please see later posting of Vulcan.zip
Here is an update for the Vulcan Plugin, with textured point sprite stars, as suggested by Patrice. I am experimenting with synthetic textures. The stars use a 16 pixel texture with one pixel set in the middle. Three quarters of the texture is then used to make a 3x3 texture mapping. Can't get much simpler than that. Notice the shape of the large star which emerges from behind the planet.
This is how a single pixel is enlarged by GL_LINEAR.
The atmosphere has also been compiled into a glList to improve efficiency.
PS The Impulse plugin looks very good Patrice. I like the exceptional clarity of the FFT.
The new song really makes Impulse dance nicely that is for sure.
The new vulcan looks great too. I didn't see the problem that Patrice captured in the screenshot. But that was listening to one song. I will play more songs tomorrow and see if I can get the same sort of problem.
That is an intriguing problem Patrice. The planet appears to have lost most of its surface and gained a a corona! But I see you are using Vista. Do you get the same problem under XP? I've had mine running for many hours. All the objects are compiled into gLists so there are very few state changes between frames.
--Charles
On XP i have another problem: No STARRY BACKGOUND
I will check for the latest OpenGL driver for the ATI Radeon being used and see if it solves it.
Point sprites would be a problem on pre-Opengl 2 drivers. It would also affect Encounter etc.
At first site the planet's loss of surfaces looks like some form of back-face culling gone wrong. - do you a least get a hemisphere?
--Charles
I have installed the latest ATI drivers on my XP computer (from november 17, 2007), an that solved two problems:
1 - The STARRY BACKGROUND is working fine now.
2 - My XP's mouse cursor doesn't flicker or disapear anymore when hover the OpenGL viewport.
Conclusion:
Always make sure to use the latest drivers when doing 3D graphics!
Note: Encounter point was working fine even without the update ?!?
Patrice, I've been able to reproduce the problem by compiling the planet into a glList,(it was dynamically generated before) on a new plugin. Amazing to watch it doing its own thing!
I think the star plane is cutting into the planet causing a Z-order alpha void. So I'll move it.
New plugin "Pop Star"
see attached zip file
...
Something green anyway.
Let's see how it does in Vista. Might turn into cabbage.
Thanks guys nice new plugins to start the day!!
I noticed one thing today. I went to maximized window and realized the bottom of the BassBox window falls behind the taskbar. I am using XP if that makes a difference.
Other than that, thanks guys!!
This is a tamer version of Vulcan, which should behave itself better in Vista etc. The star has been moved further away and rescaled. The planet is now compiled so it further reduces demands on the system. I had the planet wizzing around with no signs of disintegration.
--Charles
This one seems to have solved the culling problem on both XP and VISTA.
Thank you.
...
The whole project has been updated, see first post.
...
Is there a way of playing CDs through BassBox - having the right registry keys etc?
Another idea is to concentrate the plugins so that each one provides a theme of visualisations, which could be changed with the space bar or automatically over time. Otherwise the number of DLL plugins could become very large.
QuoteIs there a way of playing CDs through BassBox
This is the
BassBox 1.00e version with full
CD-Audio support.
It comprises advanced features to detect device arrival or remove as well as WM_QUERYCANCELAUTOPLAY to get rid of the OS message notification when adding/removing external device or CD-ROM:
WM_QUERYCANCELAUTOPLAY = RegisterWindowMessage("
QueryCancelAutoplay")
CASE WM_QUERYCANCELAUTOPLAY
FUNCTION = 1: EXIT FUNCTION '// To get rid of the OS autoplay message notification
CASE %WM_DEVICECHANGE
LOCAL DevHDR AS DEV_BROADCAST_HDR PTR
LOCAL DevVOL AS DEV_BROADCAST_VOLUME PTR
LOCAL DriveType AS LONG
IF wParam = %DBT_DEVICEREMOVECOMPLETE OR wParam = %DBT_DEVICEARRIVAL THEN
IF lParam THEN
DevHDR = lParam
IF @DevHDR.dbch_devicetype = %DBT_DEVTYP_VOLUME THEN
DevVOL = lParam
'/IF (@DevVOL.dbcv_flags AND %DBTF_MEDIA) THEN ' For digital camera detection
Dsk$ = CHR$(91 - INSTR(BIN$(@DevVOL.dbcv_unitmask, 26), "1")) + ":"
szFileName = Dsk$ + $Anti
DriveType = GetDriveType(szFileName)
hList = zGetMainItem(%ID_PlayList)
IF wParam = %DBT_DEVICEREMOVECOMPLETE THEN
IF DriveType = %DRIVE_CDROM THEN
'// If we are already playing a cd-rom then stop Bass audio
IF gnAudioChannel AND gnMediaType = %CDAUDIO THEN
CALL BassChannelStop()
CALL BassFree()
'// Clear caption
CALL ShowWindow(zGetMainItem(%ID_TAG_TITLE), %SW_HIDE)
CALL ShowWindow(zGetMainItem(%ID_TAG_ALBUM), %SW_HIDE)
CALL ShowWindow(zGetMainItem(%ID_TAG_ARTIST), %SW_HIDE)
CALL ShowWindow(zGetMainItem(%ID_TAG_TYPE), %SW_HIDE)
CALL ShowWindow(zGetMainItem(%ID_TAG_EMPTY), %SW_HIDE)
'// Restore audio default
CALL BassSetDefaultAudio()
CALL ListDeleteAll(hList)
CALL ListAdd(hList, gzAudioFile)
CALL ListSelectPlus(hList, 1)
gnPlayMode = %FORWARD
CALL EnableWindow(zGetMainItem(%ID_LEFTBUTTON), %FALSE)
CALL EnableWindow(zGetMainItem(%ID_RIGHTBUTTON), %FALSE)
CALL ShowWindow(zGetMainItem(%ID_BTN_PAUSE), %SW_HIDE): CALL zSetZorder(zGetMainItem(%ID_BTN_PAUSE), %HWND_BOTTOM)
CALL ShowWindow(zGetMainItem(%ID_BTN_PLAY), %SW_SHOW): CALL zSetZorder(zGetMainItem(%ID_BTN_PLAY), %HWND_TOP)
gnAudioPause = %FALSE
END IF
END IF
ELSEIF wParam& = %DBT_DEVICEARRIVAL THEN
IF DriveType = %DRIVE_CDROM THEN
'// Perform media detection
nCount = 0
CALL ListDeleteAll(hList)
nCheck = BassCheckExtension(szFileName)
IF nCheck = 1 THEN
IF ListAdd(hList, szFileName) > -1 THEN INCR nCount
ELSEIF nCheck = 2 THEN '// ".bbp" BassBox Playlist
nCheck = 0: zPlayList = szFileName
DO WHILE nCheck = 0
szFileName = LTRIM$(zsBufin(zPlayList, nCheck))
IF LEN(szFileName) THEN
IF ListAdd(hList, szFileName) > -1 THEN INCR nCount
END IF
LOOP
nCheck = 0
ELSE '// Browse for folders
nCount = nCount + RecursiveSearch(szFileName, hList)
END IF
IF nCount THEN CALL PlayListPlay(hList, nCount)
END IF
END IF
END IF
END IF
END IF
Note: When you insert a CD-ROM, BassBox stops the OS message notification and checks the media looking for audio files and if it founds audio, then it starts playing them in sequence.
When you remove CD-ROM, BassBox performs HOT detection to stop playing if it was already in CD-AUDIO mode, then it switches back to the default audio (same than when you start BassBox first time).
QuoteSUB BassSetDefaultAudio()
gzAudioFile = zsExePath() + "BassBox.mp3"
IF zsExist(gzAudioFile) = 0 THEN gzAudioFile = zsExePath() + "BassBox.mod"
END SUB
See the first post of this thread to download the latest version 1.00e from december 15, 2007...
Wonderful Patrice!
Now to visualise the CD collection.
I've updated 'Cartesian'. The fft samples now move away and fade into the distance. I think it works well with quiet or ambient music.
THanks guys nice updates.
Charles, it would be nice to have a toggle to switch from classic to new version for cartesian... or over time switch automatically between the 2.
I love the new look, don't get me wrong... but I also like the original look too. So I miss it also.
I guess the next problem to solve it plugin organization on the player. I guess another row could be added or a pop menu for each plugin artist.
- plgns - plgns - plgns
| | |
o PT o PS o CP
I forgot to say about the new CD-Audio feature, that you are not limited to play only .cda, but of course any CD or DVD using embedded subfolders and any kind of supported BassBox audio file.
And by the way, it could work the same with USB key.
Hi,
thanks for new release.
I tried the player for the first time with CDs, and it worked great!
Only which it could not play was one CD which is supposed to be CD Plus (?).
The "music tower" can play it as it would be normal audio CD, but BassBox not. But this in only one CD from all I have of this type, so not much problem :)
Thanks,
Petr
P.S. Charles - new version looks very nice !
The first of the soundscape plugins -A glacial landscape. This terrain needs no texture! It works best with harmonically rich pieces. I have been playing Mike Oldfields 'Songs of Distant Earth' to test it.
There is an art to synthesising textures that dont pixelate - I am learning slowly.
I have just started using USB flash drives for backup. For a fiver, I can store all my programes in less then a tenth of one of these.
PS: Kent, I will try to incorporate the original Cartesian with the new one. A forward gear somewhere.
Soundscape is really cool. Of course I went with playing the opposite of mellow and made it spike all over the place.
Then I went with The Chamber... and it was very nice as you said.
Great idea for a plugin!
BassBox version 1.00f from december, 16, 2007
Allows you to use an unlimited number of plugins
See the ZIP file attached to the first post (http://www.jose.it-berater.org/smfforum/index.php?topic=1364.0) of this thread.
...
I have updated the BassBox 1.00f ZIP file, because I foget to put the new image resources being used to scroll the plugin's check boxes.
They are attached to this post for the guy who downloaded the zip file already
Just put them into the "\BassBox\resource\" folder.
...
That is a nice elegant solution Patrice, thanks.
I have attached the new BassBox version 1.07a to the first post of this thread.
This version reduces both the memory footprint and CPU usage.
I did also several changes to force BASS.DLL to clean its memory when playing audio in loop mode.
The BBPlugin Init mode has been reworked for better texture management and plugin isolation.
Charles's "Soundscape" has been added to the project.
...
Thanks Patrice, going to download it now.
Looks and runs great, thanks guys. Flipping through the plugins, an idea occurred for a new feature.
That is user set time to flip through the plugins on its own. So it would take that time, after it elapses switch to the next plugin.
Now for some plugins that might need more time... like soundscape... maybe each plugin can have a mimimum time it needs before it would allow switching.
So maybe soundscape would say 30 seconds before it is allowed to switch.
I know lots of work, but some thoughts that came to me while enjoying the lastest cool version!
BassBox has been updated to version 1.10
A new OSCILLOSCOPE control has been added to monitor the playing audio in real time.
In order to use this feature you must set your multiplex audio card in "Stereo" or "What you hear" mode.
Note: So far i didn't checked it with XP.
The zip is attached to the first post of this thread, and the screen shot has been updated.
For those who like to know what is going on behind the hood, here is the code of the "Monitoring section":
'*****************************************************************************************************
'// Monitoring audio section
'*****************************************************************************************************
%MAXPNAMELEN = 32 ' max product name length (including NULL)
%CALLBACK_WINDOW = &H10000 ' dwCallback is a HWND
%HEAP_ZERO_MEMORY = &H00000008
%MM_WIM_DATA = &H3C0
%WM_WAVE_INIT = %WM_USER + 1
TYPE WAVEHDR
lpData AS ASCIIZ PTR
dwBufferLength AS DWORD
dwBytesRecorded AS DWORD
dwUser AS DWORD
dwFlags AS DWORD
dwLoops AS DWORD
lpNext AS LONG
Reserved AS DWORD
END TYPE
TYPE WAVEINCAPS
wMid AS WORD
wPid AS WORD
vDriverVersion AS DWORD
szPname AS ASCIIZ * %MAXPNAMELEN
dwFormats AS DWORD
wChannels AS WORD
wReserved1 AS WORD
END TYPE
TYPE WAVEFORMATEX
wFormatTag AS WORD
nChannels AS WORD
nSamplesPerSec AS DWORD
nAvgBytesPerSec AS DWORD
nBlockAlign AS WORD
wBitsPerSample AS WORD
cbSize AS WORD
END TYPE
DECLARE FUNCTION waveInGetNumDevs LIB "WINMM.DLL" ALIAS "waveInGetNumDevs" () AS LONG
DECLARE FUNCTION waveInGetDevCaps LIB "WINMM.DLL" ALIAS "waveInGetDevCapsA" (BYVAL uDeviceID AS DWORD, lpCaps AS WAVEINCAPS, BYVAL uSize AS DWORD) AS LONG
DECLARE FUNCTION GetProcessHeap LIB "KERNEL32.DLL" ALIAS "GetProcessHeap" () AS LONG
DECLARE FUNCTION HeapAlloc LIB "KERNEL32.DLL" ALIAS "HeapAlloc" (BYVAL hHeap AS DWORD, BYVAL dwFlags AS DWORD, BYVAL dwBytes AS DWORD) AS DWORD
DECLARE FUNCTION HeapFree LIB "KERNEL32.DLL" ALIAS "HeapFree" (BYVAL hHeap AS DWORD, BYVAL dwFlags AS DWORD, BYVAL lpMem AS DWORD) AS LONG
DECLARE FUNCTION waveInStop LIB "WINMM.DLL" ALIAS "waveInStop" (BYVAL hWaveIn AS DWORD) AS LONG
DECLARE FUNCTION waveInReset LIB "WINMM.DLL" ALIAS "waveInReset" (BYVAL hWaveIn AS DWORD) AS LONG
DECLARE FUNCTION waveInUnprepareHeader LIB "WINMM.DLL" ALIAS "waveInUnprepareHeader" (BYVAL hWaveIn AS DWORD, lpWaveInHdr AS WAVEHDR, BYVAL uSize AS DWORD) AS LONG
DECLARE FUNCTION waveInClose LIB "WINMM.DLL" ALIAS "waveInClose" (BYVAL hWaveIn AS DWORD) AS LONG
DECLARE FUNCTION waveInOpen LIB "WINMM.DLL" ALIAS "waveInOpen" (lphWaveIn AS DWORD, BYVAL uDeviceID AS DWORD, lpFormat AS WAVEFORMATEX, BYVAL dwCallback AS DWORD, BYVAL dwInstance AS DWORD, BYVAL dwFlags AS DWORD) AS LONG
DECLARE FUNCTION waveInPrepareHeader LIB "WINMM.DLL" ALIAS "waveInPrepareHeader" (BYVAL hWaveIn AS DWORD, lpWaveInHdr AS WAVEHDR, BYVAL uSize AS DWORD) AS LONG
DECLARE FUNCTION waveInAddBuffer LIB "WINMM.DLL" ALIAS "waveInAddBuffer" (BYVAL hWaveIn AS DWORD, lpWaveInHdr AS WAVEHDR, BYVAL uSize AS DWORD) AS LONG
DECLARE FUNCTION waveInStart LIB "WINMM.DLL" ALIAS "waveInStart" (BYVAL hWaveIn AS DWORD) AS LONG
%NUMBUF = 16
FUNCTION zPaintCapture(BYVAL hWnd AS LONG, BYVAL hDC AS LONG, BYVAL Action AS LONG) AS LONG
'LOCAL rc AS RECT
LOCAL hDCTemp, hPaintBitmap AS LONG
'CALL GetClientRect(hWnd, rc)
IF Action THEN
' Create OFF screen bitmap to avoid flickering and allow smooth display
' ---------------------------------------------------------------------
IF zGetPaintBitmap(hWnd) THEN
FUNCTION = zGetPaintDC(hWnd)
ELSE
hDCTemp = CreateCompatibleDC(hDC)
hPaintBitmap = zCreateDIBSection(hDC, 128, 63, 32)
CALL SelectObject(hDCTemp, hPaintBitmap)
CALL zSetProperty(hWnd, %FORM_PaintDC, hDCTemp)
CALL zSetProperty(hWnd, %FORM_PaintBitmap, hPaintBitmap)
FUNCTION = hDCTemp
END IF
ELSE
' End of OFF screen drawing, fast BitBlt to the target display Window
' -------------------------------------------------------------------
' Draw final result to the target window
CALL BitBlt(hDC, 0, 0, 128, 63, zGetPaintDC(hWnd), 0, 0, %SRCCOPY)
END IF
END FUNCTION
SUB DrawWave(BYVAL hWnd AS LONG, BYVAL pInteger AS INTEGER PTR)
LOCAL rc AS RECT
LOCAL x, y, x1, y1, C, nVol, hDC, graphics AS LONG
LOCAL hDCView, UseColor, YFactor, n64, n127, nPlaying AS LONG
LOCAL UseGain AS SINGLE
STATIC nTick, nDelay, xPos, WasVol AS LONG, WasGain AS SINGLE
INCR nTick: IF nTick > 1 THEN nTick = 0: EXIT SUB '// To reduce the CPU usage.
CALL GetClientRect(hWnd, rc)
YFactor = 1074 ' &H0FFFF \ (rc.nBottom - 2)
hDCView = GetDC(hWnd)
hDC = zPaintCapture(hWnd, hDCView, 1)
CALL GdipCreateFromHDC(hDC, graphics)
n64 = rc.nBottom \ 2: n127 = rc.nBottom - 1
CALL zsGdipFillRect(graphics, 0, 0, rc.nRight, rc.nBottom, zColorARGB(255, 0) )
CALL zsGdipLine(graphics, 0, n64 + 1, rc.nRight, n64 + 1, zColorARGB(255, RGB(48,48,32)) )
nPlaying = 0
IF IsWindowVisible(GetDlgItem(zMainWindow(0), %ID_BTN_Play)) = 0 THEN
nVol = zGetTrackValue(zGetMainItem(%ID_TRACK_VOL))
IF WasGain = 0 THEN WasVol = -1
IF nVol <> WasVol THEN '// This to save a few CPU cycles and avoid SQR computation
UseGain = 1 '// when it is not required.
IF nVol < 50 THEN
UseGain = MAX(9 * (SQR((100 - nVol) / 50) * 1.8 - 2), 1.0)
ELSEIF nVol > 60 THEN
UseGain = MAX(SQR((110 - nVol) / 50), 0.1)
END IF
WasGain = UseGain
ELSE
UseGain = WasGain
END IF
WasVol = nVol
FOR x = 0 TO 127' 0 TO 255
y = (rc.nBottom - (((@pInteger * UseGain) + &H7FFF) \ YFactor))
IF nPlaying = 0 THEN
IF ABS(y) > 3 THEN nPlaying = -1
END IF
IF x THEN
C = 32 - CLNG(y * 0.5) ' (32 / rc.nBottom))
CALL zsGdipLine(graphics, x1, y1, x, y, zColorARGB(255, LevelColr(C)) )
END IF
x1 = x: y1 = y
FOR C = 1 TO 2: INCR pInteger: NEXT
NEXT
END IF
IF nPlaying THEN UseColor = &H303030 ELSE UseColor = &H600000&
CALL zsGdipLine(graphics, xPos, 0, xPos, n64, zColorARGB(255, UseColor) )
CALL zsGdipLine(graphics, xPos, n64 + 2, xPos, rc.nBottom, zColorARGB(255, UseColor) )
IF nDelay = 0 THEN INCR xPos: IF xPos > rc.nRight THEN xPos = 0
INCR nDelay: IF nDelay = 4 THEN nDelay = 0
CALL zPaintCapture(hWnd, hDCView, 0)
CALL GdipDeleteGraphics(graphics)
CALL ReleaseDC(hWnd, hDCView)
END SUB
FUNCTION AudioProc (BYVAL hWnd AS LONG, BYVAL wMsg AS LONG, BYVAL wParam AS LONG, BYVAL lParam AS LONG) AS LONG
LOCAL K, hResource AS LONG, pWaveHdr AS WAVEHDR PTR
STATIC gWaveBuf() AS WAVEHDR, gHwi AS LONG
SELECT CASE LONG wMsg
CASE %WM_WAVE_INIT
LOCAL wic AS WAVEINCAPS
LOCAL wfx AS WAVEFORMATEX
LOCAL nRet, nDev AS LONG
nDev = WaveInGetNumDevs()
nRet = 22 ' "No suitable device found"
FOR K = nDev - 1 TO 0 STEP -1
IF WaveInGetDevCaps(K, wic, LEN(WAVEINCAPS)) = 0 THEN
IF INSTR(LCASE$(wic.szPname), "micro") = 0 THEN ' We don't want the microphone
wfx.nChannels = 2
wfx.nSamplesPerSec = 44100
wfx.wFormatTag = 1 ' %WAVE_FORMAT_PCM
wfx.wBitsPerSample = 16
wfx.nBlockAlign = wfx.nChannels * wfx.wBitsPerSample \ 8
wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign
wfx.cbSize = 0
nRet = waveInOpen(gHwi, K, wfx, hWnd, hWnd, %CALLBACK_WINDOW)
IF nRet = 0 THEN EXIT FOR
ELSE
nRet = 22 ' "No suitable device found"
END IF
END IF
NEXT
IF nRet = 0 THEN
REDIM gWaveBuf(%NUMBUF)
FOR K = 1 TO %NUMBUF
gWaveBuf(K).lpData = HeapAlloc(GetProcessHeap(), %HEAP_ZERO_MEMORY, 1024)
IF gWaveBuf(K).lpData THEN
gWaveBuf(K).dwBufferLength = 512 ' 1024
ELSE
nRet = 1003 ' "Unable to complete this function"
EXIT FOR
END IF
NEXT
IF nRet = 0 THEN
FOR K = 1 TO %NUMBUF
nRet = waveInPrepareHeader(gHwi, gWaveBuf(K), LEN(WAVEHDR))
IF nRet THEN
EXIT FOR
ELSE
nRet = WaveInAddBuffer(gHwi, gWaveBuf(K), LEN(WAVEHDR))
IF nRet THEN EXIT FOR
END IF
NEXT
IF nRet = 0 THEN
nRet = WaveInStart(gHwi)
END IF
END IF
END IF
IF nRet THEN gHwi = 0
FUNCTION = nRet
EXIT FUNCTION
CASE %MM_WIM_DATA
' We have data
pWaveHdr = lParam
CALL DrawWave(hWnd, @pWaveHdr.lpData)
' Put the buffer back to be reused
IF WaveInPrepareHeader(gHwi, BYVAL pWaveHdr, LEN(WAVEHDR)) = 0 THEN
CALL WaveInAddBuffer(gHwi, BYVAL pWaveHdr, LEN(WAVEHDR))
END IF
EXIT FUNCTION
CASE %WM_DESTROY
' Deallocate system resources
' // Clear paint resources
hResource = zGetPaintBitmap(hWnd)
CALL zDeleteObject(hResource): CALL zSetProperty(hWnd, %FORM_PaintBitmap, hResource)
' // Delete DC
hResource = zGetPaintDC(hWnd)
IF hResource THEN CALL DeleteDC(hResource): hResource = 0: CALL zSetProperty(hWnd, %FORM_PaintDC, hResource)
IF gHwi THEN
CALL WaveInStop(gHwi)
CALL WaveInReset(gHwi)
FOR K = 1 TO %NUMBUF
CALL waveinUnprepareHeader(gHwi, gWaveBuf(K), SIZEOF(WAVEHDR))
NEXT
CALL WaveInClose(gHwi)
' DeallocBuffers
FOR K = 1 TO %NUMBUF
IF gWaveBuf(K).lpData THEN
CALL HeapFree(GetProcessHeap(), %HEAP_ZERO_MEMORY, gWaveBuf(K).lpData)
END IF
NEXT
END IF
END SELECT
FUNCTION = DefWindowProc(hWnd, wMsg, wParam, lParam)
END FUNCTION
FUNCTION zOscillo(BYVAL hParent AS LONG, BYVAL x AS LONG, BYVAL y AS LONG, BYVAL W AS LONG, BYVAL H AS LONG, BYVAL ID AS LONG) AS LONG
LOCAL wc AS WndClassEx
LOCAL zClass AS ASCIIZ * 16
LOCAL IsInitialized, hWnd AS LONG
zClass = "ZOSCILLO"
wc.cbSize = SIZEOF(wc)
IsInitialized = GetClassInfoEx(zsInstance, zClass, wc)
IF IsInitialized = 0 THEN
wc.cbSize = SIZEOF(wc)
wc.style = 0
wc.lpfnWndProc = CODEPTR(AudioProc)
wc.cbClsExtra = 0
wc.cbWndExtra = %EXTEND_EXTRA * 4
wc.hInstance = zsInstance
wc.hIcon = %NULL
wc.hCursor = %NULL
wc.hbrBackground = %NULL
wc.lpszMenuName = %NULL
wc.lpszClassName = VARPTR(zClass)
wc.hIconSm = %NULL
IF RegisterClassEx(wc) THEN IsInitialized = -1
END IF
IF IsInitialized THEN
hWnd = CreateWindowEx(0, zClass, "", %WS_CHILD OR %WS_VISIBLE, x, y, W, H, hParent, ID, zsInstance, BYVAL %NULL)
IF hWnd THEN
IF AudioProc(hWnd, %WM_WAVE_INIT, 0, 0) = 0 THEN
FUNCTION = hWnd
ELSE
CALL DestroyWindow(hWnd)
END IF
END IF
END IF
END FUNCTION
Hi Patrice,
very nice! Really smooth, really live!
It runs on XPs without any touch to sound or soundcard settings.
Thanks,
Petr
It is working, but I am not getting anywhere near an active wave as you have in your screenshot Patrice. I just get a slight vibration to a horizontal line. I only have a built in audio chip on my motherboard at the moment. No nice creative labs card. That is probably it. From the screenshot it looks very nice. The leds on the sides work fine however.
Also one other thing... when I switch plugins from 1 to 2 to 3 to 4, the music stutters when changing plugins, but the later ones don't. Has anyone had a similar problem?
Kent
In order to monitor audio in real time and draw the oscilloscope, BassBox uses WaveInGetDevCaps to detect the record device, if none is available then you will see a flat line instead of what is shown on the screen shot.
This means you must set your audio card in multiplex mode "stereo" or "what you hear" or "Wave out mix" mode.
What I could do, is to check first if there is any available Wave device capture, and if none then keep the previous display i had in older version.
When you refer to plugins, please use their name not the number, because the order may vary from one computer to the other. For example some plugins may have been desactivated or missing or some of us can have plugins that haven't been made public.
BassBox has been updated to version 1.11 (zip file is attached to the first post of this thread)
The new OSCILLOSCOPE control has been reworked for better audio card detection and to lower the CPU usage.
Note: this feature is disabled if your computer doesn't have a multiplex audio card.
The wave device detection now ignores "microphone" and looks only for multiplex line in.
...
Patrice, thanks it runs very smoothly now and no stutters when switching between plugins! Very nice. Thanks for the quick update!
Indeed, i could pass the wave buffer pointer (@pWaveHdr.lpData) to BBPlugin as i am doing with FFT.
Then we could use it to draw 256 points into the visual plugin for each frame, and/or mix it together with current peak and fft drawing.
I could also pass the whole duration and current elapsed time, to perform introduction or shutdown effects matching the active music being played.
Note: all drawings done in the oscilloscope are done with GDIPLUS, to be compatible with the VISTA DWM composited mode.
I could even draw the scope directly in "Blur" or "Crystal" mode.
...
BassBox has been updated to version 1.20.
The OSCILLOSCOPE control has been rewritten, and now it doesn't requires anymore a multiplex audio card.
CPU usage has been further reduced, and the drawing of the oscillo curve is more accurate and independant of the volume level.
The BBPLUGIN structure has a new WIMdata member:
TYPE BBPLUGIN '// 256 bytes
Msg AS LONG '// The plugin's message (see above constant list).
ParentWindow AS LONG '// The parent window handle.
DC AS LONG '// The parent window DC (while in play mode).
RC AS LONG '// The parent OpenGL RC (while in play mode).
Lpeak AS WORD '// The left audio channel peak value (while in play mode).
Rpeak AS WORD '// The right audio channel peak value (while in play mode).
Title AS ASCIIZ * 32 '// Plugin's name or title.
Author AS ASCIIZ * 64 '// Plugin's author name.
Version AS DWORD '// LOWRD major, HIWRD minor.
RenderTo AS LONG '// %BBP_GDIPLUS, %BBP_OPENGL, %BBP_DIRECTX.
BackARGB AS LONG '// Default ARGB color background.
FFTdata AS DWORD '// DWORD pointer to the FFT() AS SINGLE array.
FFTsize AS WORD '// Size of the FFT array.
WinMsg AS LONG '// True Windows message.
wParam AS LONG '// wParam
lParam AS LONG '// lParam
WIMdata AS DWORD '// DWORD pointer to the wave MM_WIM_DATA.
Reserved AS ASCIIZ * 106'// Reserved for future extension.
END TYPE
I shall write a new visual plugin to show you how to use the WIMdata pointer.
The latest zip file is attached to first post of this thread. (http://www.jose.it-berater.org/smfforum/index.php?topic=1364.0)
...
Patrice it is working perfectly. Very nice to see the scope have nice waves on it. Thanks for making it work with the onboard sound processor!!
Thanks for the nice new plugin and example Patrice. Looks and works great!
To decode WIMdata into your plugin use something like that:
'// WIM MAGIC!
'// BBP.WIMdata returns a pointer to an area of memory containing an array of 256 short integer.
'// It is then mapped to the WIM() array where it can be accessed.
DIM WIM(255) AS INTEGER
FOR K = 0 TO 255: WIM(K) = PEEK(INTEGER, BBP.WIMdata + K * 4): NEXT
'// Warning, Left and Right audio channels are mixed together, thus use step 4, to pick only one.
And to retrieve both channels (left and right) use something like this:
DIM WIM(0 TO 255, 1 TO 2) AS INTEGER
DIM K, Offset AS LONG
FOR K = 0 TO 255
Offset = K * 4
WIM(K, 1) = PEEK(INTEGER, BBP.WIMdata + Offset)
Offset = Offset + 2
WIM(K, 2) = PEEK(INTEGER, BBP.WIMdata + Offset)
NEXT
Note: In the "Oscilloscope" plugin demo and in the zOscillo control we display only the first 128 values.
...
Thanks Patrice,
very hypnotizing!
First it GPFed, I thought that is Christmas surprise of my localised XPs, then I realised I need latest BassBox.
With that it works perfectly. Very smooth!
Bye,
Petr
BassBox has been update to
version 1.21, the zip file is attached to the first post of this thread and the screen shot has been updated.
The new plugin "Oscilloscope" has been reworked to show you how to use the new members of the BBPLUGIN structure:
- BBP.WIMdata
- BBP.MediaLength
- BBP.MediaPos
The "Oscilloscope" displays both the left and right audio channels, and it uses MediaLength and MediaPos to change the effect based on the media progression (search for "percent" in the source code).
'// Draw left channel
CALL glPushMatrix()
percent = (BBP.MediaPos * 100) / BBP.MediaLength
IF percent > 99 THEN PulseAngle = 0
IF percent < 33 OR percent > 66 THEN
CALL glRotatef(-PulseAngle, 1.0, 0.0, 0.0)
ELSE
CALL glRotatef(-PulseAngle, 0.0, 1.0, 0.0)
END IF
CALL glTranslatef(0.0, -0.25, 0.0)
CALL glbegin(%GL_LINES)
FOR K = 0 TO 127
'// color range must fit between 0-32
ColorRange = 17 + (vf(K, stt, 1) / 0.09375)
IF Multiplan > 0 THEN ColorRange = ColorRange \ 2
RGBColor = LevelColr(ColorRange)
CALL glColor4ub(BBP_GetRValue(RGBColor), _
BBP_GetGValue(RGBColor), _
BBP_GetBValue(RGBColor), _
Fading)
CALL glvertex3f(-UseSize + UseSize * K / 64, vf(K, stt, 1), zS)
CALL glvertex3f(-UseSize + UseSize *(K + 1) / 64, vf(K + 1, stt, 1), zS)
NEXT
CALL glEnd()
CALL glPopMatrix()
'// Draw right channel
CALL glPushMatrix()
IF percent < 33 OR percent > 66 THEN
CALL glRotatef(PulseAngle, 1.0, 0.0, 0.0)
ELSE
CALL glRotatef(PulseAngle, 0.0, 1.0, 0.0)
END IF
CALL glTranslatef(0.0, 0.25, 0.0)
CALL glbegin(%GL_LINES)
FOR K = 0 TO 127
'// color range must fit between 0-32
ColorRange = 17 + (vf(K, stt, 2) / 0.09375)
RGBColor = LevelColr(ColorRange)
CALL glColor4ub(BBP_GetRValue(RGBColor), _
BBP_GetGValue(RGBColor), _
BBP_GetBValue(RGBColor), _
Fading)
CALL glvertex3f(-UseSize + UseSize * K / 64, vf(K, stt, 2), zS)
CALL glvertex3f(-UseSize + UseSize *(K + 1) / 64, vf(K + 1, stt, 2), zS)
NEXT
CALL glEnd()
CALL glPopMatrix()
The new members, MediaLength and MediaPos, are very handy to synchronized the effects with the current played media. See in the example how I am changing the orientation based on the elapsed time.
Also very useful to perform introduction or close sequence.
The "Oscilloscope" fading effects are based on Charles Pegge's "Cartesian array".
I have added two new static controls to display the media length and elapsed time in HH:MM:SS.
...
Make sure you use the latest BassBox version 1.21 from 12-24-2007.
Because the BBPLUGIN structure has changed, and the latest "Oscilloscope" plugin demo shows you, how to use the left and right audio channels altogether and the media length to perform additional effects.
See also the 2 new static controls over the player's navigate buttons.
...
The waves are dancing very nicely!! I like the new additions to the plugin Patrice, thanks as always!!
BassBox has been updated to version 1.22, with the new plugin "Man of Vitruve".
The latest ZIP file is attached to the first post of this thread.
...
Hi Patrice,
thanks a lot for new update.
I wonder where you get time to work on such a perfect additions!
Thanks,
Petr
Patrice, that is wonderful. I felt like I was in space watching a laser light show and "the man" being projected on a small nebula. Thanks!
Kent, Petr,
I always appreciate your faithful comments, thank you.
...
Very nice music Patrice, it goes really well with almost all the plugins, thanks very soothing.
New BassBox plugin "Fahrenheit 451"
(http://www.zapsolution.com/BassBox/Fahrenheit.jpg)
Hard to capture must be seen in real time.
See version 1.23
...
Patrice,
again fantastic job!
The "flames" cheated my eyes for long, only from source I could see they are cylinders :)
Great!,
Petr
Super Fantastic Incredibly Fabulous and these words are still not enough to capture the wonder of this plugin, THANKS Patrice!!
BassBox has been updated to
version 1.23.
See the first post of this thread to download the ZIP file.
Could you please let me know the FPS count you got (above the oscilloscope control)
- FPS count?
- CPU type?
- Speed in MHz?
- Graphic card?
- OS version?
Thank you
...
Hi Patrice,
Im getting 66 fps after the system settles, both with normal window and full screen (1680x1050)
Computer details:
HP Pavillion
AMD64X2 Dual
2 GHz
1 Gb RAM
NVIDIA GEFORCE 7600 GS
Windows XP home SP2
Hi,
AMD Sempron x64 3400+, 1.8 GHz
1024 DDR 400
GeForce 6150 LE, 256 MB
WinXP Home, SP2 + Updates
Framerate ( default size ; maximized at 1280x1024 ):
Sunlight 66 ; 60
Genesis 66 ; 27
DayOne 47-50 ; 20
CloseEncounterOf3rdKind 56-64 ; 35-53
Fahrenheit 66 ; 48-55
FireWorks 66 ; 66
Hal 66 ; 40
Impulse 66 ; 40
LaserBeam 66 ; 22-25
MagicDiamond 66 ; 66
TheMatrix 66 ; 66
Mikado 66 ; 66
Oscilloscope 66 ; 66
PopStar 66 ; 66
SoundScape 55-56 ; 16
Spectrum 66 ; 66
StickDance 66 ; 66
ManOfVirtuve 66 ; 27
Vulcan 45-47 ; 16
Woofer 66 ; 66
I got those settings with forced V-Sync off in drivers, although not sure if driver does not lie - I get usually much higher framerates in other PB and especially thinBASIC apps ( hundreds of FPS ).
As you can see, my card is a bit sensitive to fullscreen blending FX :)
16 FPS results are quite ridiculous - I think there is really something wrong in driver, problematic plugins are not that complex to kick my card that much down. I will investigate on this further.
Thanks,
Petr
Here are my own results:
- OS: VISTA with DVM compositing ON (switching DWM On/Off doesn't change anything)
- Dual monitor in 1680 x 1050 and 1440 x 900.
- CPU Intel Dual Core 2, T7200 at 2GHz.
- nVidia GeForce GO 7600 with 512 Mb.
Default Maximized
Sunlight 66 66
Cartesian Space 66 62
Genesis 62 50
Day One 62 62
Close Encounter 66 66
Fahrenheit 451 62 62
Fireworks 66 66
HAL 62 62
Impulse 66 66
Laser Beam 62 62
Magic Diamond 66 66
The Matrix 66 66
Mikado 66 66
Oscilloscope 66 66
Pop Star 66 66
Soundscape 66 40 (sound alteration in Max mode)
Spectrum 66 66
Stick Dance 66 66
Man of Vitruve 62 62
Vulcan 66 40 (sound alteration in Max mode)
Woofer 62 62
Note: it also important to check for CPU usage...
-
Oscilloscope uses 0% in both default and maximized.
-
Vulcan uses 45-50% in maximized mode (that is the cause of the sound alteration).
The
BassBox CPU usage average is
3 x smaller than
Windows Media
So far, 66 FPS seems to be the average value, wathever the OS being used.
On my system, Vulcan runs at 66 fps in max mode, and I can't recall any disruption to the sound quality, but the animation is often quite jumpy, even though this does not show up in the fps figure.
One solution might be to reduce the frame rate to around 24-36 fps but this will not resolve the problem of jerky animation. The plugin needs to calculate its next frame using lapsed time rather than frame count, since the Windows timer message can be quite irregular.
BassBox uses 9 threads.
I got 66fps on all the plugins at the default window size.
HP Pavillion
AMD64X2 Dual
2 Gb RAM
NVIDIA GEFORCE 7300 LE
Windows XP home SP2
Because you liked "Fahrenheit 451",
here is another plugin specifically designed to work in full screen (to better see the details).
Light Show, looks like an electronic panel with light emitting diodes.
See attached LightShow.zip file.
Try it with "Disco remix" music!!!
...
Way beyond beautiful and awesome... another one that makes me think the plug-ins can't get any better and then you make it so. This is really something to look at and magical, THANKS!!
This is a version of Vulcan that renders on alternate frames, which should average to around 33 fps.
It seems to run a little smoother on my system, but more importantly, I hope it will reduce the load on other systems so that sound is not disrupted in Max Mode.
On my HP Pavillion, Vulcan in Max Mode now requires about 5% CPU without music and 10% with music playing.
If this works well on your system then it may be the best solution for complex rendering. It also provides an opportunity for 2 stage processing: for example preparing some compiled glLists on the first stage and rendering the scene in the second.
Thanks,
really great plugins again!
Charles - CPU load is ok on my PC, great!
Maybe you could use mipmapping or aniso for the Vulcan object ?
This will eliminate unwanted "pixel dance" on inclined polygons and could also lead to much smoother look ?
Thanks,
Petr
I never really checked the cpu usage, but I have had no problems with Vulcan or anything that stood out as strange. I will install the new one after I look at the old one for awhile to see if I notice anything.
You guys are so good, not only to come up with neat stuff but then to go back and optimize and optimize, the masters at work!
I have added more features to the new "Light Show" plugin.
- Unzip Texture.zip into the BBPlugin\Texture folder
See in
popcorn.zip the OGG audio file to play with it.
...
--Charles
I still have problems with Vulcan on VISTA in full screen mode: causing sound distortion and jerky move.
Sorry.
...
Thanks for the feedback.
Here's another version of Vulcan which reduces 'dancing pixels' on the sloping terrain and I hope will improve the sound situation in Vista.
Making use of the GDIplus Thumbnail function, I have brought the texture resolution down to 128x128. Since I use the texture hundreds of times, this will substantially reduce the image rendering load on the GPU and whatever other machinations are imposed by Vista.
--Charles
The last version of Vulcan has solved the problems!
Now i got 66 FPS even in full screen, and without any sound distortion.
Could you do the same for Soundscape?
Thanks!
--Light Show II
What do you think would be the best way to detect when the PulseAngle is reaching 90° (to swap the textures).
I am currenty doing this:
STATIC TT AS LONG, WasPulse AS SINGLE
PulseAngle = (PulseAngle + pulse) MOD 360
IF PulseAngle \ 90 = 1 AND WasPulse < 90 THEN INCR TT: IF TT > 7 THEN TT = 0
IF TT = 0 THEN TT = 1
WasPulse = PulseAngle
...
Thanks for the new files guys. All works fine and dandy!
Charles,
it works very fast now. I think the texture size should not hurt performance so much, maybe the original filtering fell for some reason to SW render?
Now it looks very nice!
Patrice, thanks for new music :)
Petr
This Soundscape has been extensively rewritten. It is a much smaller DLL and compiles landscape ribbons into glLists - regenerating only one ribbon per frame. It also uses very small textures (16x16), generated from scratch. So it will sit lightly on most systems, I hope.
Works well with the new music.
PS: Updated soundscape.zip posted further down
Patrice: RE:
STATIC TT AS LONG, WasPulse AS SINGLE
PulseAngle = (PulseAngle + pulse) MOD 360
IF PulseAngle \ 90 = 1 AND WasPulse < 90 THEN INCR TT: IF TT > 7 THEN TT = 0
IF TT = 0 THEN TT = 1
WasPulse = PulseAngle
I have recently developed an allergy to long division: (CPU and FPU divs take about 50 clocks!). It is now part of my New Year's resolutions to advocate avoiding it wherever possible.
but this should do the same job:
STATIC TT AS LONG
PulseAngle=PulseAngle + Pulse
IF PulseAngle>360 THEN PulseAngle = PulseAngle -360: INCR TT: IF TT > 7 THEN TT = 0
' then adjust glRotate3f to get the 90 degree changeover
Quote
STATIC TT AS LONG
PulseAngle=PulseAngle + Pulse
IF PulseAngle>360 THEN PulseAngle = PulseAngle -360: INCR TT: IF TT > 7 THEN TT = 0
' then adjust glRotate3f to get the 90 degree changeover
--Charles
I come to the same conclusion and wrote that one
STATIC TT AS LONG, WasPulse AS SINGLE
IF PulseAngle > 360 THEN PulseAngle = PulseAngle -360
IF PulseAngle > 90 AND WasPulse < 90 THEN INCR TT: IF TT > 7 THEN TT = 0
IF TT = 0 THEN TT = 1
WasPulse = PulseAngle
Thank you
--Charles
The new Soundscape works now at 66 FPS in full screen mode, without any sound distortion, good job!
Just one thing, I liked better the white color than this green one...
...
It is really flickering for me now, the new soundscape. Have no idea why?
This is how it appears on my PC.
It renders on alternate frames like Vulcan, and should run very smoothly without flickering and very low pixelation effects. The transparent blue layers cause a small tonal change every second or so but this should not be noticible unless you are looking for it.
I can't see any other causes of flickering at present, but maybe in the early hours..
Can you describe what the flickering is like, Kent: frequency, regularity etc?
The texture can be turned off by suppressing one line in the Render_scene subroutine:
glEnable GL_TEXTURE_2D
glCallList stt+16
glDisable GL_TEXTURE_2D
I found an extra Glend which should not have been there. This could be disruptive, and may have caused the flicker problem that Kent found on his system.
So here is a corrected version.
The blue overlays have now been made static. It removes the slight tonal twitch that occurs every few seconds.
The coloring is not perfect but I will be working on it.
PS: Please see further down (page 26?) for updates and corrections
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
--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.
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 (http://www.zapsolution.com/BassBox/La_isla_bonita.ogg)
...
Here is another one to play with "ShowRoom"
http://www.zapsolution.com/BassBox/Madonna_feat_abba.ogg (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
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!
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.
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
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.
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.
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
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.
...
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!
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. :)
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
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.
These are two versions of Soundscape which should be free of glErrors, one of which Petr located in the Stars.
1. Soundscape.dll - a corrected version of the original with snowy peaks.
2. SoundscapeA.dll - an updated and racy version where the landscape is terraformed at the horizon, and flies forward at considerable speed.
I have switched back to using GDIplus. It is a little more suitable for our needs, but the FreeImage commands are still present in the TexImage Function, commented out. And it is nice to know that switching between the GDIplus and FreeImage is so easy.
Thanks Charles, the new A version is working nice and quickly but alas the flicker is back. The regular soundscape is working fine however now.
It must be something in my video card settings or installation as I am the only one having any problems, so don't worry about it.
I like this new version as the motion forward seems more natural and seeing the terrain in front spawning is nicer!
Kent, this is an attempt at resolving the flickering problem. If it happens on your PC, it is bound to happen on others.
The scene rendering system is now two stroke. The first phase, prepares landscape strips and compiles them as required. The second phase deals exclusively with rendering. So glList building is not mixed in with scene rendering any more.
This plugin generates timing data in a file called SoundScapeReport.txt in the BBplugin folder.
Timings vary a lot but a typical set of figures on my PC looks like this:
Soundscape Diagnostics
Time Stamp Values in NanoSeconds:
Phase 1 prepare scene: 270763
Phase 2 render scene: 560572
2 Frame Interval: 33073730
wglMakeCurrent: 186194
clear buffers etc: 6574
Error checks: 0 0 0
The rendering only takes about 2% of CPU time and this does not seem to change by going into Max mode on my system.
Thanks Charles, sorry to report flicker is there for soundscapeA, but soundscape original is fine.
The flicker is incredibly noticeable, and can be called tearing at fullscreen.
I do have vertical synch on in my video card as it says video synch set on with triple buffering gives good performance in speed. And I need that with this card as it is slow.
Here is my report listing, nice idea:
Soundscape Diagnostics
Time Stamp Values in NanoSeconds:
Phase 1 prepare scene: 18724440
Phase 2 render scene: 792080
2 Frame Interval: 80632500
wglMakeCurrent: 192911
clear buffers etc: 4451
Error checks: 0 0 0
Added after original post above:
Ok, I turned off vertical sync and disabled triple buffering, it cleared the problem. My frame rate went from 62fps to 66. Fullscreen there is a flicker now with 22fps but no massive tearing as before, obviously caused by slow video card.
Here is speed report with turned off settings:
Soundscape Diagnostics
Time Stamp Values in NanoSeconds:
Phase 1 prepare scene: 25743
Phase 2 render scene: 849023
2 Frame Interval: 58839843
wglMakeCurrent: 281991
clear buffers etc: 9880
Error checks: 0 0 0
Thanks Kent, that is very interesting. It may well be that Max Mode on 1280x1024 resolution is too close to the edge for many video cards. All the full-screen video games I have seen so far turn the resolution way down. This is disguised by clever shading but if you look at the screen closely, you can see how blocky they are. Online Java driven games tend to work the other way, often limiting the viewport to postcard size.
But hardware specs are evolving so rapidly - what was state-of-the-art four years ago is now standard kit for home PCs, so these limitations are likely to be very transient.
The performance data, averaged out over several frames can be used to control features or quality level.
The curious thing is that the Original Soundscape uses much more CPU than the new one - the entire landscape is generated with every frame without using glLists for the strips of landscape, yet your video card can handle it. Vulcan also works the video quite hard in terms of polygon count but mostly on a pre-compiled glList. I wonder if the performance of your card is limited by old drivers.
Hi Charles,
SoundscapeA rocks! That is exactly what I like!
Regarding technical issues, I still cannot see any problem here,
only tricky think could be creating display lists on the fly, not only in INIT section. I think this can make driver a bit scared, but as openGL reports no errors ... very interesting.
Regarding report, here it goes:
Soundscape Diagnostics
Time Stamp Values in NanoSeconds:
Phase 1 prepare scene: 16404
Phase 2 render scene: 883135
2 Frame Interval: 52824353
wglMakeCurrent: 129685
clear buffers etc: 176199
Error checks: 0 0 0
Kent, by flicker do you mean low framerate or really pulsing screen as on ZX spectum when too much lines rendered in combination with clear screen :) ?
Thanks,
Petr
Thanks Petr, if we can get this working reliably, the technique can be used for generating all sorts of non-repeating terrains.
Kent,
To test the hypothesis that generating gLists on-the-fly is causing the flicker I have added an invisible control to this version of Soundscape.
If you click on the top left corner of the scene (within 100 pixels) the landscape loop will be locked, and the landscape strip lists will not be renewed. The terrain will repeat itself in an endless loop and you will see gaps where it turns over. Clicking again will unlock the landscape enabling list generation again.
Locking the landscape in this way should eliminate the flicker. If not, then the problem lies elsewhere.
Thanks!
Indeed I can also see, from time to time, a kind of fugace redrawing echo that occured on the bottom of the screen especialy when there is a sound peak level
For me this is more an error in the programming loop, than a video graphic card problem.
I think that it occures while the current audio is being moved at the end of the list, then sometimes the peak are drawn hover the first plan, "looking like" flickering.
...
Guys, thanks for new versions. In regular screen size, it works fine. When I go fullscreen it steps and that is probably because of my video card not being able to handle the resolution at fullscreen.
Clicking on the corner made no difference in the stepping /flicker like feel. So it has to be my card. Since it runs fine at normal screen size, I am very happy, that is what I normally run it at unless I go to the couch and just relax and watch and listen from there.
Well that indicates the technique is basically sound, thank you Kent. I will just have to watch out for fall-offs in performance.
Another thing you may have noticed is that if you click on the Vulcan scene, the terrain stops moving momentarily - the picking procedure seems to be inefficient at checking through a large number of polygons. - it seems to be much slower than rendering, - probably doing most of the work client-side. So I'll have to simplify the scene construction when in SELECT mode, which can be easily done by reducing the recursion level. Each step reduces the polygon count by a factor of 4.
Patrice, I'll see if there is a way of clamping the frame rate more precisely. I think it can be done on the Plugin side, locking into 60 fps for example. This would help slow moving plugins.
--Charles
I have attached a modified version of SoundscapeAA.bas using WimDATA instead of FFT and a new OGG file to help you diagnostic the problems.
While playing bennybenassi.ogg you will see the flickering when there are huge peak levels, and also the sound distortion that could occure when playing full screen.
As i said already, the flickering is caused by the current curve being drawn in the front before being moved in the background.
To see the change i have done, search for '//PATRICE in the source code.
...
Scary peaks and fortresses of harmonics! After securing my speakers to the floor with Monti bolts, I played in full screen mode. but no audio distortion occurred on my XP machine.
In this version I have put in an attenuation function so their size will always be limited no matter what the volume might be - the peaks will scale down. Normal sensitivity is restored between tracks, when there is a mute period. Peaks at the very front will shrivel to minimise flashing in front.
Many thanks for giving this your attention Patrice, I hope the above steps will resolve the audio distortion on your system.
DO
IF k>=64 THEN EXIT DO
v=SQR(fft(k))*8*atten
IF v>4 THEN atten=4/v ' attenuation
IF v=0 THEN v=RND*.4: atten=1 ' restore sensitivity
vf(i1)=v
'vf(i1)=vf(i1)*.5+SQR(fft(k))*4 ' averaged height
INCR k: INCR i1
LOOP
--Charles
The new Soundscapea version solved the loop problem that caused the "flickering".
There is still sound distortion, however it could be very limited in using
v=SQR(fft(k+8))*8 ' avoid to use the first FFT values to suppress sharp drawing on the left side
instead of
v=SQR(fft(k))*8*atten
Soundscape Diagnostics
Time Stamp Values in NanoSeconds:
Phase 1 prepare scene: 21584748
Phase 2 render scene: 953664
2 Frame Interval: 41847564
Frame interval rt : 2.09685867896618E-2
Frame per sec rtt : 47.6903861014149
QueryPerformance Frequency: 14318180
QueryPerformance Counter: 50001799164
Time Stamp: 6968873829435
Error checks: 0 0 0
Yes adding an offset of 8 to avoid the base frequencies, gives a more even landscape. I have tried it with a variety of music and it looks okay. The base frequencies are quite interesting so I can still use them in another way.
But that that help to improve the audio quality on your PC?
The diagnostics show quite a high frame rate (it measures pairs of frames.). It should be around 30-33 but your sample shows 47 fps. The test only measures the last frame pair but I have not seen a figure that high on my machine.
--Charles
Yes, using an offset of 8 suppresses the lows level frequencie peak on the left and help to produce a softer landscape drawing.
I use the bennybenassi.ogg file to stress all my visual plugins and see if they don't produce audio distortion without using the equalizer. Of course if your turn On the equalizer altogether with bass boost, it is quite easy to produce saturation that would cause sound distortion.
My sample shows 47 fps, because I am using VISTA that is highly optimized to perform 3D operation and is a top notch for any intensive graphic application, on that aspect BassBox is a very good prototype to fetch the DWM VISTA limits.
All my tests are done in dual screen mode, with BassBox runing in 1680 x 1650 in plain 32-bit mode and full DWM composited mode.
The same thread handles OpenGL and GDIPLUS (the drawing of the view meter + oscilloscope). Audio decoding is processed in another thread.
...
I never heard distortion with the soundscapeA plugin, but I don't listen to music too loudly.
I do like the landscape with the new coding mods.
Charles, Is there a way to make the horizon wider so it goes off of the edge of the plugin screen?
It would look more like a planet's surface one was flying over that way.
This has been stretched in the X axis, so you have a full horizon, even on a wide screen. I would like to do a proper planetary surface so you could travel in any direction. but the logistics are more tricky for doing this.
But if you click on the scene then press the spacebar, you will be able to travel in reverse :)
Thanks Charles, looks and works great!!
--Charles
Here is my feedback for the new Soundscapea version.
- Sound distortion still there while playing in full screen, but only when using the second monitor in dual display mode.
- No sound distortion while playing in 1440 x 900 on my laptop built-in screen.
- Using full horizon, makes the whole scene more like a planet than in "star war" mode.
- Being able to swap between "far" and "near" is a nice addition.
- You can also use the new audio duration parameters to swap between far/near or fade in/fade out.
Many thanks, I am reworking the first soundscape. Did you get any audio distortion with that? It generates the landscape from scratch on every frame-so it works a lot harder CPU side but less work for the GPU because it uses GL_QUAD_STRIPs instead of isolated quads with individual textures.
And I didnt compile the planet either.
I hope to make use of the audio duration parameters very soon.
Hi Charles,
new version is very nice!
I am "sorry" to report I cannot experience any sound distortion :)
Bye,
Petr
Charles,
when I disable overlays I immediately get same FPS "fullscreen" and windowed.
What about replacing multiple blended polys with fog ? ( +possible one fake blue overlay ).
Blending is one of the perfect functions in OpenGL, but low end usually suffers on it a lot. As it is per pixel it is very resolution-sensitive.
OpenGL fog "classic" ( not via shader ) is per vertex operation, could give better speed and usable results :)
Bye,
Petr
Yes, I am trying a single overlay on the first Soundscape, a little fog may help but I want to keep the stars fairly clear. That is a good point you make about multiple blending which involves multi pass processing of of pixels covering a large portion of the screen in Max mode.
Hi Charles,
I was thinking of enableing fog just for terrain, for stars and planet disable it.
Regarding overlay - it could be 5 quads with color gradients, see attached image.
Maybe then even the fog would not be needed so much?
Bye,
Petr
Thanks Petr, this is a very similar idea and gives the best gradation of tint so far. It's a stretched pyramid with the peak pointing towards the horizon.
'DO
' IF i>12 THEN EXIT DO
' glTranslatef 0,0,1
' glCallList 2 ' transparent blue overlays
' INCR i
'LOOP
glPopMatrix
' diffuse atmosphere
glBegin GL_TRIANGLE_FAN
glcolor4f 0.1,0.2,0.8,0.4
glvertex3f 0,0,-15
glcolor4f 0.1,0.2,0.8,0.0
glvertex3f -20,-1, 2
glvertex3f 20,-1, 2
glvertex3f 20, 6, -1
glvertex3f -20, 6, -1
glvertex3f -20,-1, 2
glend
glFlush
RETURN ' end of scene
To keep the BennyBenassi peaks from beaking through I have changed the 'atten' threshold from 4 to 2. I think they look better anyway. Passion under control..
v=SQR(fft(k+8))*8*atten
IF v>2 THEN atten=2/v ' attenuation
IF v=0 THEN v=RND*.4: atten=1 ' restore sensitivity
vf(i1)=v
--Charles
About soundscapea and consor:
Sound distortion problem is solved when the call to "transparent blue overlays" is removed!
'DO
' IF i>12 THEN EXIT DO
' glTranslatef 0,0,1
' glCallList 2 ' transparent blue overlays
' INCR i
'LOOP
Using "diffuse atmosphere" doesn't cause sound distortion either, however there is a culling problem as you can see on the attached jpeg screen shot.
' diffuse atmosphere
glBegin GL_TRIANGLE_FAN
glcolor4f 0.1,0.2,0.8,0.4
glvertex3f 0,0,-15
glcolor4f 0.1,0.2,0.8,0.0
glvertex3f -20,-1, 2
glvertex3f 20,-1, 2
glvertex3f 20, 6, -1
glvertex3f -20, 6, -1
glvertex3f -20,-1, 2
glend
...
Thanks Patrice, I hope we have got to the root of the problem, which was affecting our PCs in different ways.
My current attenuation code limiting the height of the Benassi peaks, cures the problem seen above:
Same as before but 2 instead of 4, and v=2 to clamp the height of the current peak.
IF v>2 THEN atten=2/v:v=2 ' attenuation
The peaks are less spectacular by the view of the harmonics is clearer.
I like the new textures Patrice and the refinement of the stars with point sprites. I am still experimenting with synthesised textures and find they have to be quite subtle to avoid giving the viewer a migraine with pixelation effects. The more detailed a texture becomes, the finer the color gradation has to be. Your subtle bg9 snowy texture is an ideal candidate for algorithmic generation.
Considering what other elements could be added to the Soundscapes: - perhaps some meteor/fireworks in the distance.
As I am in an analytical mood this evening, I have been checking to see if the textures are managed correctly when no longer needed. glDeleteTextures only works on a valid list of texture numbers, so the way you use it to predelete textures does not work. And My various attempts to delete the textures at %BBP_DESTROY using the texture numbers from your BBTexture mt() did not work either. - for some obscure reason. So I have resorted to brute force by creating an artificial list of texture numbers and telling Opengl to eliminate them. This works. The texture deletion in SoundscapeA also works correctly - the texture numbers are held in a global contiguous array so they are easy to get at.
The symptom of undeleted textures is that the texture numbers (ie names) go up whenever a new plugin is invoked.
This sort of bug does not cause any visible problems until the Graphics hardware gets full.
Inserted into %BBP_DESTROY
' This did not work - tried all sorts of variations
'j=UBOUND(mt)
'FOR i=1 TO j
' MSGBOX STR$(mt(i).texture)
' k=mt(i).texture
' CALL glDeleteTextures (1,k)
'NEXT
' This brutal method works apparently without causing any problems.
' and could be safely used in other textured plugins
j=32
REDIM dt(j) AS LOCAL LONG
FOR i=1 TO j:dt(i)=i:NEXT
glDeleteTextures j,dt(1)
' msgbox str$(glGetError)
For a number of operations it is desirable to initialise once only. So I use a flag called 'inito' to prevent multiple initialisations of the plugin. This flag can also be used to prevent a plugin from being destroyed before it is created.
BassBox sends a %BBP_DESTROY message to all plugins when it is started. This could be a problem for future plugins which use complex resources, without some protection against premature destruction.
STATIC inito AS LONG
'...
CASE %BBP_INIT
'// Do your code initialisation there
IF inito=1 THEN EXIT FUNCTION
inito=1
'...
CASE %BBP_DESTROY
'// Free up your resources there
IF inito=0 THEN EXIT FUNCTION
--Charles (and others)
I shall follow your advice to use the brute force to delete the textures, but i'll do it in BassBox in BBP_Detached, to avoid doing it in each of the plugin.
By the way do you have any idea of the maximum texture number that could be used simultaneously? (32 is that the maximum).
Also look at the new constant:
%BBP_NO_REGISTRY = 1 ' Disable registry support
%BBP_NO_IOFILE = 1 ' Disable file I/O support
%BBP_NO_GLFONT = 1 ' Disable GL font support
#INCLUDE "Include\BBPlugin.inc"
--Charles (and others)
I am doing another change into BassBox to make sure that the %BBP_INIT will be sent only once to the plugin (to avoid extra check in each of the plugin)
I have not seen an upper limit for the number of textures Patrice, I would assume that it is limited only by the storage capacity of the graphics card,before they spill into main memory and cause performance problems. Ideally the Plugins should be responsible for taking down their own textures but I think that deleting the first 32 by default for most plugins is a safe and efficient method. If the textures do not exist, Opengl will not complain when asked to delete them.
PS:
Thanks for the new constants - they will help to keep the compiled DLL sizes down.
Ok, then i will use the brute force to delete the texture using arbitrary value of 32.
I shall post the new build # 1.25 in a couple of hours, with the changes we spoke in previous posts, altogether with the new textures, new chm, and new include file.
...
BassBox has been updated to version
1.25.
See the first post of this thread to download the whole updated project.
What is new:
- plugin "Flying the pole".
- 2 new textures (moon.jpg and bg9.gif).
- BassBox.bas and BBPlugin.inc updated for further code optimization.
- New constants to reduce code size: BBP_NO_REGISTRY, BBP_NO_IOFILE, BBP_NO_GLFONT.
- BassBox clears all the textures, while the DLL plugin is detached.
...
Thanks for the update,
works great here!
Bye,
Petr
Petr, have you looked at Opengl GLSL Shader Language yet? I am starting to explore it. GLSL is supported in Opengl 2.0 and compiles snippets of C-like code directly into the video hardware to control shading lighting and texture blending directly, bypassing the static functions of standard Opengl. I think all the recent video cards will support it.
Hi Charles,
I like how GLSL is designed. I have experimented with it, but only in thinBASIC:
http://community.thinbasic.com/index.php?topic=1043.msg6926#msg6926
What I like about GLSL is surprisingly understandable syntax, what I dislike seriously is how it is implemented on Radeon HD series. ATI reworked whole OpenGL driver ... and something is terribly wrong. But I am sure it will get better. But X series should be ok. It runs even on Radeon 9600 :)
So range of cards we can play with GLSL on is quite wide ( OpenGL 1.5 as extension, OpenGL 2.0 as part of standard ), but not sure if enough wide to build complete general purpose engine on it. But if you target newer cards then it is really interesting option!
For example per pixel lighting and fog is so much better looking than fixed pipeline per vertex operations I almost had to run in the house crying loud YESSS! FINALLY! ;D when I saw it for first time.
Bye,
Petr
P.S. Good to "validate" the shaders using GLSL Validator from 3D labs (http://developer.3dlabs.com/downloads/glslvalidate/index.htm)
P.P.S. Interesting you can write geometry shaders using GLSL too, on WindowsXP. I think it is nice advantage over geometry shaders in DirectX10 which is binded to Vistas only. Please see here (http://www.icare3d.org/content/view/50/9/)
Thanks for the info Petr, I see that none of the shader setup functions, now standard in Opengl 2.0, are exposed in the XP Open32.dll (2004). You have to obtain the proc addresses using wglGetProcAddress and it's usually the ARB version of the function.
So the functions have to be called indirectly as CALL DWORD ..
But one advantage over static DLL binding is that the Shaders can be excluded from the scene rendering if the drivers or hardware do not support the Shader language. So plugins can do the basic scene for older systems or an enhanced scene.
Am I right in thinking that DX9 does not provide access to shaders?
Hi Charles,
OpenGL32.DLL contains OpenGL 1.1 only! So of course extra functionality ( even multitexturing ) is dynamic - this is reason why I did tests in thinBASIC - there was no need for CALL DWORD, just once DECLARE SET ADDRESS and forget :) I love this feature.
All OpenGL functionality is provided by driver, because MS implementation is sadly ( intentionally? ) very poor - even depth test is done in very lazy way.
DirectX9 works with shaders for sure, with ShaderModel 3.0 I think. But not in GLSL - it is called HLSL language. But I still think developing in OpenGL is easier - no need to install SDK to get new functionality, just retrieve pointer and go :) But it is up to you.
Also you won't get geometry shaders on XPs with DX. But if you do not plan to use them then probably not such a issue.
Bye,
Petr
P.S. Charles do you know what happened to project Fahrenheit? It was agreement between MS and SGI to create new 3D API, as a crosbreed between DirectX and OpenGL. I think it was announced in 1997, but since then ... just silence :)
Hi Petr, I found an article on the history and demise of the Fahrenheit project. MS scuppered the project by not providing low level support for it, and promoting DX7 instead, which was very bad news for SGI who wanted to migrate all their high-level graphics applications to PCs.
http://en.wikipedia.org/wiki/Fahrenheit_graphics_API
I have got the code for compiling and linking shaders, based on the ClockworkCoders tutorial implemented in PB.
Rather than use the CALL DWORD syntax, I used assembler to see what it was like. (no need to declare prototypes).
This is the tutorial
http://www.opengl.org/sdk/docs/tutorials/ClockworkCoders/loading.php
and here is a snippet of assrmber code showing a complicated call and a simple call.
' glShaderSourceARB(fragmentShaderObject, 1, &FragmentShaderSource, &flength);
j=LEN(FragmentShaderSource):i=VARPTR(j)
! push eax
i=VARPTR(FragmentShaderSource)
! push eax
! push 1
! push FragmentShaderObject
! call glShaderSource
' glCompileShaderARB(VertexShaderObject);
! push VertexShaderObject
! call glCompileShader
Hi Charles,
could you post complete PB code, this looks very interesting!
Thanks,
Petr
This is the code Petr. I have added some armour plating to ensure it wont crash the system when any of the required GLSL calls are unsupported. There are some ARB calls and one of the diagnostic calls in the tutorial is not supported in my system and does not appear in the opengl 2.0 reference in any form.
If there is a GLSL Compiler error, it gets reported in a Message box. Linking is allowed to procede but the shader, as far as I can tell will be safely unimplemented.
I am using landscapeA as a test bed and will post as soon as I can get the shaders to do something useful.
This is how the code is used:
init:
Static shaderA as long
BindGLSL
shaderA=CreateShaders
.....
render_scene:
IF GLSL THEN
glcolor4f 1,1,1,1
glDisable GL_TEXTURE_2D
! push shaderA
! call glUseProgram
glbegin GL_QUADS
glVertex3f -1, 1,-2
glVertex3f -1,-1,-2
glVertex3f 1,-1,-2
glVertex3f 1, 1,-2
glEnd
! push 0
! call glUseProgram
END IF
and this is the GLSL test interface without any additional dependencies
'/* Shaders */
'the leading zeros prevent sign extension. eg: ffff8b30
MACRO GL_FRAGMENT_SHADER = &h00008B30
MACRO GL_VERTEX_SHADER = &h00008B31
MACRO GL_MAX_VERTEX_ATTRIBS = &h00008869
MACRO GL_MAX_VERTEX_UNIFORM_VECTORS = &h00008DFB
MACRO GL_MAX_VARYING_VECTORS = &h00008DFC
MACRO GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS = &h00008B4D
MACRO GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS = &h00008B4C
MACRO GL_MAX_TEXTURE_IMAGE_UNITS = &h00008872
MACRO GL_MAX_FRAGMENT_UNIFORM_VECTORS = &h00008DFD
MACRO GL_SHADER_TYPE = &h00008B4F
MACRO GL_DELETE_STATUS = &h00008B80
MACRO GL_LINK_STATUS = &h00008B82
MACRO GL_VALIDATE_STATUS = &h00008B83
MACRO GL_ATTACHED_SHADERS = &h00008B85
MACRO GL_ACTIVE_UNIFORMS = &h00008B86
MACRO GL_ACTIVE_UNIFORM_MAX_LENGTH = &h00008B87
MACRO GL_ACTIVE_ATTRIBUTES = &h00008B89
MACRO GL_ACTIVE_ATTRIBUTE_MAX_LENGTH = &h00008B8A
MACRO GL_SHADING_LANGUAGE_VERSION = &h00008B8C
MACRO GL_CURRENT_PROGRAM = &h00008B8D
'/* Shader Source */
MACRO GL_COMPILE_STATUS = &h00008B81
MACRO GL_INFO_LOG_LENGTH = &h00008B84
MACRO GL_SHADER_SOURCE_LENGTH = &h00008B88
MACRO GL_SHADER_COMPILER = &h00008DFA
MACRO check_GLSL ' must keep all line breaks intact
MACROTEMP nex
'
! cmp eax,0
! jnz nex
! jmp fail
nex:
END MACRO
SUB BindGLSL()
#REGISTER NONE
GLOBAL GLSL AS LONG
GLOBAL glCreateShader,glShaderSource,glCompileShader AS LONG 'glGetObjectParameteriv
GLOBAL glGetShaderiv,glGetInfoLog,glAttachShader,glLinkProgram AS LONG
GLOBAL glCreateProgram,glGetProgramiv,glUseProgram AS LONG
glCreateShader=wglGetProcAddress("glCreateShader"):check_GLSL
glShaderSource=wglGetProcAddress("glShaderSourceARB"):check_GLSL ' ARB
glCompileShader=wglGetProcAddress("glCompileShaderARB"):check_GLSL ' ARB
glGetInfoLog=wglGetProcAddress("glGetInfoLogARB"):check_GLSL ' ARB only
'glGetObjectParameteriv ??
glGetShaderiv=wglGetProcAddress("glGetShaderiv"):check_GLSL
glAttachShader=wglGetProcAddress("glAttachShader"):check_GLSL
glLinkProgram=wglGetProcAddress("glLinkProgram"):check_GLSL
glCreateProgram=wglGetProcAddress("glCreateProgram"):check_GLSL
glGetProgramiv=wglGetProcAddress("glGetProgramiv"):check_GLSL
glUseProgram=wglGetProcAddress("glUseProgram")::check_GLSL
GLSL=-1
EXIT SUB
fail:
GLSL=0
END SUB
FUNCTION CreateShaders() AS LONG
' http://www.opengl.org/sdk/docs/tutorials/ClockworkCoders/loading.php
#REGISTER NONE
IF GLSL=0 THEN EXIT FUNCTION
LOCAL e,i,j,k AS LONG
LOCAL InfoLog AS STRING
LOCAL VertexShaderSource AS STRING: VertexShaderSource=_
"void main(void) "+_
"{ "+_
" vec4 a = gl_Vertex; "+_
" a.x = a.x * 0.5; "+_
" a.y = a.y * 0.5; "+_
" gl_Position = gl_ModelViewProjectionMatrix * a; "+_
"} "
LOCAL FragmentShaderSource AS STRING: FragmentShaderSource=_
"void main (void) "+_
"{ "+_
" gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0); "+_
"} "
LOCAL VertexShaderObject, FragmentShaderObject AS DWORD
'
' vertexShaderObject = glCreateShader(GL_VERTEX_SHADER);
! push dword GL_VERTEX_SHADER
! call glCreateShader
! mov VertexShaderObject,eax
'fragmentShaderObject = glCreateShader(GL_FRAGMENT_SHADER);
! push dword GL_FRAGMENT_SHADER
! call glCreateShader
! mov FragmentShaderObject,eax
'glShaderSourceARB(vertexShaderObject, 1, &VertexShaderSource, &vlength);
j=LEN(VertexShaderSource):i=VARPTR(j)
! push eax
i=VARPTR(VertexShaderSource)
! push eax
! push 1
! push vertexShaderObject
! call glShaderSource
' glShaderSourceARB(fragmentShaderObject, 1, &FragmentShaderSource, &flength);
j=LEN(FragmentShaderSource):i=VARPTR(j)
! push eax
i=VARPTR(FragmentShaderSource)
! push eax
! push 1
! push FragmentShaderObject
! call glShaderSource
' glCompileShaderARB(VertexShaderObject);
! push VertexShaderObject
! call glCompileShader
' glCompileShaderARB(fragmentShaderObject);
! push FragmentShaderObject
! call glCompileShader
' glGetObjectParameteriv(ShaderObject, GL_COMPILE_STATUS, &compiled); OBSOLETE?
'i=varptr(j)
'! push eax
'! push GL_COMPILE_STATUS
'! push VertexShaderObject
'! call glGetObjectParameteriv
' if (compiled) { /* yes it compiled! */ }
'glGetShaderiv(ShaderObject, GL_INFO_LOG_LENGTH , &blen);
i=VARPTR(j)
! push eax
! push GL_INFO_LOG_LENGTH
! push VertexShaderObject
! call glGetShaderiv
IF j>1 THEN
'glGetInfoLogARB(ShaderObject, blen, &slen, compiler_log);
InfoLog=NUL$(1024)
i=STRPTR(InfoLog)
! push eax
i=VARPTR(j)
! push eax
! push 1024
! push VertexShaderObject
! call glGetInfoLog
MSGBOX InfoLog ' compiler errors
EXIT FUNCTION
END IF
'Linking:
'ProgramObject = glCreateProgram();
! call glCreateProgram
! mov j,eax
'glAttachShader(ProgramObject, vertexShaderObject);
! push VertexShaderObject
! push j
! call glAttachShader
' glAttachShader(ProgramObject, fragmentShaderObject);
! push FragmentShaderObject
! push j
! call glAttachShader
' glLinkProgram(ProgramObject);
! push j
! call glLinkProgram
' glGetProgramiv(ProgramObject, GL_LINK_STATUS, &linked);
i=VARPTR(k)
! push eax
! push GL_LINK_STATUS
! push j
! call glGetProgramiv
'msgbox hex$(k)
FUNCTION=j
END FUNCTION
Thanks Charles,
highly appreciated!
Petr
An advanced but exciting tutorial showing some of the possibilities unleashed by using shaders:
The art of texturing Using the OpenGL Shading Language
By Jerome Guinot
http://www.ozone3d.net/tutorials/glsl_texturing.php
Hi Charles,
this is very good site, although some shaders from there did not passed GLSL validation ( I think it was per-pixel fog sample ), but generally it is a great resource! The article you posted link to is really fantastic!
Thanks,
Petr
P.S. Maybe better to move GLSL talk to new thread?
Certainly Petr, It is such a major topic, that somewhat stretches the boundaries of BASIC so I have set up a board for GLSL (below Charles Pegge Long Code). I envisage giving this area quite a lot of attention over the next few months.
http://www.jose.it-berater.org/smfforum/index.php?board=241.0
But I think the BassBox project is a very good platform for Plugins that can take advantage of GLSL's subtle shading capabilities, if Patrice is agreeable to this of course.
Yes,
you are right, GLSL plugins would be cool too.
Thanks a lot for creating new board!
Bye,
Petr
BassBox is already able to handle multiple textures in full ARGB mode.
For example replace the bg9.gif texture of "Flying the pole" with the attached one
...
GLSL can do things which are normally too difficult or intensive for static Opengl, fire, smoke,the refractions of running water and the reflection of the sky on a glossy surface for instance. But I am starting right from the beginning and rejoice when a little square gets colored lime green by a shader program copied from a tutorial.
Shaders use textures as raw data and combine them in exotic ways to get these effects in real-time.
--Charles,
QuoteFor the equates we would need to provide a BBPlugin.h for Plugins written in C and in the case of Freebasic, a BBPlugin.bi. If the plugins need to use the support functions like GetTextureFromFile then these would also have to be translated.
This might help to extend the audience for BassBox. I hope so.
I can translate one of the Soundscapes into FreeBasic and see if any other issues become apparent.
If you want to translate the BBPlugin.bi to FreeBasic that is fine with me, then i'll do a new zip when you are done.
Now for C, C++ and C#, i am more circonspect, i did post myself about BassBox on
codeproject there:
http://www.codeproject.com/KB/openGL/_BassBox.aspx (http://www.codeproject.com/KB/openGL/_BassBox.aspx)
But as you can see, the feedback was almost null and the rating very low, thus i stopped posting the new versions on codeproject.
I did post also on
VBFrance and the rating was good as you can see there:
http://www.vbfrance.com/codes/BASSBOX-AUDIO-OPENGL-VISUAL-PLUGINS_44975.aspx (http://www.vbfrance.com/codes/BASSBOX-AUDIO-OPENGL-VISUAL-PLUGINS_44975.aspx)
however i didn't get any feedback of people wanting to write plugins in VB, thus i stopped also to post new versions on VBFrance.
Now about PowerBASIC, except you, Petr and myself, nobody else posted a contribution for BassBox, let's see if FreeBasic programmers could write new plugins.
Note: this post has been edited by myself, to remove a negative comment i did because of a nasty e-mail i got today.
...
Quote from: Patrice Terrier on January 31, 2008, 07:06:38 PM
Looks like most people are just interrested to steal the code without giving anything back, not even a thank you, but i was aware of that already and i accepted it, because of José's.
Why so negative?
It is hard but you have to accept that your code is not the center of the main thougts of the brains walking here and in other places.
I'm not sarcastic here but just realistic because I experience the same feelings many time. But now I see it from another point of view.
If you publish source code, expect other people just get it and forget about you. No thanks, no comments, no interaction to suggestions, nothing.
If you are searching for glory, ok, you can be disappointed. But if you are sharing with great generosity your knowledge you have to be prepared to no feedback at all.
You already got this fantastic thread with many, many, many reply and great participation from 3/4 nice guy. You should be happy about that otherwise your words can be an offence for the value those few guys put in this thread.
And about PB Forum, you already know: all first ladies there so do not expect too much.
Just my opinion.
Keep up the great work you are doing.
Ciao
Eros
--Eros
My contributions are my way to say thank you to José for all the code he shared with us.
I will go on posting there, not for glory but because I like the active members of this small community.
However I would be more than happy if others would also post there, i am not speaking for BassBox, but anything that we could learn from.
Patrice,
I perfectly know why you are doing this, you stated it in other posts here. That's why I remained a little confused about your last sentence, especially by the word "stole". But we are all humans and humans can have some up and down in sentiments.
I think we all would like to have more users here sharing the same nice, polite, good, tech atmosphere of this forum. But it takes time.
Personally I prefer to have very few friends than thousands of users bashing all around. Slow-food is better than fast-food.
Ciao
Eros
--Eros
I have edited my negative comment.
...
I understand the feelings and thoughts expressed here.
I think all of us who ever put lots of time and effort into a project and are proud of what we created from nothing-- when it is presented, the response from the outside world is usually sort of a let down. I don't think it is from any bad motives.
I think most of us here are from the old days and back then-- anything new we created received attention when we showed it to friends or presented at local computer clubs. There was lots of excitement by what you did, people wanted copies or wanted you to run your application again so they could show it to their friends that they brought over to show this cool thing that you did.
But now with everyone is used to really fantastic things on the computer and the capabilities there, it is hard to get even close to that response from people.
I am always shocked of how hard it is to do something in main programming languages that you can easily do with web based languages. You can have a fantastic web page in very short time full of pictures, sound and video, nice text formats and even animations and very nice fun user interfaces that would be beasts to code in any main stream languages.
Also even on a forum like this you can see the wide array of specialized areas of interest that is available now to all users and creators. So we are all off in our own worlds or areas of interest and this cuts down the amount of users maybe even looking at our work.
I program and learn for my own benefit now more than ever. If I can share my program with a few friends it is a bonus for me in satisfaction.
So don't get down guys and keep up the great job you are doing!!
I wish I could participate in the BassBox project, but I know so little about graphics programming that I can't do much more than porting some examples.
The code that Patrice, Charles and Petr are posting is of top quality and hard to digest to PBer's that are still struggling with the DDT graphic control. However, there is it, available to those willing to learn from the masters.
Quote
I am always shocked of how hard it is to do something in main programming languages that you can easily do with web based languages. You can have a fantastic web page in very short time full of pictures, sound and video, nice text formats and even animations and very nice fun user interfaces that would be beasts to code in any main stream languages.
I don't want to go off topic, so just a brief comment. One day, probably next year, you will be able to use both Windows controls and web controls to build interactive GUIs in your desktop application. I'm currently working with the Active Scripting technology to allow you to call scripts in the web page from your PB code, and to allow the scripts in the web page to call functions implemented in your PB code.
BassBox is a very significant project as a testbed for Vista/XP compatibility and high performance audio-visual software. With its extensive range of SDK technology in one program, I think it could be the basis for many new projects to come. I for one have learnt a huge amount from Patrice's code. ( Some of my own coding habits belong back in the 80s :) ).
I see real-time 3d being on the cutting edge for a long time to come - and a perfect subject for low level programming. Many of the techniques used are quite esoteric, the reference manuals and other tech literature do not make much sense on their own so we rely on good examples and tutorials to port. To make this task more interesting, much of the material out there contains bugs, obsolete functions or missing components so a certain amount of forensic reconstruction is required.
José, Re: PB GUIs for the web: A very exciting project. I made some attempts a while ago to get COMforDLL to work with VBscripts in Internet Explorer but I think security barriers prevented the script from calling the COM server to which a PB program could be attached.
Patrice, I hope you recover from that nasty troll bite soon!
@Charles,
PB GUIs for the web no. Dynamic HTML GUIs for your PB applications.
Hi,
I wish I could do more on BassBox, but I am a bit time limited. So I put things I want to do on paper and then pick them using FIFO approach :D.
I like lot of things on BassBox, its CPU friendlyness, fantastic look of course, pluginability and throwing files on the window. Before I learn all the depths of its source code it will take lot of time, but sure it is very nice experience already.
I know WinAmp for example has its SDK too, but the BassBox one seems easier to me. Still have lot of ideas on plugins, but must wait till I get there on my FIFO paperTM ;)
Bye,
Petr
P.S. Good feature to have would be shuffle :-X
I would like to know if anyone there, is using a "Media center" remote control?
I am asking this, to see the opportunity to handle the WM_INPUT message in BassBox.
...
I have a media center pc Patrice, I don't use my remote, I have a wireless keyboard and mouse that I use since most of what I watch is from the internet as vidcasts.
My Uncle has a Media Center PC and they use their remote and it is really quite nice how they did everything. I wouldn't put it as any priority, but I think support eventually will be a good thing for the remote.
Patrice,
Updated zip 24 Feb 2008 see further on
After attempting a translation of BBPlugin.inc, and getting into deep water, I tried splitting BBPlugin,inc into a header file and a DLL. This will make BassBox much more accessible to Plugins written in different programming languages and save significant space in each plugin DLL.
The zip file below contains the new BBPluginUtil.dll to go in the main BassBox folder, all the modified Plugins, and the BBPluginUtil bas and inc files.
I hope this meets with your approval.
During the course of my translation efforts, I found a bug in BBPlugin.inc:
There is a boundary error which is not checked during compilation but Freebasic picked it up.
should be: DIM P(1 TO 12) AS LONG
DIM P(1 TO 11) AS LONG
ARRAY ASSIGN P() = 2,4,8,16,32,64,128,256,512,1024,2048,4096
Generally speaking, FB is much stricter about TYPE definitions, - one of the major hassles in translating from PB's relaxed interpretation of the Windows SDK. FB requires all SDK calls to be pass params BYVAL. Also Zstrings are always passed using a pointer BYVAL
Charles,
nice job, that was lot of work to change all plugins. Very much valuated from my side!
Side comment: it took me some time to see the ARRAY ASSIGN is deadly fast, even if assigned values are expressions.
I used it in TBGL to speed up matrix multiplication and got very solid speed improvements comparing to PB native MAT functions.
Thanks,
Petr
Fortunately the Plugins required very little work - just a few missing Declares. Nothing compared to translating BBPlugin.inc.
My mental grasp of matrix maths is rather limited. I can never remember which way to combine them. Apparently OpenGL does it the opposite way to conventional maths. I rely on blind obedience to make them work.
--Charles,
The changes you have done do not work on VISTA, see attached screen shot.
Looks like it couldn't find the texture's folder.
...
All I did was to create a separate header file and compile BBplugin.inc to a DLL. All the BB functions were given Aliases and designated as Export. They are all based on V 1.25 and the 01-19-2008 release of BBPlugin.inc
There was just the 1 bug fix mentioned above.
In the Plugins the include file was altered from "BBPlugin.inc" to BBPluginUtil.inc". Most of them required some missing Declares like glPushMatrix but nothing else was altered.
Do they all have the same problem? Some of mine do not use BBPluginUtils.
Looks like it couldn't find the texture's folder.
Being out of home, I shall be unable to check the source code before the weekend.
...
Thanks Patrice. I think I've done all the checking I can here. Hiding the texture folder reproduces the symptoms. Perhaps you can try moving the texture folder to BBplugin\BBplugin\ to see if the path has been shifted down one level ??
DIM P(1 TO 11) AS LONG
ARRAY ASSIGN P() = 2,4,8,16,32,64,128,256,512,1024,2048,4096
This would not caused an array bound error in PowerBASIC because the compiler just ignore the value 4096, that is indeed out of bound.
Thus writing
DIM P(1 TO 2) AS LONG
ARRAY ASSIGN P() = 2,4,8,16,32,64,128,256,512,1024,2048,4096
is perfectly legal in PB, as long as you use it together with the same BBPlugin.inc code that checks the array bounds:
FOR K& = UBOUND(P) TO LBOUND(P) STEP -1
IF Xin = 0 AND ImgW > P(K&) - 1 THEN Xin = P(K&)
IF Yin = 0 AND ImgH > P(K&) - 1 THEN Yin = P(K&)
NEXT
The FB compiler does not let you get away with anything remotely suspicious without letting you know about it. Practices which we are accustomed to in PB often provoke stern warning messages if not outright rejection. This certainly catches more potential errors but after using PB, it takes some getting used to.
As a matter of interest, rge above code is very similar in FreeBasic but suffixes are no longer accepted:
DIM K AS LONG
...
DIM P(1 TO 12) AS LONG => { 2,4,8,16,32,64,128,256,512,1024,2048,4096 }
FOR K = UBOUND(P) TO LBOUND(P) STEP -1
IF Xin = 0 AND ImgW > P(K) - 1 THEN Xin = P(K)
IF Yin = 0 AND ImgH > P(K) - 1 THEN Yin = P(K)
NEXT
FB will also accept multidimensional initialisers {{,},{,},{,}} etc for multidimensional arrays or arrays of UDTs.
But Multidimensional arrays are in Row-Major order ie. highest first.
FREEFRAME is an open-source cross-platform real-time video effects plugin system.
See it there (http://freeframe.sourceforge.net/gallery.html)
...
Patrice are these lines causing the problem in Vista. ie picking up the wrong current directory, when the plugin dll calls another dll.?
In BBPluginUtil.inc: BBP_CreateGLTextureFromFile:
CALL BBP_SplitN(BBP_ExeName, sPathName, "")
IF INSTR(sImgName, sPathName) = 0 THEN sImgName = sPathName + sImgName
--Charles
You did a typo in the BBP_Exist function (see below in red)
FUNCTION BBP_Exist ALIAS "BBP_Exist LIB" (zFileSpec AS ASCIIZ) EXPORT AS LONG
LOCAL fd AS WIN32_FIND_DATA, hFind AS LONG
IF LEN(zFileSpec) THEN
hFind = FindFirstFile(zFileSpec, fd)
IF hFind <> -1 THEN
CALL FindClose(hFind&)
FUNCTION = -1
END IF
END IF
END FUNCTION
...
Thank you Patrice. I hope everything else is in good order.
XP seems to be treating space as a symbol delimiter whereas Vista does not.
Updated Zip below:
I have fixed a small glitch in the zSkin.inc, when the main window was maximized it was however still possible to move it arround, that is of course not the standard way (a maximized window can't be moved arround).
Here is how to fix it in zDefWindowproc:
'//ELSE ' See %WM_LBUTTONDBLCLK below
'// IF p.Y < CaptionHeight THEN nRet = %HTCAPTION
END IF
ELSEIF Msg = %WM_LBUTTONDBLCLK THEN
IF IsZoomed(hWnd) THEN
p.X = LO(INTEGER, lParam): p.Y = HI(INTEGER, lParam)
CALL zGetImageSize(zGetProperty(hWnd, %FORM_TopMid), 0, CaptionHeight)
IF p.Y < CaptionHeight AND IsWindowVisible(GetDlgItem(hWnd, %ID_RESTORE)) THEN
CALL zButtonSysCommand(hWnd, MAKLNG(%ID_RESTORE, 0))
END IF
END IF
END IF
Complete source code there:
'// Monitor Windows DEF PROC to take over HITTEST detection
FUNCTION zDefWindowProc(BYVAL hWnd AS LONG, BYVAL Msg AS LONG, BYVAL wParam AS LONG, BYVAL lParam AS LONG) AS LONG
LOCAL nRet, HITTEST, CaptionHeight AS LONG
LOCAL rc AS RECT, p AS POINTAPI
nRet = DefWindowProc(hWnd, Msg, wParam, lParam)
IF Msg = %WM_NCHITTEST THEN
CALL zGetImageSize(zGetProperty(hWnd, %FORM_TopMid), 0, CaptionHeight)
p.X = LO(INTEGER, lParam): p.Y = HI(INTEGER, lParam)
CALL ScreenToClient(hWnd, p)
IF IsZoomed(hWnd) = 0 THEN
IF nRet = %HTCLIENT THEN
HITTEST = %HTCAPTION
IF SK_DRAG_BACKGROUND() = 0 THEN
IF p.Y > CaptionHeight AND CaptionHeight > 0 THEN
HITTEST = %HTNOWHERE
IF hWnd <> GetForegroundWindow THEN CALL SetFocus(hWnd)
END IF
END IF
IF zWinResizable(hWnd) THEN ' We fool Window
CALL GetClientRect (hWnd, rc)
LOCAL xF, yF, xSide, Border AS LONG
xF = rc.nRight: yF = rc.nBottom
xSide = 0
Border = GetSystemMetrics(32) ' %SM_CXFRAME
IF ((p.X >= xF - Border) AND ((p.Y >= yF - Border))) THEN
HITTEST = %HTBOTTOMRIGHT
ELSE
'// Left side
IF (p.X <= 8) THEN
IF (p.X <= Border) THEN HITTEST = %HTLEFT
xSide = 1
END IF
'// Right side
IF (p.X >= xF - 8) THEN
IF (p.X >= xF - Border) THEN HITTEST = %HTRIGHT
xSide = 2
END IF
'// Top side
IF (p.Y <= Border) THEN
HITTEST = %HTTOP
IF (xSide = 1) THEN
HITTEST = %HTTOPLEFT
ELSEIF (xSide = 2) THEN
HITTEST = %HTTOPRIGHT
END IF
END IF
'// Bottom side
IF (p.Y >= yF - Border) THEN
IF (xSide = 1) THEN
HITTEST = %HTBOTTOMLEFT
ELSE
HITTEST = %HTBOTTOM
END IF
END IF
END IF
END IF
nRet = HITTEST
END IF
'//ELSE ' See %WM_LBUTTONDBLCLK below
'// IF p.Y < CaptionHeight THEN nRet = %HTCAPTION
END IF
ELSEIF Msg = %WM_LBUTTONDBLCLK THEN
IF IsZoomed(hWnd) THEN
p.X = LO(INTEGER, lParam): p.Y = HI(INTEGER, lParam)
CALL zGetImageSize(zGetProperty(hWnd, %FORM_TopMid), 0, CaptionHeight)
IF p.Y < CaptionHeight AND IsWindowVisible(GetDlgItem(hWnd, %ID_RESTORE)) THEN
CALL zButtonSysCommand(hWnd, MAKLNG(%ID_RESTORE, 0))
END IF
END IF
END IF
FUNCTION = nRet
END FUNCTION
Hi Patrice,
thanks for the fix, I did not noticed that it was moveable.
Thanks,
Petr
--José
Do you have translated some of the new VISTA API?
I am interrested in the IAudioEndpointVolume interface, as well as the IAudioStreamVolume and the IAudioSessionManager.
(I am asking this because the old Mixer API doesn't work anymore on VISTA)
Time to move on ;)
...
No, I don't have Vista. Do you have the WASAPI C header files?
Thanks for the files. I will use them to update the new include files.
--José
Thanks to you.
Note: i have removed the link and the zip file to freeup some space on my servor ;)
Ian Luck from www.un4seen.com has just released Bass.dll version 2.4.
This version introduces several changes to the parameters being used.
If ever you plan to upgrade to Bass.dll version 2.4, you must have BassBox version 1.26+.
I am currently checking the new BassBox version 1.26, if you want to check it yourself, just send me a private message.
...
Hi Patrice,
I am confused - the website mentions that on April 02nd there was released BASS 2.4, not 1.24.
BASS.DLL is awesome library, the first I am close to understand ;D
One thing I noticed - BASS provides some effects via DirectX ( DirectSound or DirectMusic, not sure ).
I read somewhere that in Vista / DX 10 there were some changes in the way the sound part of DX works, do you have some more info on this topic please?
Thanks for the message,
Petr
QuoteI am confused - the website mentions that on April 02nd there was released BASS 2.4, not 1.24.
Yes, that was a typo from me, i have fixed my previous message, version
2.4 is the latest release.
QuoteI read somewhere that in Vista / DX 10 there were some changes in the way the sound part of DX works, do you have some more info on this topic please?
BassBox, works very well on VISTA ;)
including the sound effects, see
AudioFX.inc.
...
Hi Patrice,
works nice on XPs, no problem noticed.
Thanks,
Petr
(http://www.zapsolution.com/BassBox/FullBlack.jpg)
This is the new Skin theme of BassBox 1.26.
The zip file has been attached to the first post of this thread.
...
This is new plugin that looks nice with the DarkCrystal theme.
See the attached Flash.zip
Note: unzip the file into your \BassBox\BBPlugin folder.
...
Version 1.27:
The last plugin being used is saved/retrieved between sessions.
ZIP file attached to first post of this thread.
...
Thanks Patrice,
Petr
Anyone interrested to add midi support to BassBox?
Then look at this:
BASSMIDI 2.4 (http://www.un4seen.com/download.php?bassmidi24)
...
If you want to decrease down the BassBox CPU's usage, without sacrifying audio and visual quality, add apiSleep(20) in the RenderOpenGL subroutine like this:
IF glRC THEN
nLevel = BassChannelGetLevel()
nLpeak = SolvePeak(LO(WORD, nLevel), 128)
nRpeak = SolvePeak(HI(WORD, nLevel), 128)
BBP.Msg = %BBP_RENDER
BBP.ParentWindow = glCtrl
BBP.DC = glDC
BBP.RC = glRC
BBP.Lpeak = nLpeak
BBP.Rpeak = nRpeak
BBP.BackARGB = SK_AEROCOLOR()
BBP.FFTdata = BassChannelGetData()
BBP.FFTsize = 256
BBP.MediaLength = gnMediaLength
BBP.MediaPos = gnMediaPos
BBP.WIMdata = BassChannelGetWimData()
CALL apiSleep(20) ' <------------------------
CALL BBP_PLUGIN(BBP)
'// Refresh display
CALL SwapBuffers(glDC)
CALL zUpdateWindow(glCtrl, 0)
'CALL wglSwapBuffers(glDC)
This will reduce down the FPS to almost 46, but that is still more than playing a Movie :)
...
Here is a copy of a private message i got from Jordi Vallès, about the BassBox CPU usage reduction on his VISTA system.
I post it there because it could help other VISTA's user as well.
Quote
Today I implemented your sugestion to reduce the Bassbox CPU usage and playing with the value of ApiSleep and reducing the FPS to 42 the problem with of Bassbox on Windows Vista on my PC disapears. Now can see the beautiful screens without any problems, equal as my other PC with Windows XP.
I sent you this good notice for your information.
By the way, there is another small code modification you could add to the
RenderOpenGL subroutine if your CPU is very busy at the time
BassBox starts runing:
SUB RenderOpenGL(BYVAL glCtrl AS LONG)
IF IsWindowVisible(glCtrl) = 0 THEN EXIT SUB
LOCAL graphics, nLevel, nLpeak, nRpeak, glDC, InDWMmode AS LONG
LOCAL BBP AS BBPLUGIN
LOCAL C1, C2, C3 AS LONG
Please can anybody tell me where i can found the Source of BassBox
has great Visualisation and think translate (Interface in/out) it do Delphi used in BassVis ( Visualisation wrapper for Bass Audio Library )
your help is welcome
sorry my english is not the best i hope you can understand me...
i hope the translation is not to hard ;)
greets Emil
The source code is attached as a ZIP file to the first post of this thread.
Hi Emil,
usually you can find project files attached to the first post of a thread.
So go to the very first page of this long long thread and look at the bottom of the first post.
Patrice code merit a deep study.
Ciao
Eros
Patrice, 35 secs faster than me :D
thanks :)
i hope this is the right thread or should make new for this ?
i'm have load Archive BassBox_1_27.zip
think this is right..
greets Emil
This is how to perform further CPU usage reduction in BassBox.
Just cut and paste the code below into the BassBox source code as a replacement for the previous RenderOpenGL subroutine.
SUB RenderOpenGL(BYVAL glCtrl AS LONG)
STATIC bFlip AS LONG
bFlip = NOT bFlip
IF IsWindowVisible(glCtrl) = 0 OR bFlip = 0 THEN EXIT SUB
LOCAL graphics, nLevel, nLpeak, nRpeak, glDC, InDWMmode AS LONG
LOCAL BBP AS BBPLUGIN
LOCAL C1, C2, C3 AS LONG
STATIC C0, CB1, CB2, CB3, CG1, CG2, CG3, TickCount, hOscillo AS LONG
IF CB1 = 0 THEN
C0 = zColorARGB(255, 0)
CB1 = zColorARGB(255, RGB(0,23,66))
CB2 = zColorARGB(255, RGB(0,37,103))
CB3 = zColorARGB(255, RGB(0,74,201))
CG1 = zColorARGB(255, RGB(0,66,23))
CG2 = zColorARGB(255, RGB(0,103,37))
CG3 = zColorARGB(255, RGB(0,201,74))
hOscillo = zGetMainItem(%ID_OSCILLO)
END IF
glDC = GetDC(glCtrl)
IF glRC THEN
nLevel = BassChannelGetLevel()
nLpeak = SolvePeak(LO(WORD, nLevel), 128)
nRpeak = SolvePeak(HI(WORD, nLevel), 128)
BBP.Msg = %BBP_RENDER
BBP.ParentWindow = glCtrl
BBP.DC = glDC
BBP.RC = glRC
BBP.Lpeak = nLpeak
BBP.Rpeak = nRpeak
BBP.BackARGB = SK_AEROCOLOR()
BBP.FFTdata = BassChannelGetData()
BBP.FFTsize = 256
BBP.MediaLength = gnMediaLength
BBP.MediaPos = gnMediaPos
BBP.WIMdata = BassChannelGetWimData()
CALL BBP_PLUGIN(BBP)
'// Refresh display
CALL SwapBuffers(glDC)
CALL zUpdateWindow(glCtrl, 0)
'CALL wglSwapBuffers(glDC)
STATIC FPScount, nFPScount AS LONG
INCR nFPScount
IF FPScount = 0 THEN FPScount = GetTickCount() + 1000
IF GetTickCount() > FPScount THEN
FPScount = 0
CALL zSetCTLText(zGetMainItem(%ID_FPS), ("FPS" + STR$(nFPScount)))
nFPScount = 0
END IF
' --------------------------------------------------------------------
' //Start drawing the ViewMeter's LED directly onto the main window DC
LOCAL OkL, OkR, K, C, hDC, nCell, CellW, CellH, x, y AS LONG
LOCAL rc AS RECT
CALL DrawOscillo(hOscillo, BBP.WIMdata)
' // 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 - 133: Y = 50
IF hOscillo = 0 THEN
nCell = 16: CellH = 3: CellW = 16: x = rc.nRight - 133 + 16: Y = 50
ELSE
nCell = 16: CellH = 3: CellW = 8: x = rc.nRight - (163 + 9): Y = 50
END IF
CALL GdipCreateFromHDC(hDC, graphics)
'IF zGetCheckButtonStatus(zGetMainItem(%ID_AEROBLUR)) OR _
' zGetCheckButtonStatus(zGetMainItem(%ID_AEROCRYSTAL)) THEN
' InDWMmode = -1
'ELSE
' InDWMmode = 0
'END IF
FOR K = nCell TO 1 STEP -1
C = SolvePeak(K, nCell)
'IF InDWMmode THEN
CALL zPaintBrushBitmap(hDC, x, y, CellW, CellH, zColorARGB(255, gPeak(C,1)))
IF hOscillo = 0 THEN
CALL zPaintBrushBitmap(hDC, x + CellW + CellH , y, CellW, CellH, zColorARGB(255, gPeak(C,2)))
ELSE
CALL zPaintBrushBitmap(hDC, x + 128 + 10 , y, CellW, CellH, zColorARGB(255, gPeak(C,2)))
END IF
'ELSE
' CALL zsGdipFillRect(graphics&, x, y, CellW, CellH, zColorARGB(255, gPeak(C,1)) )
' CALL zsGdipFillRect(graphics&, x + 128 + 10 , y, CellW, CellH, zColorARGB(255, gPeak(C,2)) )
'END IF
y = y + CellH + 1
NEXT
CALL GdipDeleteGraphics(graphics&)
' // End ViewMeter section
IF hOscillo = 0 THEN
LOCAL p AS POINTAPI
STATIC xPos AS LONG, stepX AS LONG
CALL GetWindowRect(glCtrl, rc)
p.X = rc.nLeft: p.Y = rc.nTop
CALL ScreenToClient(GetParent(glCtrl), p)
x = p.X: y = p.Y + rc.nBottom - rc.nTop
CellW = rc.nRight - rc.nLeft
xPos = xPos + stepX
CellW = CellW - 69 ' 30 + 2 + 20 + 2 + 15
IF stepX = 0 THEN stepX = 1
IF xPos > CellW THEN xPos = cellW: stepX = - stepX
IF xPos < 0 THEN xPos = 0: stepX = - stepX
' // Select active or inactive color
IF nLpeak OR nRpeak THEN
C1 = CG1: C2 = CG2: C3 = CG3
ELSE
C1 = CB1: C2 = CB2: C3 = CB3
END IF
IF stepX > 0 THEN
CALL zPaintBrushBitmap(hDC, x, y, xPos, 2, C0)
CALL zPaintBrushBitmap(hDC, x + xPos, y, 30, 1, C1)
CALL zPaintBrushBitmap(hDC, x + xPos + 30 + 2, y, 20, 1, C2)
CALL zPaintBrushBitmap(hDC, x + xPos + 50 + 4, y, 15, 1, C3)
ELSE
CALL zPaintBrushBitmap(hDC, x + xPos, y, 15, 1, C3)
CALL zPaintBrushBitmap(hDC, x + xPos + 15 + 2, y, 20, 1, C2)
CALL zPaintBrushBitmap(hDC, x + xPos + 35 + 4, y, 30, 1, C1)
END IF
CALL zPaintBrushBitmap(hDC, x + xPos + 50 + 4 + 15, y, CellW - xPos, 2, C0)
END IF
CALL ReleaseDC(zMainWindow(0), hDC)
' --------------------------------------------------------------------
' // Update the trackbar location
IF gnAudioChannel THEN
'IF TickCount < GetTickCount() + 1000 THEN
'TickCount = GetTickCount() + 1000
INCR TickCount
IF TickCount = 100 THEN
gnMediaPos = BassChannelGetPos()
CALL zSetTrackValue(zGetMainItem(%ID_TRACK_SEARCH), gnMediaPos)
CALL zSetCTLText(zGetMainItem(%ID_ELLAPSED), BassAudioToTime(gnMediaPos))
TickCount = 0
END IF
END IF
END IF
CALL ReleaseDC(glCtrl, glDC)
END SUB
And here is s screen shot of the CPU usage on my VISTA computer while using the FLASH plugin:
(http://www.zapsolution.com/BassBox/BB_Optimize.jpg)
The result gives an average FPS of 34, that is almost the same than for a movie.
...
i have replace it ;)
thanks ;)
greets Emil
Here is another way to perform CPU usage reduction, and please tell me which one gives the best result on your system.
SUB RenderOpenGL(BYVAL glCtrl AS LONG)
STATIC bFlip AS LONG
bFlip = NOT bFlip
IF IsWindowVisible(glCtrl) = 0 THEN EXIT SUB
LOCAL graphics, nLevel, nLpeak, nRpeak, glDC, InDWMmode AS LONG
LOCAL BBP AS BBPLUGIN
LOCAL C1, C2, C3 AS LONG
STATIC C0, CB1, CB2, CB3, CG1, CG2, CG3, TickCount, hOscillo AS LONG
IF CB1 = 0 THEN
C0 = zColorARGB(255, 0)
CB1 = zColorARGB(255, RGB(0,23,66))
CB2 = zColorARGB(255, RGB(0,37,103))
CB3 = zColorARGB(255, RGB(0,74,201))
CG1 = zColorARGB(255, RGB(0,66,23))
CG2 = zColorARGB(255, RGB(0,103,37))
CG3 = zColorARGB(255, RGB(0,201,74))
hOscillo = zGetMainItem(%ID_OSCILLO)
END IF
glDC = GetDC(glCtrl)
IF glRC THEN
IF bFlip THEN
nLevel = BassChannelGetLevel()
nLpeak = SolvePeak(LO(WORD, nLevel), 128)
nRpeak = SolvePeak(HI(WORD, nLevel), 128)
BBP.Msg = %BBP_RENDER
BBP.ParentWindow = glCtrl
BBP.DC = glDC
BBP.RC = glRC
BBP.Lpeak = nLpeak
BBP.Rpeak = nRpeak
BBP.BackARGB = SK_AEROCOLOR()
BBP.FFTdata = BassChannelGetData()
BBP.FFTsize = 256
BBP.MediaLength = gnMediaLength
BBP.MediaPos = gnMediaPos
BBP.WIMdata = BassChannelGetWimData()
CALL BBP_PLUGIN(BBP)
'// Refresh display
CALL SwapBuffers(glDC)
CALL zUpdateWindow(glCtrl, 0)
'CALL wglSwapBuffers(glDC)
STATIC FPScount, nFPScount AS LONG
INCR nFPScount
IF FPScount = 0 THEN FPScount = GetTickCount() + 1000
IF GetTickCount() > FPScount THEN
FPScount = 0
CALL zSetCTLText(zGetMainItem(%ID_FPS), ("FPS" + STR$(nFPScount)))
nFPScount = 0
END IF
ELSE
' --------------------------------------------------------------------
' //Start drawing the ViewMeter's LED directly onto the main window DC
LOCAL OkL, OkR, K, C, hDC, nCell, CellW, CellH, x, y AS LONG
LOCAL rc AS RECT
nLevel = BassChannelGetLevel()
nLpeak = SolvePeak(LO(WORD, nLevel), 128)
nRpeak = SolvePeak(HI(WORD, nLevel), 128)
CALL DrawOscillo(hOscillo, BassChannelGetWimData())
' // 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 - 133: Y = 50
IF hOscillo = 0 THEN
nCell = 16: CellH = 3: CellW = 16: x = rc.nRight - 133 + 16: Y = 50
ELSE
nCell = 16: CellH = 3: CellW = 8: x = rc.nRight - (163 + 9): Y = 50
END IF
CALL GdipCreateFromHDC(hDC, graphics)
'IF zGetCheckButtonStatus(zGetMainItem(%ID_AEROBLUR)) OR _
' zGetCheckButtonStatus(zGetMainItem(%ID_AEROCRYSTAL)) THEN
' InDWMmode = -1
'ELSE
' InDWMmode = 0
'END IF
FOR K = nCell TO 1 STEP -1
C = SolvePeak(K, nCell)
'IF InDWMmode THEN
CALL zPaintBrushBitmap(hDC, x, y, CellW, CellH, zColorARGB(255, gPeak(C,1)))
IF hOscillo = 0 THEN
CALL zPaintBrushBitmap(hDC, x + CellW + CellH , y, CellW, CellH, zColorARGB(255, gPeak(C,2)))
ELSE
CALL zPaintBrushBitmap(hDC, x + 128 + 10 , y, CellW, CellH, zColorARGB(255, gPeak(C,2)))
END IF
'ELSE
' CALL zsGdipFillRect(graphics&, x, y, CellW, CellH, zColorARGB(255, gPeak(C,1)) )
' CALL zsGdipFillRect(graphics&, x + 128 + 10 , y, CellW, CellH, zColorARGB(255, gPeak(C,2)) )
'END IF
y = y + CellH + 1
NEXT
CALL GdipDeleteGraphics(graphics&)
' // End ViewMeter section
IF hOscillo = 0 THEN
LOCAL p AS POINTAPI
STATIC xPos AS LONG, stepX AS LONG
CALL GetWindowRect(glCtrl, rc)
p.X = rc.nLeft: p.Y = rc.nTop
CALL ScreenToClient(GetParent(glCtrl), p)
x = p.X: y = p.Y + rc.nBottom - rc.nTop
CellW = rc.nRight - rc.nLeft
xPos = xPos + stepX
CellW = CellW - 69 ' 30 + 2 + 20 + 2 + 15
IF stepX = 0 THEN stepX = 1
IF xPos > CellW THEN xPos = cellW: stepX = - stepX
IF xPos < 0 THEN xPos = 0: stepX = - stepX
' // Select active or inactive color
IF nLpeak OR nRpeak THEN
C1 = CG1: C2 = CG2: C3 = CG3
ELSE
C1 = CB1: C2 = CB2: C3 = CB3
END IF
IF stepX > 0 THEN
CALL zPaintBrushBitmap(hDC, x, y, xPos, 2, C0)
CALL zPaintBrushBitmap(hDC, x + xPos, y, 30, 1, C1)
CALL zPaintBrushBitmap(hDC, x + xPos + 30 + 2, y, 20, 1, C2)
CALL zPaintBrushBitmap(hDC, x + xPos + 50 + 4, y, 15, 1, C3)
ELSE
CALL zPaintBrushBitmap(hDC, x + xPos, y, 15, 1, C3)
CALL zPaintBrushBitmap(hDC, x + xPos + 15 + 2, y, 20, 1, C2)
CALL zPaintBrushBitmap(hDC, x + xPos + 35 + 4, y, 30, 1, C1)
END IF
CALL zPaintBrushBitmap(hDC, x + xPos + 50 + 4 + 15, y, CellW - xPos, 2, C0)
END IF
CALL ReleaseDC(zMainWindow(0), hDC)
' --------------------------------------------------------------------
' // Update the trackbar location
IF gnAudioChannel THEN
'IF TickCount < GetTickCount() + 1000 THEN
'TickCount = GetTickCount() + 1000
INCR TickCount
IF TickCount = 100 THEN
gnMediaPos = BassChannelGetPos()
CALL zSetTrackValue(zGetMainItem(%ID_TRACK_SEARCH), gnMediaPos)
CALL zSetCTLText(zGetMainItem(%ID_ELLAPSED), BassAudioToTime(gnMediaPos))
TickCount = 0
END IF
END IF
END IF
END IF
CALL ReleaseDC(glCtrl, glDC)
END SUB
The source code has been edited because left and right view meters were not redrawn anymore, this has been fixed, please cut and paste again in case you did it already.
i have replace it ..
has no effect by me can not compile BassBox with no PowerBasic
wait for you has update the Archive
thanks
greets Emil
You can get the latest public version there (http://www.zapsolution.com/BassBox/setup.zip) (compiled)
...
Hi Patrice.
After apply your new code to reduce the CPU usage I can see perfectly the BassBox in my PC with Vista. The FPS indicates 33.
Thanks.
Jordi
Hi Patrice.
Using the lastest compiled code that have FPS 66, the old problem with Windows Vista on my PC appears again. Seems that the problem is directly related with the amount of FPS.
Regards
Jordi
Jordi,
Then this is clearly related to the power (or underpower) of the graphic card being used.
Anyway, 34 FPS would be quite sufficient, because it is almost the same than for playing a movie (see MovieBox).
Thank you for sharing your feedback.
...
Question..
Please can you make in the future when you have time ;)
Change BBP.Title to PluginFile
and added new
BBP.Title for SongFile
then make a great SongFile Animation like Milkdrop or other that can show in the Visualization
when change the FileTitle ?
greets Emil
The Phoenix
UnZip it in the BassBox BBPlugin folder, and enjoy.
(http://www.zapsolution.com/BassBox/ThePhoenix.jpg)
...
great and thanks for good work
greets Emil
Thanks Patrice,
really impresive :o
Just one complaint ( applies to my Mikado too :-[ ) - for rhytmic music, the perspective scaling of whole ... thing ... on screen is very jumpy, which results in impression the visualisation flickers/runs slow although it runs at great 60FPS.
Petr
Petr,
I shall work on this when i have time, i did it fast with cut and paste from several plugins, including Mikado ;)
I shall post the source code there when cleaned up.
would you imagine that there are spherical quadric objects in it 8)
Added:
By the way it should work at 34 Fps not 60 Fps, if you apply the changes i posted there a few days ago, that will decrease drasticaly the CPU usage.
...
Thanks for the info,
do you use quadrics for the surround beams?
Regarding low CPU mods - I have seen them, and worked great. But I am FPS addict, when I do not get at least 40FPS I start to cry :D, so I stick with the CPU torture ( ok not that much :) ) version.
Thanks,
Petr
Quotedo you use quadrics for the surround beams?
Yes, but in a very unusual way, see below in red:
SUB RenderPhoenix(BYVAL edge AS SINGLE)
edge = edge / 2
CALL glTexCoord2f(0.0, 0.0): CALL glVertex3f(-edge,-edge, 0.0)
CALL glTexCoord2f(1.0, 0.0): CALL glVertex3f( edge,-edge, 0.0)
CALL glTexCoord2f(1.0, 1.0): CALL glVertex3f( edge, edge, 0.0)
CALL glTexCoord2f(0.0, 1.0): CALL glVertex3f(-edge, edge, 0.0)
LOCAL quadObj AS LONG
quadObj = gluNewQuadric() ' Pointer to the Quadric Object (Return 0 If No Memory))
IF quadObj THEN
CALL gluQuadricNormals(quadObj, %GLU_SMOOTH) ' Create Smooth Normals
CALL gluQuadricTexture(quadObj, %GL_TRUE) ' Create Texture Coords
CALL gluSphere(quadObj, edge * 3,
2,
2)
CALL gluDeleteQuadric(quadObj)
END IF
END SUB
I used gluSphere by lazyness.
new idea
it's real you can make the mousepointer to opengl
when move over the Window
think is a god control for check i have a Focus....
greets Emil
Emil,
See in BassBox the VisualProc:
FUNCTION VisualProc (BYVAL hWnd AS LONG, BYVAL Msg AS LONG, BYVAL wParam AS LONG, BYVAL lParam AS LONG) EXPORT AS LONG
LOCAL hResource AS LONG, ps AS PAINTSTRUCT, rc AS RECT
LOCAL BBP AS BBPLUGIN
SELECT CASE LONG Msg
CASE %WM_ERASEBKGND
FUNCTION = 1: EXIT FUNCTION
' CASE %WM_KEYDOWN TO %WM_UNICHAR
' BBP.Msg = %BBP_KEYBOARD
' BBP.WinMsg = Msg
' BBP.wParam = wParam
' BBP.lParam = lParam
' CALL BBP_Plugin(BBP)
CASE %WM_MOUSEMOVE TO %WM_XBUTTONDBLCLK
IF Msg = %WM_LBUTTONDOWN AND GetFocus() <> hWnd THEN CALL SetFocus(hWnd)
BBP.Msg = %BBP_MOUSE
BBP.WinMsg = Msg
BBP.wParam = wParam
BBP.lParam = lParam
CALL BBP_Plugin(BBP)
CASE %WM_PAINT
CALL BeginPaint(hWnd, ps)
CALL EndPaint(hWnd, ps)
FUNCTION = 0: EXIT FUNCTION
END SELECT
FUNCTION = DefWindowProc (hWnd, Msg, wParam, lParam)
END FUNCTION
do not understand me
i mean a grafik Cursor in OpenGl
change window Cursor to OpenGl Cursor
greets Emil
Hi Emil,
if you mean cursor rendered in OpenGL ... sure it is possible ( check out gluUnProject for transformation of window to 3D coordinates ), but it is recommended to use Windows "hardware" cursor, which never lags, even if framerate goes down.
Patrice, thanks for showing the way. It little bit scares me as I cannot see any glBegin/glEnd around the glVertex3f commands. If it is defined outside, then it is kind of luck you mix gluQuadrics and glVertex3f there ( NVIDIA drivers are very tolerant, other not so much ). Once the complete source code will be out I can give more advice, but I think now you dance on thin edge separating OpenGL specification and driver specific implementation. On some cards it could generate GL error and could be followed by undefined behaviour.
According to specs:
Quote
Only a subset of GL commands can be used between glBegin and glEnd.
The commands are
glVertex,
glColor,
glIndex,
glNormal,
glTexCoord,
glEvalCoord,
glEvalPoint,
glArrayElement,
glMaterial, and
glEdgeFlag.
Also, it is acceptable to use glCallList or glCallLists to execute display lists that include only the preceding commands.
If any other GL command is executed between glBegin and glEnd, the error flag is set and the command is ignored.
Petr
QuoteHi Emil,
if you mean cursor rendered in OpenGL ... sure it is possible ( check out gluUnProject for transformation of window to 3D coordinates ), but it is recommended to use Windows "hardware" cursor, which never lags, even if framerate goes down.
yes is posible make this for all plugin ?
when not then i make it self ...
my problem this is no longer compatible to plugin
greets Emil
Petr,
Here is the rough code, feel free to enhance it.
as you will see RenderPhoenix is enclosed in glBegin/glEnd.
I didn't had time yet to work on the sound sensitivity (aka Mikado)
Note: without seeing the source code, i guess nobody could figure the texture that has been used :)
'+--------------------------------------------------------------------------+
'| |
'| Phoenix |
'| BassBox OpenGL plugin |
'| |
'| Version 1.00 |
'+--------------------------------------------------------------------------+
'| |
'| Author Patrice TERRIER |
'| |
'| copyright(c) 2008 |
'| |
'| Patrice Terrier http://www.zapsolution.com |
'| |
'+--------------------------------------------------------------------------+
'| Project started on : 06-10-2008 (MM-DD-YYYY) |
'| Last revised : 06-10-2008 (MM-DD-YYYY) |
'+--------------------------------------------------------------------------+
'
#COMPILE DLL "Phoenix.dll"
#INCLUDE "Include\BBPlugin.inc"
%GL_MODELVIEW = &H1700
%GL_PROJECTION = &H1701
%GL_DEPTH_TEST = &H0B71
%GL_SMOOTH = &H1D01
%GL_TRIANGLE_FAN = &H0006
%GL_DEPTH_BUFFER_BIT = &H00000100
%GL_COLOR_BUFFER_BIT = &H00004000
%GL_LINES = &H0001???
%GL_LESS = &H0201
%GL_ONE = &h0001&
%GL_BLEND = &h0BE2&
%GL_GREATER = &H0204
%GL_PERSPECTIVE_CORRECTION_HINT = &h0C50&
%GL_NICEST = &h1102&
%GL_QUADS = &h0007&
%GL_TEXTURE_2D = &h0DE1&
%GL_TEXTURE_MAG_FILTER = &h2800&
%GL_TEXTURE_MIN_FILTER = &h2801&
%GL_LUMINANCE = &h1909&
%GL_RGB = &H1907
%GL_RGBA = &H1908
%GL_TEXTURE = &H1702
%GL_LESS = &H0201
%GL_LIGHTING = &H0B50
%GL_GREATER = &H0204
%GL_LINEAR = &h2601&
%GL_POINTS = &H0000
%GL_POINT_SPRITE = &H08861
%GL_COORD_REPLACE = &H08862
TYPE RECT
nLeft AS LONG
nTop AS LONG
nRight AS LONG
nBottom AS LONG
END TYPE
TYPE tColorBox
length AS SINGLE
r1 AS BYTE
g1 AS BYTE
b1 AS BYTE
r2 AS BYTE
g2 AS BYTE
b2 AS BYTE
END TYPE
DECLARE FUNCTION GetClientRect LIB "USER32.DLL" ALIAS "GetClientRect" (BYVAL hwnd AS DWORD, lpRect AS RECT) AS LONG
DECLARE SUB glClearColor LIB "OPENGL32.DLL" ALIAS "glClearColor" (BYVAL red AS SINGLE, BYVAL green AS SINGLE, BYVAL blue AS SINGLE, BYVAL alpha AS SINGLE)
DECLARE SUB glEnable LIB "OPENGL32.DLL" ALIAS "glEnable" (BYVAL cap AS DWORD)
DECLARE SUB glShadeModel LIB "OPENGL32.DLL" ALIAS "glShadeModel" (BYVAL mode AS DWORD)
DECLARE SUB glMatrixMode LIB "OPENGL32.DLL" ALIAS "glMatrixMode" (BYVAL mode AS DWORD)
DECLARE SUB glLoadIdentity LIB "OPENGL32.DLL" ALIAS "glLoadIdentity" ()
DECLARE SUB gluPerspective LIB "glu32.dll" ALIAS "gluPerspective" (BYVAL fovy#, BYVAL aspect#, BYVAL zNear#, BYVAL zFar AS DOUBLE)
DECLARE SUB glClear LIB "OPENGL32.DLL" ALIAS "glClear" (BYVAL mask AS DWORD)
DECLARE SUB glRotatef LIB "OPENGL32.DLL" ALIAS "glRotatef" (BYVAL angle AS SINGLE, BYVAL x AS SINGLE, BYVAL y AS SINGLE, BYVAL z AS SINGLE)
DECLARE SUB glBegin LIB "OPENGL32.DLL" ALIAS "glBegin" (BYVAL mode AS DWORD)
DECLARE SUB glEnd LIB "OPENGL32.DLL" ALIAS "glEnd" ()
DECLARE SUB glColor3ub LIB "OPENGL32.DLL" ALIAS "glColor3ub" (BYVAL red AS BYTE, BYVAL green AS BYTE, BYVAL blue AS BYTE)
DECLARE SUB glVertex3f LIB "opengl32.dll" ALIAS "glVertex3f" (BYVAL SINGLE, BYVAL SINGLE, BYVAL SINGLE)
DECLARE SUB glPushMatrix LIB "OPENGL32.DLL" ALIAS "glPushMatrix" ()
DECLARE SUB glPopMatrix LIB "OPENGL32.DLL" ALIAS "glPopMatrix" ()
DECLARE SUB glTranslatef LIB "opengl32.dll" ALIAS "glTranslatef" (BYVAL SINGLE, BYVAL SINGLE, BYVAL SINGLE)
DECLARE SUB gluLookAt LIB "glu32.dll" ALIAS "gluLookAt" (BYVAL eyex#, BYVAL eyey#, BYVAL eyez#, BYVAL centerx#, BYVAL centery#, BYVAL centerz#, BYVAL upx#, BYVAL upy#, BYVAL upz AS DOUBLE)
DECLARE FUNCTION wglMakeCurrent LIB "OPENGL32.DLL" ALIAS "wglMakeCurrent" (BYVAL hdc AS DWORD, BYVAL hglrc AS DWORD) AS LONG
DECLARE SUB glLineWidth LIB "OPENGL32.DLL" ALIAS "glLineWidth" (BYVAL nWidth AS SINGLE)
DECLARE SUB glGenTextures LIB "opengl32.dll" ALIAS "glGenTextures" (BYVAL DWORD, textures AS ANY)
DECLARE SUB glBindTexture LIB "opengl32.dll" ALIAS "glBindTexture" (BYVAL DWORD, BYVAL DWORD)
DECLARE FUNCTION glGetError LIB "opengl32.dll" ALIAS "glGetError" () AS DWORD
DECLARE SUB glDeleteTextures LIB "opengl32.dll" ALIAS "glDeleteTextures" (BYVAL LONG, textures AS ANY)
DECLARE SUB glClearDepth LIB "opengl32.dll" ALIAS "glClearDepth" (BYVAL DOUBLE)
DECLARE SUB glBlendFunc LIB "opengl32.dll" ALIAS "glBlendFunc" (BYVAL LONG, BYVAL LONG)
DECLARE SUB glDepthFunc LIB "OPENGL32.DLL" ALIAS "glDepthFunc" (BYVAL func AS DWORD)
DECLARE SUB glAlphaFunc LIB "OPENGL32.DLL" ALIAS "glAlphaFunc" (BYVAL func AS DWORD, BYVAL ref AS SINGLE)
DECLARE SUB glHint LIB "opengl32.dll" ALIAS "glHint" (BYVAL DWORD, BYVAL DWORD)
DECLARE SUB glTexCoord2f LIB "opengl32.dll" ALIAS "glTexCoord2f" (BYVAL SINGLE, BYVAL SINGLE)
DECLARE SUB glTexParameteri LIB "opengl32.dll" ALIAS "glTexParameteri" (BYVAL DWORD, BYVAL DWORD, BYVAL LONG)
DECLARE SUB glTexImage2D LIB "opengl32.dll" ALIAS "glTexImage2D" (BYVAL DWORD, BYVAL LONG, BYVAL LONG, BYVAL LONG, BYVAL LONG, BYVAL LONG, BYVAL DWORD, BYVAL DWORD, npixels AS ANY)
DECLARE SUB glPointSize LIB "opengl32.dll" ALIAS "glPointSize" (BYVAL lsize AS SINGLE)
DECLARE SUB glTexEnvi LIB "opengl32.dll" ALIAS "glTexEnvi" (BYVAL DWORD, BYVAL DWORD, BYVAL LONG)
GLOBAL gColor() AS LONG
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
'// The main exported plugin's function would be bbProc, like this:
FUNCTION BBProc ALIAS "BBProc" (BYREF BBP AS BBPLUGIN) EXPORT AS LONG
STATIC rXangle, rYangle, rZangle, LastTime AS DOUBLE
DIM PulseMemory(0 TO 128) AS STATIC tColorBox
LOCAL nRet AS LONG
DIM mt(1 TO 1) AS STATIC BBPTEXTURE
nRet = %BBP_SUCCESS
SELECT CASE LONG BBP.Msg
CASE %BBP_RENDER
'// Draw the scene using BBP.LeftPeak and BBP.RightPeak
LOCAL K, nLValue, nRValue, RGBColor AS LONG
LOCAL xD, pulse AS SINGLE, R1, G1, B1, R2, G2, B2 AS BYTE
LOCAL PulseMemorySample AS tColorBox
nLValue = (BBP.Lpeak / 700)
nRValue = (BBP.Rpeak / 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 UseRC to the new UseDC
'// Note: don't use permanent DC, this produce better and smoother display
CALL wglMakeCurrent(BBP.DC, BBP.RC)
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 Visualisation
RGBColor = LevelColr(nLValue)
R2 = BBP_GetRValue(RGBColor)
G2 = BBP_GetGValue(RGBColor)
B2 = BBP_GetBValue(RGBColor)
RGBColor = LevelColr(nRValue)
R1 = BBP_GetRValue(RGBColor)
G1 = BBP_GetGValue(RGBColor)
B1 = BBP_GetBValue(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
FOR K = LBOUND(PulseMemory) TO UBOUND(PulseMemory)
CALL glPushMatrix()
CALL glTranslatef(0, 0, -K / 10)
CALL glRotatef( K * 3, 0, 0, 1)
xD = 0.25 * (1 + pulse): GOSUB SubRender
CALL glPopMatrix()
CALL glPushMatrix()
CALL glTranslatef(0, 0, -K / 10)
CALL glRotatef(-K * 3, 0, 0, 1)
xD = 0.125: GOSUB SubRender
CALL glPopMatrix()
NEXT
CASE %BBP_CREATE
'// Retrieve plugin details
BBP.Title = "The Phoenix"
BBP.Author = "Patrice Terrier"
BBP.Version = MAKDWD(1, 0) '// Version 1.0"
BBP.RenderTo = %BBP_OPENGL '// or %BBP_GDIPLUS, or %BBP_DIRECTX
CASE %BBP_INIT
'// Do your code initialisation there
CALL BBP_SplitColorARGB(BBP.BackARGB, A?, R?, G?, B?)
Alpha! = A? + 1: Red! = R? + 1: Green! = G? + 1: Blue! = B? + 1
CALL glClearColor(Red! / 256, Green! /256, Blue! / 256, Alpha! / 256)
CALL glShadeModel(%GL_SMOOTH) '// Enables Smooth Color Shading
CALL glClearDepth(1.0) '// Depth Buffer Setup
CALL glDisable(%GL_DEPTH_TEST)'// Disable Depth Buffer
CALL glBlendFunc(%GL_ONE, %GL_ONE)
CALL glDepthFunc(%GL_LESS) '// The Type Of Depth Test To Do
CALL glDisable(%GL_LIGHTING)
CALL glEnable(%GL_BLEND)
CALL glAlphaFunc(%GL_GREATER, 0.01)
CALL glHint(%GL_PERSPECTIVE_CORRECTION_HINT, %GL_NICEST)
CALL glEnable(%GL_TEXTURE_2D)
mt(1).FullName = $BBP_PLUGIN_FOLDER + "Texture\MiniStar.jpg": mt(1).ID = 1: mt(2).Square = 0
CALL MakeMutipleTexture (BYVAL VARPTR(mt(LBOUND(mt))), UBOUND(mt) - LBOUND(mt) + 1)
CALL ColorInit()
CASE %BBP_SIZE
'// The size of the view port has changed.
LOCAL rAspect AS DOUBLE, rc AS RECT
CALL GetClientRect(BBP.ParentWindow, rc)
CALL glMatrixMode(%GL_PROJECTION)
CALL glLoadIdentity()
rAspect = 0: IF rc.nBottom THEN rAspect = rc.nRight / rc.nBottom
CALL gluPerspective(35.0, rAspect, 0.1, 150.0)
CALL glMatrixMode(%GL_MODELVIEW)
CASE %BBP_DESTROY
'// Free up your resources there
CASE ELSE
nRet = %BBP_ERROR
END SELECT
FUNCTION = nRet
EXIT FUNCTION
SubRender:
CALL glBindTexture(%GL_TEXTURE_2D, mt(1).Texture)
CALL glBegin(%GL_QUADS)
CALL glColor3ub(PulseMemory(K).r2, PulseMemory(K).g2, PulseMemory(K).b2)
CALL glVertex3f( xD, -PulseMemory(K).length, PulseMemory(K).length)
CALL RenderPhoenix(PulseMemory(K).length * 2)
CALL glEnd()
RETURN
END FUNCTION
DECLARE FUNCTION gluNewQuadric LIB "glu32.dll" ALIAS "gluNewQuadric" () AS LONG
DECLARE SUB gluDeleteQuadric LIB "glu32.dll" ALIAS "gluDeleteQuadric" (BYVAL state AS ANY)
DECLARE SUB gluQuadricNormals LIB "glu32.dll" ALIAS "gluQuadricNormals" (BYVAL quadObject AS ANY, BYVAL normals AS DWORD)
DECLARE SUB gluQuadricTexture LIB "glu32.dll" ALIAS "gluQuadricTexture" (BYVAL quadObject AS ANY, BYVAL textureCoords AS DWORD)' ANY)
DECLARE SUB gluSphere LIB "glu32.dll" ALIAS "gluSphere" (BYVAL qobj AS ANY, BYVAL radius#, BYVAL slices&, BYVAL stacks AS LONG)
%GL_TRUE = 1
%GLU_SMOOTH = 100000
SUB RenderPhoenix(BYVAL edge AS SINGLE)
edge = edge / 2
CALL glTexCoord2f(0.0, 0.0): CALL glVertex3f(-edge,-edge, 0.0)
CALL glTexCoord2f(1.0, 0.0): CALL glVertex3f( edge,-edge, 0.0)
CALL glTexCoord2f(1.0, 1.0): CALL glVertex3f( edge, edge, 0.0)
CALL glTexCoord2f(0.0, 1.0): CALL glVertex3f(-edge, edge, 0.0)
LOCAL quadObj AS LONG
quadObj = gluNewQuadric() ' Pointer to the Quadric Object (Return 0 If No Memory))
IF quadObj THEN
CALL gluQuadricNormals(quadObj, %GLU_SMOOTH) ' Create Smooth Normals
CALL gluQuadricTexture(quadObj, %GL_TRUE) ' Create Texture Coords
CALL gluSphere(quadObj, edge * 3, 2, 2)
CALL gluDeleteQuadric(quadObj)
END IF
END SUB
SUB MakeMutipleTexture (BYVAL tp AS BBPTEXTURE PTR, BYVAL N AS LONG)
LOCAL mtCount, K, nRet, xSize, ySize AS LONG
DIM mt(1 TO N) AS BBPTEXTURE AT tp
mtCount = UBOUND(mt()) - LBOUND(mt()) + 1
IF mtCount THEN
DIM Texture(1 TO mtCount) AS LONG
CALL glDeleteTextures(mtCount, Texture(1))
CALL glGenTextures(mtCount, Texture(1)): nRet = glGetError()
IF nRet = 0 THEN
FOR K = 1 TO mtCount
REDIM PixelArray(0) AS BYTE
IF BBP_CreateGLTextureFromFile(mt(K).FullName, xSize, ySize, PixelArray(), mt(K).Square) THEN
mt(k).Texture = Texture(K)
CALL glBindTexture(%GL_TEXTURE_2D, Texture(K)): nRet = glGetError
IF nRet = 0 THEN
CALL glTexParameteri(%GL_TEXTURE_2D, %GL_TEXTURE_MAG_FILTER, %GL_LINEAR)
CALL glTexParameteri(%GL_TEXTURE_2D, %GL_TEXTURE_MIN_FILTER, %GL_LINEAR)
CALL glTexImage2D(%GL_TEXTURE_2D, 0, 4, xSize&, ySize&, 0, %GL_RGBA, %GL_UNSIGNED_BYTE, PixelArray(0))
END IF
END IF
NEXT
END IF
END IF
END SUB
Hi Patrice,
your current code produced GL_INVALID_OPERATION, there were 2 reasons:
- passing 5 vertices to %GL_QUADS ( fixed as using more versatile %GL_POLYGON )
- that yet mentioned quading inside glBegin/glEnd
... now the bad news - the surround beams looked as they looked thanks to some weird transformation crossbreeding with error on stack.
Here is my best try so far, still does not look like original but like angry parrot feathers :). But no GL error.
'+--------------------------------------------------------------------------+
'| |
'| Phoenix |
'| BassBox OpenGL plugin |
'| |
'| Version 1.00 |
'+--------------------------------------------------------------------------+
'| |
'| Author Patrice TERRIER |
'| |
'| copyright(c) 2008 |
'| |
'| Patrice Terrier http://www.zapsolution.com |
'| |
'+--------------------------------------------------------------------------+
'| Project started on : 06-10-2008 (MM-DD-YYYY) |
'| Last revised : 06-10-2008 (MM-DD-YYYY) |
'+--------------------------------------------------------------------------+
'
#COMPILE DLL "Phoenix.dll"
#INCLUDE "Include\BBPlugin.inc"
%GL_MODELVIEW = &H1700
%GL_PROJECTION = &H1701
%GL_DEPTH_TEST = &H0B71
%GL_SMOOTH = &H1D01
%GL_TRIANGLE_FAN = &H0006
%GL_DEPTH_BUFFER_BIT = &H00000100
%GL_COLOR_BUFFER_BIT = &H00004000
%GL_LINES = &H0001???
%GL_LESS = &H0201
%GL_ONE = &h0001&
%GL_BLEND = &h0BE2&
%GL_GREATER = &H0204
%GL_PERSPECTIVE_CORRECTION_HINT = &h0C50&
%GL_NICEST = &h1102&
%GL_QUADS = &h0007&
%GL_POLYGON = &H0009???
%GL_TEXTURE_2D = &h0DE1&
%GL_TEXTURE_MAG_FILTER = &h2800&
%GL_TEXTURE_MIN_FILTER = &h2801&
%GL_LUMINANCE = &h1909&
%GL_RGB = &H1907
%GL_RGBA = &H1908
%GL_TEXTURE = &H1702
%GL_LESS = &H0201
%GL_LIGHTING = &H0B50
%GL_GREATER = &H0204
%GL_LINEAR = &h2601&
%GL_POINTS = &H0000
%GL_POINT_SPRITE = &H08861
%GL_COORD_REPLACE = &H08862
TYPE RECT
nLeft AS LONG
nTop AS LONG
nRight AS LONG
nBottom AS LONG
END TYPE
TYPE tColorBox
length AS SINGLE
r1 AS BYTE
g1 AS BYTE
b1 AS BYTE
r2 AS BYTE
g2 AS BYTE
b2 AS BYTE
END TYPE
DECLARE FUNCTION GetClientRect LIB "USER32.DLL" ALIAS "GetClientRect" (BYVAL hwnd AS DWORD, lpRect AS RECT) AS LONG
DECLARE SUB glClearColor LIB "OPENGL32.DLL" ALIAS "glClearColor" (BYVAL red AS SINGLE, BYVAL green AS SINGLE, BYVAL blue AS SINGLE, BYVAL alpha AS SINGLE)
DECLARE SUB glEnable LIB "OPENGL32.DLL" ALIAS "glEnable" (BYVAL cap AS DWORD)
DECLARE SUB glShadeModel LIB "OPENGL32.DLL" ALIAS "glShadeModel" (BYVAL mode AS DWORD)
DECLARE SUB glMatrixMode LIB "OPENGL32.DLL" ALIAS "glMatrixMode" (BYVAL mode AS DWORD)
DECLARE SUB glLoadIdentity LIB "OPENGL32.DLL" ALIAS "glLoadIdentity" ()
DECLARE SUB gluPerspective LIB "glu32.dll" ALIAS "gluPerspective" (BYVAL fovy#, BYVAL aspect#, BYVAL zNear#, BYVAL zFar AS DOUBLE)
DECLARE SUB glClear LIB "OPENGL32.DLL" ALIAS "glClear" (BYVAL mask AS DWORD)
DECLARE SUB glRotatef LIB "OPENGL32.DLL" ALIAS "glRotatef" (BYVAL angle AS SINGLE, BYVAL x AS SINGLE, BYVAL y AS SINGLE, BYVAL z AS SINGLE)
DECLARE SUB glBegin LIB "OPENGL32.DLL" ALIAS "glBegin" (BYVAL mode AS DWORD)
DECLARE SUB glEnd LIB "OPENGL32.DLL" ALIAS "glEnd" ()
DECLARE SUB glColor3ub LIB "OPENGL32.DLL" ALIAS "glColor3ub" (BYVAL red AS BYTE, BYVAL green AS BYTE, BYVAL blue AS BYTE)
DECLARE SUB glVertex3f LIB "opengl32.dll" ALIAS "glVertex3f" (BYVAL SINGLE, BYVAL SINGLE, BYVAL SINGLE)
DECLARE SUB glPushMatrix LIB "OPENGL32.DLL" ALIAS "glPushMatrix" ()
DECLARE SUB glPopMatrix LIB "OPENGL32.DLL" ALIAS "glPopMatrix" ()
DECLARE SUB glTranslatef LIB "opengl32.dll" ALIAS "glTranslatef" (BYVAL SINGLE, BYVAL SINGLE, BYVAL SINGLE)
DECLARE SUB gluLookAt LIB "glu32.dll" ALIAS "gluLookAt" (BYVAL eyex#, BYVAL eyey#, BYVAL eyez#, BYVAL centerx#, BYVAL centery#, BYVAL centerz#, BYVAL upx#, BYVAL upy#, BYVAL upz AS DOUBLE)
DECLARE FUNCTION wglMakeCurrent LIB "OPENGL32.DLL" ALIAS "wglMakeCurrent" (BYVAL hdc AS DWORD, BYVAL hglrc AS DWORD) AS LONG
DECLARE SUB glLineWidth LIB "OPENGL32.DLL" ALIAS "glLineWidth" (BYVAL nWidth AS SINGLE)
DECLARE SUB glGenTextures LIB "opengl32.dll" ALIAS "glGenTextures" (BYVAL DWORD, textures AS ANY)
DECLARE SUB glBindTexture LIB "opengl32.dll" ALIAS "glBindTexture" (BYVAL DWORD, BYVAL DWORD)
DECLARE FUNCTION glGetError LIB "opengl32.dll" ALIAS "glGetError" () AS DWORD
DECLARE SUB glDeleteTextures LIB "opengl32.dll" ALIAS "glDeleteTextures" (BYVAL LONG, textures AS ANY)
DECLARE SUB glClearDepth LIB "opengl32.dll" ALIAS "glClearDepth" (BYVAL DOUBLE)
DECLARE SUB glBlendFunc LIB "opengl32.dll" ALIAS "glBlendFunc" (BYVAL LONG, BYVAL LONG)
DECLARE SUB glDepthFunc LIB "OPENGL32.DLL" ALIAS "glDepthFunc" (BYVAL func AS DWORD)
DECLARE SUB glAlphaFunc LIB "OPENGL32.DLL" ALIAS "glAlphaFunc" (BYVAL func AS DWORD, BYVAL ref AS SINGLE)
DECLARE SUB glHint LIB "opengl32.dll" ALIAS "glHint" (BYVAL DWORD, BYVAL DWORD)
DECLARE SUB glTexCoord2f LIB "opengl32.dll" ALIAS "glTexCoord2f" (BYVAL SINGLE, BYVAL SINGLE)
DECLARE SUB glTexParameteri LIB "opengl32.dll" ALIAS "glTexParameteri" (BYVAL DWORD, BYVAL DWORD, BYVAL LONG)
DECLARE SUB glTexImage2D LIB "opengl32.dll" ALIAS "glTexImage2D" (BYVAL DWORD, BYVAL LONG, BYVAL LONG, BYVAL LONG, BYVAL LONG, BYVAL LONG, BYVAL DWORD, BYVAL DWORD, npixels AS ANY)
DECLARE SUB glPointSize LIB "opengl32.dll" ALIAS "glPointSize" (BYVAL lsize AS SINGLE)
DECLARE SUB glTexEnvi LIB "opengl32.dll" ALIAS "glTexEnvi" (BYVAL DWORD, BYVAL DWORD, BYVAL LONG)
GLOBAL gColor() AS LONG
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
'// The main exported plugin's function would be bbProc, like this:
FUNCTION BBProc ALIAS "BBProc" (BYREF BBP AS BBPLUGIN) EXPORT AS LONG
STATIC rXangle, rYangle, rZangle, LastTime AS DOUBLE
DIM PulseMemory(0 TO 128) AS STATIC tColorBox
LOCAL nRet AS LONG
DIM mt(1 TO 1) AS STATIC BBPTEXTURE
nRet = %BBP_SUCCESS
SELECT CASE LONG BBP.Msg
CASE %BBP_RENDER
'LOCAL gl_Err AS LONG
'gl_Err = glgeterror()
'IF gl_Err <> 0 THEN MSGBOX STR$(gl_Err), 0,"OpenGL Error Ocurred" : EXIT FUNCTION
'// Draw the scene using BBP.LeftPeak and BBP.RightPeak
LOCAL K, nLValue, nRValue, RGBColor AS LONG
LOCAL xD, pulse AS SINGLE, R1, G1, B1, R2, G2, B2 AS BYTE
LOCAL PulseMemorySample AS tColorBox
nLValue = (BBP.Lpeak / 700)
nRValue = (BBP.Rpeak / 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 UseRC to the new UseDC
'// Note: don't use permanent DC, this produce better and smoother display
CALL wglMakeCurrent(BBP.DC, BBP.RC)
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 Visualisation
RGBColor = LevelColr(nLValue)
R2 = BBP_GetRValue(RGBColor)
G2 = BBP_GetGValue(RGBColor)
B2 = BBP_GetBValue(RGBColor)
RGBColor = LevelColr(nRValue)
R1 = BBP_GetRValue(RGBColor)
G1 = BBP_GetGValue(RGBColor)
B1 = BBP_GetBValue(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
FOR K = LBOUND(PulseMemory) TO UBOUND(PulseMemory)
CALL glPushMatrix()
CALL glTranslatef(0, 0, -K / 10)
CALL glRotatef( K * 3, 0, 0, 1)
xD = 0.25 * (1 + pulse): GOSUB SubRender
CALL glPopMatrix()
CALL glPushMatrix()
CALL glTranslatef(0, 0, -K / 10)
CALL glRotatef(-K * 3, 0, 0, 1)
xD = 0.125: GOSUB SubRender
CALL glPopMatrix()
NEXT
CASE %BBP_CREATE
'// Retrieve plugin details
BBP.Title = "The Phoenix"
BBP.Author = "Patrice Terrier"
BBP.Version = MAKDWD(1, 0) '// Version 1.0"
BBP.RenderTo = %BBP_OPENGL '// or %BBP_GDIPLUS, or %BBP_DIRECTX
CASE %BBP_INIT
'// Do your code initialisation there
CALL BBP_SplitColorARGB(BBP.BackARGB, A?, R?, G?, B?)
Alpha! = A? + 1: Red! = R? + 1: Green! = G? + 1: Blue! = B? + 1
CALL glClearColor(Red! / 256, Green! /256, Blue! / 256, Alpha! / 256)
CALL glShadeModel(%GL_SMOOTH) '// Enables Smooth Color Shading
CALL glClearDepth(1.0) '// Depth Buffer Setup
CALL glDisable(%GL_DEPTH_TEST)'// Disable Depth Buffer
CALL glBlendFunc(%GL_ONE, %GL_ONE)
CALL glDepthFunc(%GL_LESS) '// The Type Of Depth Test To Do
CALL glDisable(%GL_LIGHTING)
CALL glEnable(%GL_BLEND)
CALL glAlphaFunc(%GL_GREATER, 0.01)
CALL glHint(%GL_PERSPECTIVE_CORRECTION_HINT, %GL_NICEST)
CALL glEnable(%GL_TEXTURE_2D)
mt(1).FullName = $BBP_PLUGIN_FOLDER + "Texture\MiniStar.jpg": mt(1).ID = 1: mt(2).Square = 0
CALL MakeMutipleTexture (BYVAL VARPTR(mt(LBOUND(mt))), UBOUND(mt) - LBOUND(mt) + 1)
CALL ColorInit()
CASE %BBP_SIZE
'// The size of the view port has changed.
LOCAL rAspect AS DOUBLE, rc AS RECT
CALL GetClientRect(BBP.ParentWindow, rc)
CALL glMatrixMode(%GL_PROJECTION)
CALL glLoadIdentity()
rAspect = 0: IF rc.nBottom THEN rAspect = rc.nRight / rc.nBottom
CALL gluPerspective(35.0, rAspect, 0.1, 150.0)
CALL glMatrixMode(%GL_MODELVIEW)
CASE %BBP_DESTROY
'// Free up your resources there
CASE ELSE
nRet = %BBP_ERROR
END SELECT
FUNCTION = nRet
EXIT FUNCTION
SubRender:
CALL glBindTexture(%GL_TEXTURE_2D, mt(1).Texture)
CALL glPushMatrix()
' -- glEnd is called in RenderPhoenix :P
CALL glBegin(%GL_POLYGON)
CALL glColor3ub(PulseMemory(K).r2, PulseMemory(K).g2, PulseMemory(K).b2)
CALL glVertex3f( xD, -PulseMemory(K).length, PulseMemory(K).length)
CALL RenderPhoenix(PulseMemory(K).length * 2)
CALL glPopMatrix()
RETURN
END FUNCTION
DECLARE FUNCTION gluNewQuadric LIB "glu32.dll" ALIAS "gluNewQuadric" () AS LONG
DECLARE SUB gluDeleteQuadric LIB "glu32.dll" ALIAS "gluDeleteQuadric" (BYVAL STATE AS ANY)
DECLARE SUB gluQuadricNormals LIB "glu32.dll" ALIAS "gluQuadricNormals" (BYVAL quadObject AS ANY, BYVAL normals AS DWORD)
DECLARE SUB gluQuadricTexture LIB "glu32.dll" ALIAS "gluQuadricTexture" (BYVAL quadObject AS ANY, BYVAL textureCoords AS DWORD)' ANY)
DECLARE SUB gluSphere LIB "glu32.dll" ALIAS "gluSphere" (BYVAL qobj AS ANY, BYVAL radius#, BYVAL slices&, BYVAL stacks AS LONG)
%GL_TRUE = 1
%GLU_SMOOTH = 100000
SUB RenderPhoenix(BYVAL edge AS SINGLE)
edge = edge / 2
CALL glTexCoord2f(0.0, 0.0): CALL glVertex3f(-edge,-edge, 0.0)
CALL glTexCoord2f(1.0, 0.0): CALL glVertex3f( edge,-edge, 0.0)
CALL glTexCoord2f(1.0, 1.0): CALL glVertex3f( edge, edge, 0.0)
CALL glTexCoord2f(0.0, 1.0): CALL glVertex3f(-edge, edge, 0.0)
CALL glEnd()
LOCAL quadObj AS LONG
glTranslatef -edge, edge, 0.0
quadObj = gluNewQuadric() ' Pointer to the Quadric Object (Return 0 If No Memory))
IF quadObj THEN
CALL gluQuadricNormals(quadObj, %GLU_SMOOTH) ' Create Smooth Normals
CALL gluQuadricTexture(quadObj, %GL_TRUE) ' Create Texture Coords
CALL gluSphere(quadObj, edge * 3, 2, 2)
CALL gluDeleteQuadric(quadObj)
END IF
END SUB
SUB MakeMutipleTexture (BYVAL tp AS BBPTEXTURE PTR, BYVAL N AS LONG)
LOCAL mtCount, K, nRet, xSize, ySize AS LONG
DIM mt(1 TO N) AS BBPTEXTURE AT tp
mtCount = UBOUND(mt()) - LBOUND(mt()) + 1
IF mtCount THEN
DIM Texture(1 TO mtCount) AS LONG
CALL glDeleteTextures(mtCount, Texture(1))
CALL glGenTextures(mtCount, Texture(1)): nRet = glGetError()
IF nRet = 0 THEN
FOR K = 1 TO mtCount
REDIM PixelArray(0) AS BYTE
IF BBP_CreateGLTextureFromFile(mt(K).FullName, xSize, ySize, PixelArray(), mt(K).Square) THEN
mt(k).Texture = Texture(K)
CALL glBindTexture(%GL_TEXTURE_2D, Texture(K)): nRet = glGetError
IF nRet = 0 THEN
CALL glTexParameteri(%GL_TEXTURE_2D, %GL_TEXTURE_MAG_FILTER, %GL_LINEAR)
CALL glTexParameteri(%GL_TEXTURE_2D, %GL_TEXTURE_MIN_FILTER, %GL_LINEAR)
CALL glTexImage2D(%GL_TEXTURE_2D, 0, 4, xSize&, ySize&, 0, %GL_RGBA, %GL_UNSIGNED_BYTE, PixelArray(0))
END IF
END IF
NEXT
END IF
END IF
END SUB
I have a bit busy time now, so not sure when 100% visually same version will be online, but wanted to put here at least temporary version without GL errors.
Emil - will do the code for gl cursor, but not sooner than in horizont of few weeks, busy times :(
Basically it is just unprojecting mouse coordinates, setting up ortho mode (2D) and drawing textured quad, ideally alpha masked.
Bye,
Petr
QuoteEmil - will do the code for gl cursor, but not sooner than in horizont of few weeks, busy times
Basically it is just unprojecting mouse coordinates, setting up ortho mode (2D) and drawing textured quad, ideally alpha masked.
yes thanks :)
i have build a GLWindow Component for my VisPlugin
i can wait .. ;)
greets Emil
Emil,
It is exactly the same than for drawing text.
See BBP_DrawGLText in BBPlugin.inc
SUB BBP_DrawGLText (BYVAL glWnd AS LONG, UseFont AS ZGLFONT, BYVAL x AS LONG, BYVAL y AS LONG, zTxt AS ASCIIZ, BYVAL ARGB AS LONG)
LOCAL rc AS RECT, A, R, G, B AS BYTE, cAlpha, cRed, cGreen, cBlue AS SINGLE, WasTexture, WasLighting AS LONG
CALL GetClientRect(glWnd, rc)
WasTexture = glIsEnabled(%GL_TEXTURE_2D)
IF WasTexture THEN CALL glDisable(%GL_TEXTURE_2D) ' Turn off textures, didn't want our text textured
WasLighting = glIsEnabled(%GL_LIGHTING)
IF WasLighting THEN CALL glDisable(%GL_LIGHTING) ' Disable Lighting
CALL glMatrixMode(%GL_PROJECTION)
CALL glPushMatrix()
CALL glLoadIdentity()
CALL glOrtho(0.0, rc.nRight, 0.0, rc.nBottom, -1.0, 1.0)
CALL glMatrixMode(%GL_MODELVIEW)
CALL glPushMatrix()
CALL glLoadIdentity()
' Set color
CALL BBP_SplitColorARGB(ARGB, A, R, G, B)
cAlpha = A + 1: cRed = R + 1: cGreen = G + 1: cBlue = B + 1
CALL glColor3f(cRed / 256, cGreen / 256, cBlue / 256)
' Set X,Y location
CALL glRasterPos2i(x, rc.nBottom - (UseFont.fontHeight - 4) - y)
' Draw the text
CALL glPushAttrib(%GL_LIST_BIT) ' Pushes The Display List Bits
CALL glListBase(UseFont.fontBase - UseFont.charStart)' Sets The Base Character to 0
CALL glCallLists(LEN(zTxt), %GL_UNSIGNED_BYTE, zTxt) ' Draws The Display List Text
CALL glPopAttrib() ' Pops The Display List Bits
CALL glPopMatrix()
CALL glMatrixMode(%GL_PROJECTION)
CALL glPopMatrix()
CALL glMatrixMode(%GL_MODELVIEW)
IF WasTexture THEN CALL glEnable(%GL_TEXTURE_2D) ' Enable texture mode
IF WasLighting THEN CALL glEnable(%GL_LIGHTING) ' Enable Lighting
CALL glColor3f(1, 1, 1) ' Back to default color
END SUB
Also check its use in the LaserBeam.bas plugin.
Added:
All you have to do is to provide a 16 x 16 texture (arrow or whatever you want). And BBP_CreateGLTextureFromFile allows you to use PNG files to create the texture.
...
Thanks for this ..
i will nothing change in the plugin self only use a OpenGl cursor in to BassVis
think this is not a problem ;)
greets Emil
See attached ZIP files
The Phoenix - Reborn
(http://www.zapsolution.com/BassBox/Phoenix.jpg)
Maelstrom
(http://www.zapsolution.com/BassBox/Maelstrom.jpg)
i have show boahhhh ;)
what is the difference from Phoenix to Maelstrom ?
Play Phoenix with Pink Floyd: Echoes :) then you can show a real Phoenix
great effekt
greets Emil
Emil,
Yes, playing Phoenix with the echo on, gives a nice result.
Phoenix and Maelstrom are based on the same concept, however the effect being used in Phoenix makes it look more like feathers, while Maelstrom looks more like a spriral.
For me the visual appearance is almost as important as the programming part, that's has always been my way since my first software written 30 years ago. 8)
Added
And yes the Pink Floyd album "Echoes" looks good with Phoenix, that looks like a flying bird with flapping wings.
...
QuoteFor me the visual appearance is almost as important as the programming part, that's has always been my way since my first software written 30 years ago.
yes, I see the same way
programming since commodore 64 :)
greets Emil
Using setup "Echo On"
Good candidates to play with Phoenix are:
Pink Floyd "The Dark Side Of The Moon", "TIME"
and "Welcome to The Machine".
Try also with Jean-Michel Jarre:
"CALYPSO PART 3 (fin de siècle)", "En attendant Cousteau".
"EQUINOXE IV" (from the Chinese concert),
"MAGNETIC FIELDS",
"OXYGENE 8", "OXYGENE 10"
"SECOND RENDEZ-VOUS (PART3)"
"TROISIEME RENDEZ-VOUS"
"QUATRIEME RENDEZ-VOUS"
"CINQUIEME RENDEZ-VOUS (PART1)"
"CHRONOLOGIE"
ERA:
"AMENO", "MOTHER", "MIRROR"
And to see the Phoenix with open wings:
VANGELIS:
"CONQUEST OF PARADISE" , "THE TAO OF LOVE", "CHARIOTS OF FIRE", etc.
Patrice
this is my music ;)
i'm 50 Year and my time
greets Emil
Here is a small color variation you could apply to the Phoenix plugin
SubRender:
CALL glBindTexture(%GL_TEXTURE_2D, mt(1).Texture)
CALL glColor3ub(PulseMemory(K).r2, PulseMemory(K).g2, PulseMemory(K).b2)
CALL RenderPolygon(xD, PulseMemory(K).length)
CALL glTranslatef(-PulseMemory(K).length * 3, PulseMemory(K).length * 3.5, 0.0)
swap PulseMemory(K).r2, PulseMemory(K).b2
CALL glColor4ub(PulseMemory(K).r2 \ 2, PulseMemory(K).g2 \ 2, PulseMemory(K).b2 \ 2, 64)
CALL glBindTexture(%GL_TEXTURE_2D, mt(2).Texture)
CALL Sphere(PulseMemory(K).length)
swap PulseMemory(K).r2, PulseMemory(K).b2
RETURN
sorry i can not compile it have no PowerBasic
greets Emil
Emil,
Attached ZIP file with Phoenix.dll plugin using the swap color mode.
...
thanks.. thanks ..
great work
greets Emil
Emil,
That's true computer Art, isn't it ;D
...
Quote from: Patrice Terrier on June 16, 2008, 04:22:21 PM
Emil,
That's true computer Art, isn't it ;D
...
yea.. hhhh ;)
wanted to make a simple Progressbar as Tripex from Winamp plugin
no idea how :'(
greets Emil
Emil,
When you have time, send me a working example of BassVis, to let me see what your code is doing.
You can send it to me there:
pterrier@zapsolution.com
...
Quote from: Patrice Terrier on June 16, 2008, 04:27:12 PM
Emil,
When you have time, send me a working example of BassVis, to let me see what your code is doing.
You can send it to me there:
pterrier@zapsolution.com
...
i have send it
doubleclick on the panel go to fullscreen
all work fine with mouse ot Keyboard
click on show with gen then a new window show you can resize it
only little problem with position from Bar .. i'm work on it ;)
greets Emil
Emil,
To make the progress bar like this winamp example, take a look at the "Impulse" plugin source code (the part that is drawn on top, and consider just the left or right channel part).
...
Quote from: Patrice Terrier on June 16, 2008, 04:34:07 PM
Emil,
To make the progress bar like this winamp example, take a look at the "Impulse" plugin source code (the part that is drawn on top, and consider just the left or right channel part).
...
i will show in to this code ;)
greets Emil
Emil
I think that you didn't check your BassVis example on a VISTA computer 8)
We can't even speak of FPS (display one single frame each second or two...)
Note: My VISTA is running in DWM composited mode (AERO)
Added:
Also it is not a good idea to change the display resolution on VISTA AERO, and it is even more problematic when you are using Dual display like myself.
...
Emil,
Also the volume level has no effect on VISTA (the whole mixer API has changed there)
Quote from: Patrice Terrier on June 16, 2008, 04:54:06 PM
Emil
I think that you didn't check your BassVis example on a VISTA computer 8)
We can't even speak of FPS (display one single frame each second or two...)
Note: My VISTA is running in DWM composited mode (AERO)
Added:
Also it is not a good idea to change the display resolution on VISTA AERO, and it is even more problematic when you are using Dual display like myself.
...
i have no Vista ;)
no idea what is wrong in vista
on xp with nvidea 7800 SLI and AMD 64 2400 MHZ run fine in 1280x1024
show pic
greets Emil
Quote from: Patrice Terrier on June 16, 2008, 05:03:56 PM
Emil,
Also the volume level has no effect on VISTA (the whole mixer API has changed there)
render from Device not work in this Sample not finish yet ;)
or your mean nothing Render ?
greets Emil
Emil,
I am speaking of the audio level trackbar, moving the slider doesn't change the audio level, that is always being played at maximum level.
I have spent myself several monthes to master the new VISTA API, and I can say that it was a huge work...
Good luck :-[
Quote from: Patrice Terrier on June 16, 2008, 05:16:55 PM
Emil,
I am speaking of the audio level trackbar, moving the slider doesn't change the audio level, that is always being played at maximum level.
I have spent myself several monthes to master the new VISTA API, and I can say that it was a huge work...
Good luck :-[
yes think is hard .. i have read any in Bass Forum for this problem
can not programming on a operation system what i not have.
XP all work good.. hmmm
no user has tell me that any wrong from Bass Forum ;) under Vista
Helium musikmanager work with bassvis on vista and Xp with no problem
EDIT:
will change any when Windows 7 avaiable
greets Emil
QuoteHelium musikmanager work with bassvis on vista and Xp with no problem
I can only speak of what i see on my VISTA computer, and so far it is unusable.
It looks like if OpenGL was software emulated and not hardware managed, perhaps a DirectX emulation?
VISTA is there and it is a reality. It can't be ignored anymore ...
Added:Switch to PowerBASIC we are always pleased to welcome talented SDK programmers ;D
QuoteI can only speak of what i see on my VISTA computer, and so far it is unusable.
It looks like if OpenGL was software emulated and not hardware managed, perhaps a DirectX emulation?
VISTA is there and it is a reality. It can't be ignored anymore ...
is Ok ;)
QuoteSwitch to PowerBASIC we are always pleased to welcome talented SDK programmers
hehehehe i think :) i'm to old switch to new developer language.
work good by me and change any when Windows 7 appears
not for Vista :-\ sorry
greets Emil
Emil
I am 9 years older than you and i have changed ;)
One more thing with your application that you must fix:
You are changing the way the window are being moved hover the desktop, and you don't restore the previous state when leaving, forcing the user to re-enable the "full move window mode" manualy...
QuoteAlso it is not a good idea to change the display resolution on VISTA AERO, and it is even more problematic
when you are using Dual display like myself.
user can ;)
i'm use in my sample this funktion from bassvis
when doubleclick on Panel..
BASSVISKIND_BASSBOX:
BASSVIS_SetFullscreen(@mVisParam,
Panel1.Handle,
frmMain.Handle,
490,
8,
320,
240,
FullScreen,
FScreenWidth,
FScreenHeight);
user can ignore this function and set the fullscreen manualy
when used Vista this is not a problem ;)
EDIT:user can fellow:
SetParent(Panel1.Handle, GetDesktopWindow);
SetWindowPos(Panel1.Handle,x,x,x ...
this nothing changed the Screen Resolution ;)
greets Emil
Emil
For the move window I am speaking of this API:
SystemParametersInfo(SPI_SETDRAGFULLWINDOWS, %FALSE, BYVAL %NULL, 0&)
Quote from: Patrice Terrier on June 16, 2008, 07:12:56 PM
Emil
For the move window I am speaking of this API:
SystemParametersInfo(SPI_SETDRAGFULLWINDOWS, %FALSE, BYVAL %NULL, 0&)
i'm use this ;)
procedure Tfrm_Gen.picBottomMMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: integer);
begin
//release capture
SetFullWindowDrag(frm_Gen.Handle, True);
//free Release
SetFullWindowDrag(frm_Gen.Handle, False);
end;EDIT:
In my Player VB
Public Function SetFullWindowDrag(ByVal hwnd As Long, ByVal ShowFullWindow As Boolean) As Boolean
' Aktiviert oder deaktiviert die Anzeige von Fensterinhalten während des
' Ziehens oder der Größenänderung von Anwendungsfenstern.
' Der Rückgabewert gibt Aufschluss darüber, ob der Aufruf zu einer Änderung
' gegenüber der vorherigen Einstellung geführt hat (True) oder nicht (False).
Dim lOldSetting As Long
Dim lSuccess As Long
' Bisherige Einstellung ermitteln:
lSuccess = SystemParametersInfo(SPI_GETDRAGFULLWINDOWS, 0&, lOldSetting, 0)
If lSuccess = 0 Then
' Der abfragende Aufruf war nicht erfolgreich
' (z.B. Windows 95 ohne "PLUS!"-Pack).
Exit Function ' Rückgabewert bleibt False
End If
' Eine Aktion ist nur dann notwendig, wenn sich der bisherige
' vom gewünschten Wert unterscheidet:
If CBool(lOldSetting) <> ShowFullWindow Then
' Wert ändern und Erfolg prüfen:
lSuccess = SystemParametersInfo(SPI_SETDRAGFULLWINDOWS, Abs(CLng(ShowFullWindow)), ByVal 0&, SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE)
If lSuccess Then
SetFullWindowDrag = True
ReleaseCapture
SendMessage hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
If stndPlayList = 1 Then
SaveSetting App.EXEName, "Playlist", "PlaylistSize", STR$(frmPlayList.Width) & "," & STR$(frmPlayList.Height)
SaveSetting App.EXEName, "Playlist", "PlaylistPos", STR$(frmPlayList.left) & "," & STR$(frmPlayList.tOp)
End If
End If
End If
End Functiongreets Emil
when move the Window and the flag in console
Window content in drag show then my code do nothing ;)
only you have the Flag set to other option
then my code changed it and restore to your settings when lost the button up
Quote' Eine Aktion ist nur dann notwendig, wenn sich der bisherige
' vom gewünschten Wert unterscheidet:
Quote'An action is only necessary if the current
'Differs from the desired value:
greets Emil
I confirm that your code changes the setting.
try it with the option "with GenBitmap" then you will see that previous state is not restored.
...
Quote from: Patrice Terrier on June 16, 2008, 08:16:57 PM
I confirm that your code changes the setting.
try it with the option "with GenBitmap" then you will see that previous state is not restored.
...
no understand what make Vista
on my system the flag is of.. show pic
and restore settings when change buttondown to up
think vista make any problems and very slow system ;) or I :) hehehehee
EDIT:
That is the reason that I'm not using itgreets Emil
Emil
VISTA is a wonderful OS for advanced graphic applications, believe me 8)
If you can give a try to BassBox on a VISTA computer, then switch to either "Blur" or "Crystal" mode and look at the aspect of the BassBox interface while you move the window hover the desktop or any other applications. I guess you will be amazed.
Also note that there is no FPS loss while moving the window hover the desktop.
See the screen shot there:
http://www.jose.it-berater.org/smfforum/index.php?topic=1372.0
And for XP see it there:
http://www.jose.it-berater.org/smfforum/index.php?topic=1283.0
http://www.jose.it-berater.org/smfforum/index.php?topic=1263.0
http://www.jose.it-berater.org/smfforum/index.php?topic=1314.0
http://www.jose.it-berater.org/smfforum/index.php?topic=1580.0
show good .. on vista ;)
I wonder why opengl with bassvis with you running so slow on Vista
and fery fast on XP
hmm .. can nothing do for it :'(
greets Emil
Emil
Quotehmm .. can nothing do for it
Yes you can, look closely in the BassBox source code at the InitOpenGL function.
Also very important in VISTA is to use this:
CALL SwapBuffers(glDC)
CALL zUpdateWindow(glCtrl, 0) '// <----
to force DWM to update the video bufferinstead of this
CALL wglSwapBuffers(glDC)
And the other solution is to disable the VISTA AERO mode, but not very friendly i think ;)
I am reporting this to you because other users of BassVis may experience the same behaviour while running on VISTA, and I think it would be hard to tell them to switch back to XP.
My previous multimedia player has been totaly broken by all the VISTA changes, and i first wrote BassBox as a kind of laboratory to experiment with.
And I have shared here, what i have learned the hard way about VISTA and without the help of MSDN that was only prolific with DotNET managed documentation ...
QuoteTo make the progress bar like this winamp example, take a look at the "Impulse" plugin source code (the part that is drawn on top, and consider just the left or right channel part).
not work by me ;)
look in to can nothing do with it
Songtext and Time now work..
greets Emil
QuoteAlso very important in VISTA is to use this:
CALL SwapBuffers(glDC)
CALL zUpdateWindow(glCtrl, 0) '// <---- to force DWM to update the video buffer
instead of this
CALL wglSwapBuffers(glDC)
ahhhh Thanks i will check this ;)
if this the same as UpdateWindow(Handle) ?
greets Emil
'// To perform immediate redraw of any Windows control.
SUB zUpdateWindow (BYVAL hWnd AS LONG, BYVAL FlagMode AS LONG)
CALL InvalidateRect(hWnd, BYVAL 0&, FlagMode)
CALL UpdateWindow(hWnd)
END SUB
Quote from: Patrice Terrier on June 16, 2008, 09:49:23 PM
'// To perform immediate redraw of any Windows control.
SUB zUpdateWindow (BYVAL hWnd AS LONG, BYVAL FlagMode AS LONG)
CALL InvalidateRect(hWnd, BYVAL 0&, FlagMode)
CALL UpdateWindow(hWnd)
END SUB
thanks ;)
i have found it in to zSkins
i have make fellow ..
// Refresh display
if SwapBuffers(glDc) = True then
Result := True;
zUpdateWindow(glCtrl, Bool(0));
ReleaseDC(glCtrl, glDc);can check OS System think not necessary
use this for XP and Vista
ok i make fellow
remove SetFullWindowDrag from Example Exe
and change Screen Resolution then send back for you a new Sample.
EDIT:procedure zUpdateWindow (Handle : integer; FlagMode : LongBool);
begin
InvalidateRect(Handle, nil, FlagMode);
UpdateWindow(Handle);
end;greets Emil
here a new sample ;)
hope it is any faster as befor
remove SetFullWindowDrag
remove change Desktop resolution
added zUpdateWindow
greets Emil
Emil,
It is better.
However without using yourself a VISTA computer, it is like shooting in the dark.
...
Quote from: Patrice Terrier on June 17, 2008, 02:36:02 PM
Emil,
It is better.
However without using yourself a VISTA computer, it is like shooting in the dark.
...
yes you have right ;)
greets Emil
Patrice
one question
activate WM_PAINT
not used befor ..
WM_PAINT:
begin
BeginPaint(WndHandle, ps);
EndPaint(WndHandle, ps);
Result := 0;
exit;
end
is this faster or slower under Vista?
have added a temp FPS .. on XP 40 Frames with 1280x1024
greets Emil
It all depends how you create the OpenGL window container.
If you use zsRegisterVisualClass then yes, it could help to perfrom a wm_paint do nothing.
On VISTA and on XP, with the latest BassBox version, the FPS rate is limited to 34.
It was 66 FPS with the previous version, but this was using more CPU resources because the real time oscilloscope and the two peak meters are drawn with GDIPLUS.
I have been told that BassBox works very well even on a little Eee PC.
...
QuoteBassBox works very
yes work great ;)
thanks for the information.
greets Emil
i have aktivate VSync now think this is better for Vista
procedure VBL2(vsync : TVSyncMode);
var
i : Integer;
begin
if WGL_EXT_swap_control then
begin
i := wglGetSwapIntervalEXT;
case VSync of
vsmSync : if i<>1 then wglSwapIntervalEXT(1);
vsmNoSync : if i<>0 then wglSwapIntervalEXT(0);
else
Assert(False);
end;
end;
end;
greets Emil
Hi Patrice
can i upload BBPlugin on my Server for BassVis ?
No Source only compiled.
greets Emil
Emil,
Speaking for my own plugins, you have my agreement to use them under the form of compiled DLL (no source code).
For Petr's and Charles's plugins, please ask the original author first, thank you!
...
Quote from: Patrice Terrier on June 26, 2008, 09:34:03 PM
Emil,
Speaking for my own plugins, you have my agreement to use them under the form of compiled DLL (no source code).
For Petr's and Charles's plugins, please ask the original author first, thank you!
...
I will ask
thanks you
What is with the Include Folder ?
any Plugin used this that it work
greets Emil
Emil,
You are welcome to use any of my BassBox plugins - including source code if you require it :)
Quote from: Charles Pegge on June 27, 2008, 04:47:44 AM
Emil,
You are welcome to use any of my BassBox plugins - including source code if you require it :)
Thanks Charles ;)
greets Emil
Hi Emil,
no problem using my plugin too, it does not contain any trade secrets :D
Petr
Quote from: Petr Schreiber on June 27, 2008, 08:30:04 AM
Hi Emil,
no problem using my plugin too, it does not contain any trade secrets :D
Petr
questions before but better :)
Thanks Emil
think work great now ;)
my MediaPlayer written in Visual Basik 6.0 used BassBox Plugin
greets Emil
Emil,
Looks like you are using a nice skinned interface (a little MAC oriented) ;)
...
Quote from: Patrice Terrier on June 27, 2008, 07:39:36 PM
Emil,
Looks like you are using a nice skinned interface (a little MAC oriented) ;)
...
use any more ;)
greets Emil
Emil,
One important feature with BassBox plugins is that they are very reactive to the music being played, following exactly the pulsating audio curve.
...
Emil
Here is why I wrote about very MAC oriented:
http://www.blueskyheart.com/scrollites.html (http://www.blueskyheart.com/scrollites.html)
;)
Quote from: Patrice Terrier on June 27, 2008, 08:03:59 PM
Emil
Here is why I wrote about very MAC oriented:
http://www.blueskyheart.com/ (http://www.blueskyheart.com/)
;)
great work :)
greets Emil
See the link that I have updated
http://www.blueskyheart.com/scrollites.html (http://www.blueskyheart.com/scrollites.html)
Quote from: Patrice Terrier on June 27, 2008, 07:57:08 PM
Emil,
One important feature with BassBox plugins is that they are very reactive to the music being played, following exactly the the pulsating audio curve.
...
it is true
due to the low CPU utilization
Better then Winamp Pluginslow CPU, good visualization, good beat to the music
allways top
greets Emil
Quote from: Patrice Terrier on June 27, 2008, 08:09:31 PM
See the link that I have updated
http://www.blueskyheart.com/scrollites.html (http://www.blueskyheart.com/scrollites.html)
fine artwork i think
greets Emil
Hi Patrice
Do you have interest make a API for PowerBasic of BAssVis ?
Here is my API in Visual Basic think is ferry simple translate it to PowerBasic.
'mBassVis.BAS
'--------------------------- VB 6.0 Form Module -----------------------------
' BassVis API Module ADD-ON for Bass Audio Library
' Copyright © 2007 BrewIdeas@Emil Weiss, All Rights Reserved
'
' Author(s) of this module: Emil Weiss
'
' Code was written in and formatted for 10pt Courier New
'----------------------------------------------------------------------------
Option Explicit
' BASS_SONIQUEVIS_CreateVis flags
Public Const BASS_VIS_NOINIT As Integer = 1
' BASS_SONIQUEVIS_SetConfig flags
Public Const BASS_SONIQUEVIS_CONFIG_FFTAMP As Integer = 1
Public Const BASS_SONIQUEVIS_CONFIG_FFT_SKIPCOUNT As Integer = 2 ' Skip count range is from 0 to 3 (because of limited FFT request size)
Public Const BASS_SONIQUEVIS_CONFIG_WAVE_SKIPCOUNT As Integer = 3 ' Skip count range is from 0 to (...) try it out, whenever Bass crashes or does not return enough sample data
Public Const BASS_SONIQUEVIS_CONFIG_SLOWFADE As Integer = 4 ' Dim light colors to less than half, then slowly fade them out
' BASS_WINAMP_SetConfig flags
Public Const BASS_WINAMPVIS_CONFIG_FFTAMP As Integer = 1
' BASS_WMP_SetConfig flags
Public Const BASS_WMPVIS_CONFIG_FFTAMP As Integer = 1
' BASS_VIS_FindPlugin flags
Public Const BASS_VIS_FIND_RECURSIVE As Integer = 4
' Plugin Kind
Public Const BASSVISKIND_NONE = 0
Public Const BASSVISKIND_WINAMP = 1
Public Const BASSVISKIND_SONIQUE = 2
Public Const BASSVISKIND_WMP = 3
Public Const BASSVISKIND_BASSBOX = 4
' Plugin Parameter
Public Type BASSVIS_PARAM
Vishandle As Long ' VisHandle
VisWinhandle As Long ' VisWinHandle
VisGenWinhandle As Long ' General Vis Window Handle
Kind As Long ' Plugin Kind (BASSVISKIND_NONE, _
BASSVISKIND_WINAMP, _
BASSVISKIND_SONIQUE, _
BASSVISKIND_WMP, _
BASSVISKIND_BASSBOX, _
)
End Type
' Definition der Typen für die variablen Parameter bei Create bzw. Execute
Public Type BASSVIS_EXEC
AMP_SON_BB_Pluginfile As String ' Dateiname des Plugins für Sonique und Winamp
AMP_UseOwnW1 As Long ' Flag für Winamp False =(Render Winamp5 im eigenen Window) 0=aus,1=an
AMP_UseOwnW2 As Long ' Flag für Winamp False =(Render Winamp2 im eigenen Window) 0=aus,1=an
AMP_Moduleindex As Long ' Modul-index für Winamp
SON_PaintHandle As Long ' Painthandle für Sonique
SON_ConfigFile As String ' Dateiname der Konfiguration für Sonique
SON_Flags As Long ' Flags für Sonique
WMP_PluginIndex As Long ' Pluginindex für WMP;
WMP_PresetIndex As Long ' Presetindex für WMP
WMP_SrcVisHandle As Long ' ContainerVisHandle für WMP
BB_ParentHandle As Long ' Parent Windowhandle
BB_Flags As Long ' Flags für BassBox selbe wie Sonique
BB_ShowFPS As Long ' Frames pro Sekunde anzeigen
BB_ShowPrgBar As Long ' Progressbar anzeigen
Width As Long ' Fensterbreite
Height As Long ' Fensterhöhe
Left As Long ' Top
Top As Long ' Left
End Type
Public Type BASSVIS_INFO
SongTitle As String ' SongTitel ohne Pfad
Songfile As String ' SongFile incl. Pfad (StreamFile)
pos As Long ' StreamPos = 1000*StreamPos
len As Long ' Stream länge
PlaylistPos As Long ' PlaylistPos minimal > 0
Playlistlen As Long ' Playlist länge
SampleRate As Long ' Samplerate default = 44100
BitRate As Long '
Duration As Long '
Channels As Long ' 2
End Type
Public Enum BASSVIS_PLAYSTATE
psError = -1
psStop = 0
psPlay = 1
psIsPlaying = 2
psPause = 3
psPrevTitle = 4
psNextTitle = 5
psSetPlaylistTitle = 6
psGetPlaylistTitlePos = 7
psSetPlaylistPos = 8
psGetSelectedTitlePos = 9
End Enum
'Core functions for initalizing BASSVIS and Find Plugins of any kind
Public Declare Function BASSVIS_Init Lib "bass_vis.dll" ( _
ByVal Kind As Long, _
ByVal AppHandle As Long, _
ByVal WinHandle As Long _
) As Boolean
'Core functions for initalizing BASSVIS and Find Plugins of any kind
'delemiter As Byte = 44 .. ASC(",")
'you can send other delemiter for Spliting
Public Declare Function BASSVIS_FindPlugins Lib "bass_vis.dll" ( _
ByVal Kind As Long, _
ByVal PluginPath As Any, _
ByVal Searchflags As Long, _
Optional ByVal delemiter As Byte = 44 _
) As Long
Public Declare Function BASSVIS_Free Lib "bass_vis.dll" ( _
ByRef param As BASSVIS_PARAM _
) As Boolean
Public Declare Function BASSVIS_GetVersion Lib "bass_vis.dll" () As String
Public Declare Sub BASSVIS_ExecutePlugin Lib "bass_vis.dll" ( _
ByRef param As BASSVIS_EXEC, _
ByRef Base As BASSVIS_PARAM _
)
Public Declare Function BASSVIS_RenderChannel Lib "bass_vis.dll" ( _
ByRef param As BASSVIS_PARAM, _
ByVal channel As Long _
) As Boolean
Public Declare Function BASSVIS_StartRecord Lib "bass_vis.dll" ( _
ByRef param As BASSVIS_PARAM, _
Optional ByVal SampleRate As Long = 44100, _
Optional ByVal Channels As Long = 2 _
) As Boolean
Public Declare Function BASSVIS_Config Lib "bass_vis.dll" ( _
ByRef param As BASSVIS_PARAM, _
Optional ByVal Entry As Long = 0 _
) As Boolean
Public Declare Function BASSVIS_SetInfo Lib "bass_vis.dll" ( _
ByRef param As BASSVIS_PARAM, _
ByRef infos As BASSVIS_INFO _
) As Boolean
Public Declare Function BASSVIS_Resize Lib "bass_vis.dll" ( _
ByRef param As BASSVIS_PARAM, _
ByVal Left As Long, _
ByVal Top As Long, _
ByVal Width As Long, _
ByVal Height As Long _
) As Boolean
Public Declare Function BASSVIS_SetFullscreen Lib "bass_vis.dll" ( _
ByRef param As BASSVIS_PARAM, _
ByVal SourceHandle As Long, _
ByVal DestHandle As Long, _
ByVal SourceLeft As Long, _
ByVal SourceTop As Long, _
ByVal SourceWidth As Long, _
ByVal SourceHeight As Long, _
ByVal FullScreenFlag As Boolean, _
ByVal FullScreeWidth As Long, _
ByVal FullScreenHeight As Long _
) As Boolean
Public Declare Function BASSVIS_GetModulePresetCount Lib "bass_vis.dll" ( _
ByRef param As BASSVIS_PARAM, _
ByVal PluginName As Any _
) As Long
Public Declare Function BASSVIS_GetModulePresetName Lib "bass_vis.dll" ( _
ByRef param As BASSVIS_PARAM, _
ByVal index As Long, _
ByVal PluginName As Any _
) As Long
Public Declare Function BASSVIS_GetModulePresetNameList Lib "bass_vis.dll" ( _
ByRef param As BASSVIS_PARAM, _
ByVal PluginName As Any _
) As Long
Public Declare Function BASSVIS_SetModulePreset Lib "bass_vis.dll" ( _
ByRef param As BASSVIS_PARAM, _
ByVal index As Long _
) As Boolean
Public Declare Function BASSVIS_GetOption Lib "bass_vis.dll" ( _
ByRef param As BASSVIS_PARAM, _
ByVal options As Long _
) As Long
Public Declare Function BASSVIS_SetOption Lib "bass_vis.dll" ( _
ByRef param As BASSVIS_PARAM, _
ByVal options As Long, _
ByVal value As Long _
) As Boolean
Public Declare Function BASSVIS_SetPlayState Lib "bass_vis.dll" ( _
ByRef param As BASSVIS_PARAM, _
ByVal State As BASSVIS_PLAYSTATE, _
Optional ByVal value As Long = -1, _
Optional ByVal Title As Any = "" _
) As Long
Public Declare Function BASSVIS_GetPluginHandle Lib "bass_vis.dll" ( _
ByVal Kind As Long, _
ByVal Pluginfile As Any _
) As Long
Public Declare Function BASSVIS_GetPluginName Lib "bass_vis.dll" ( _
ByRef param As BASSVIS_PARAM _
) As Long
Public Declare Function BASSVIS_IsFree Lib "bass_vis.dll" ( _
ByRef param As BASSVIS_PARAM _
) As Boolean
Public Declare Sub BASSVIS_Quit Lib "bass_vis.dll" ( _
ByRef param As BASSVIS_PARAM _
)
Public Declare Sub BASSVIS_SetVisPort Lib "bass_vis.dll" ( _
ByRef param As BASSVIS_PARAM, _
ByVal WindowHandle As Long, _
ByVal ContainerHandle As Long, _
ByVal x As Long, _
ByVal y As Long, _
ByVal Width As Long, _
ByVal Height As Long _
)
Public Declare Sub BASSVIS_WINAMP_SetStateCallback Lib "bass_vis.dll" ( _
ByVal callback As BASSVIS_PLAYSTATE _
)
Public Declare Sub BASSVIS_WINAMP_RemoveCallback Lib "bass_vis.dll" ()
Public Declare Function BASSVIS_SONIQUEVIS_Clicked Lib "bass_vis.dll" ( _
ByVal handle As Long, _
ByVal x As Long, _
ByVal y As Long _
) As Boolean
Public Declare Function BASSVIS_SONIQUEVIS_RenderToDC Lib "bass_vis.dll" ( _
ByVal Kind As Long, _
ByVal handle As Long, _
ByVal channel As Long, _
ByVal canvas As Long _
) As Long
Public Declare Function BASSVIS_SONIQUEVIS_RenderToDC2 Lib "bass_vis.dll" ( _
ByVal Kind As Long, _
ByVal handle As Long, _
ByVal data As Long, _
ByVal fft As Long, _
ByVal canvas As Long, _
ByVal flags As Long, _
ByVal pos As Long _
) As Long
' ************** End BASSVIS Interface **************
'*****************************************************
' Windows API Declaration
Private Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" ( _
ByVal lpString As Long _
) As Long
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
ByRef Destination As Any, _
ByRef Source As Any, _
ByVal Length As Long _
)
Public Function VBStrFromAnsiPtr(ByVal lpStr As Long) As String
Dim bStr() As Byte
Dim cChars As Long
On Error Resume Next
' Get the number of characters in the buffer
cChars = lstrlen(lpStr)
' Resize the byte array
ReDim bStr(0 To cChars - 1) As Byte
' Grab the ANSI buffer
Call CopyMemory(bStr(0), ByVal lpStr, cChars)
' Now convert to a VB Unicode string
VBStrFromAnsiPtr = StrConv(bStr, vbUnicode)
End Function
greets Emil
Already done :)
See the second post of this thread: http://www.jose.it-berater.org/smfforum/index.php?topic=1749.0
Quote from: José Roca on July 19, 2008, 08:19:59 AM
Already done :)
See the second post of this thread: http://www.jose.it-berater.org/smfforum/index.php?topic=1749.0
ahh great only support for BassBox not in the File
i will show how can added it self
thanks for the work
greets Emil
i have update it.. and added it to BassVis Archive
ups.. reload it
have forget changed this line
Quote' BassVis 2.4.1.1
' An extension allowing the use of Sonique, Winamp, and Windows Media Player and BassBox visual plugins with BASS.
greets Emil
Emil
This is the old version that i did for XP (ZAP Visual Plugin)
http://www.zapsolution.com/zvpus.htm (http://www.zapsolution.com/zvpus.htm)
But now, i want one working with VISTA (and XP) and the name of it is: BassBox ;D
...
Quote from: Patrice Terrier on July 19, 2008, 08:44:57 AM
Emil
This is the old version that i did for XP (ZAP Visual Plugin)
http://www.zapsolution.com/zvpus.htm (http://www.zapsolution.com/zvpus.htm)
But now, i want one working with VISTA (and XP) and the name of it is: BassBox ;D
...
hmm i have write a bad name ? shame
or you will write a Sample for that named
BassBoxi have finish now my OpenGl Plugin for Winamp think show good
greets Emil
i hope i can post my problem here
attached 2 picture strip one 12x5 and own 2x255
i search for a way that i can use with my source drawspectrum the palette from 2x255 Bitmap strip
this work only with 12x5
remove old code
i hope anybody can help me
spectrum show as 2.jpg from Spectrum4.bmp
greets Emil
Better to use a ColorLUT.
See in any of my plugin source code how i am using this:
GLOBAL gColor() AS LONG
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
ok thanks Patrice
greets Emil
Hi patrice
my spectrum show now with this..
my problem
i will not that any bar change to one color .. sample RED
should be full Color like Palette
can you help me ?
work this not with Quads ?
glBegin(GL_QUADS);
for i :=0 to mSpecBars-1 do
begin
if UsePalette then
begin
RGBColor := gColor[i];
cbR := GetRValue(RGBColor);
cbG := GetGValue(RGBColor);
cbB := GetBValue(RGBColor);
glColor4ub(cbR, cbG, cbB, 0);
end;
x1:=i*d1+d2;
x2:=(i+1)*d1+overdraw;
z2:=-heights[0][i]+z1-2.0*(d1-d2);
h2:=z1-d12d;
h3:=z2+d12d;
glTexCoord2f(0.0,0.0); glVertex3f(-x1,y,z1);
glTexCoord2f(1.0,0.0); glVertex3f(-x2,y,z1);
glTexCoord2f(1.0,0.3); glVertex3f(-x2,y,h2);
glTexCoord2f(0.0,0.3); glVertex3f(-x1,y,h2);
glTexCoord2f(0.0,0.3); glVertex3f(-x1,y,h2);
glTexCoord2f(1.0,0.3); glVertex3f(-x2,y,h2);
glTexCoord2f(1.0,0.7); glVertex3f(-x2,y,h3);
glTexCoord2f(0.0,0.7); glVertex3f(-x1,y,h3);
glTexCoord2f(0.0,0.7); glVertex3f(-x1,y,h3);
glTexCoord2f(1.0,0.7); glVertex3f(-x2,y,h3);
glTexCoord2f(1.0,1.0); glVertex3f(-x2,y,z2);
glTexCoord2f(0.0,1.0); glVertex3f(-x1,y,z2);
//end;
end;
glEnd();
i hope you understand what i mean ;)
greets Emil
http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=236286
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glBegin(GL_QUADS);
//red color
glColor3f(1.0,0.0,0.0);
glVertex2f(-1.0, 1.0);
glVertex2f(-1.0,-1.0);
//blue color
glColor3f(0.0,0.0,1.0);
glVertex2f(1.0,-1.0);
glVertex2f(1.0, 1.0);
glEnd();
Quote from: Patrice Terrier on July 24, 2008, 11:55:21 PM
http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=236286
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glBegin(GL_QUADS);
//red color
glColor3f(1.0,0.0,0.0);
glVertex2f(-1.0, 1.0);
glVertex2f(-1.0,-1.0);
//blue color
glColor3f(0.0,0.0,1.0);
glVertex2f(1.0,-1.0);
glVertex2f(1.0, 1.0);
glEnd();
this is a simple gradient with 2 Color i use 255 Color Pallete strip from Bitmap
is not the same ;)
thanks ..
greets Emil
then just draw horizontal stacked line of 2 or more pixel using indiviual color, and show them superimpose along the Y axe.
I am using the same technic in BassBox with rectangles, to draw the view meters shown on both side of the oscilloscope.
BassBox has been updated!
Version from july, 27, 2008 has been added,
it uses the latest Skin Engine and new backgrounds.
This is to celebrate the more than 30000 lurkers of this thread 8)
Added:
The BassBox24.zip is attached to the first post of this thread.
Added:
The ALIEN effect
See the settings on the top left corner
Hi Patrice,
thanks a lot. One idea - I think the FPS counter should be visible only when bassbox is launched with "-diagnostics" parameter or something, it looks too much "debug" stuff to me as "user" :)
Petr
Petr,
QuoteFPS counter should be visible only ...
Easy to solve, just REM this code out:
' hCtrl = zStaticLabelEx(hMain, "", 736, 23, 45, 15, %ID_FPS, SK_INACTIVECAPTION(), %BS_LABEL_LEFT, 1)
' CALL zSetAnchorMode(hCtrl, %ANCHOR_RIGHT)
' CALL zSetZorder(hCtrl, %HWND_TOP)
;D
By the way i would be glad to try some of your 3D's work, do you have some demo written in PB?
...
(that i could also post, under the form of screen shots, in the "Written in powerBASIC" section)
Hi Patrice,
I know I know :)
Quote
By the way i would be glad to try some of your 3D's work, do you have some demo written in PB?
[OT]
Here comes kind of paradox part - I write TBGL DLL completely in PowerBASIC for Windows/8.04, but I use functions from this module in ThinBasic. I have tons of TB demos using PB powered module ... So I am not sure if that counts, probably not?
My last big application-type 3D project in PB is: ThinEdge (http://psch.thinbasic.com/thinedge.html).
3D editor ... but it has not been updated for ages ( year or so ), so I am not sure if it would not do kind of "negative advertisement" for PB. I use the WIP version almost daily, but it really does not meet requirements for "proffesional" app yet ( especially the help file is brief ).
I am rewriting ThinEdge ( hearing to your timer suggestions too), once it will be out I will publish link and images here. It will be 100% PB project again.
Second big project was ClassEd, created by order of customer, to suit his needs. So single copy business. You can see screen here:
ClassEd visualization (http://www.komeskola.cz/help.htm).
I have lot of smaller games done in PB, but their code is not perfect, as I was learning OpenGL on them, nor the games are in finished state ... all just concept demos, sometimes not even that.
Time time time ... that's what I need desperately :)
[/OT]
Petr
Patrice
good work as always..
greets Emil
Petr, Emil,
Thank you.
The next feature i would like to add to BassBox, is to simulate composited mode.
Patrice,
I found one problem with the way BassBox plugins create textures.
Problem is on line:
Quote
CALL glTexImage2D(%GL_TEXTURE_2D, 0, 4, xSize, ySize, 0, %GL_RGBA, %GL_UNSIGNED_BYTE, PixelArray(0))
... that 4. While it is according to specs, it is recommended to use %GL_RGBA8 instead. It has basically the same meaning, but the equate has different value and should prevent some issues with ATi ( and possibly other ) drivers.
So it should be like this in the end:
Quote
CALL glTexImage2D(%GL_TEXTURE_2D, 0, %GL_RGBA8, xSize, ySize, 0, %GL_RGBA, %GL_UNSIGNED_BYTE, PixelArray(0))
Hope it will help prevent some issues.
Petr
Petr, that's good to know - I'll make sure that is fed through to my future Opengls.
Patrice, I am out of the BassBox orbit for the time being but I hope to catch up with developments in due course - Many thanks for your sustained work on this project.
Petr,
I for myself, NVIDIA user, made the choice of 4 because in my GDImage i am using RGBA exclusively to create composited graphic (with variable opacity).
(see the GDImage "illusion" demo)
Howevr it seems that there are some divergent opinions about that:
http://berkelium.com/OpenGL/GDC99/internalformat.html (http://berkelium.com/OpenGL/GDC99/internalformat.html)
http://www.flipcode.com/archives/Cool_It_Works-Issue_05_32-Bit_GL_Textures_Log_Files.shtml (http://www.flipcode.com/archives/Cool_It_Works-Issue_05_32-Bit_GL_Textures_Log_Files.shtml)
I shall make a test with %GL_RGBA8 to see if it could work on VISTA in composited mode.
Charles,
Thank you again for your different ASM contributions.
Hi Patrice,
GL_RGBA8 should mean R-8bits, G-8bits, B-8bits, A-8bits.
The documents you linked are interesting, and I think they do not go against what I suggested.
The point is, when using GL_RGBA8, you are suggesting to preserve full quality. With GL_RGBA without bits specified I have noticed on some cards the driver would convert bitmaps to 16bit color, which might be faster, but makes your eyes sad when looking what impact it did have on visual quality in blending. This fact is also mentioned in second link you posted.
Petr
%GL_RGBA8 works well also with VISTA, so we can use it as well.
Thank you
Windows Vista and OpenGL-the Facts ..
http://www.opengl.org/pipeline/article/vol003_9/
greets Emil
Emil
I know this article, and i would say that it is not accurate.
BassBox has been highly optimized to work on VISTA, and indeed it runs faster on it than on XP even in full AERO mode.
However it tooks me many weeks until i was able to master the DWM composited mode, and it is almost impossible to develop for VISTA without using yourself a computer running it.
On my computer I can run BassBox, MovieBox (playing HD movie), and PhotoSetup (running in full crystal clear mode) at full speed while i am able to move anything without filcker and without lag...
Something i am unable to do on XP.
VISTA, once you know how to use it, is realy great for intensive graphic application. However the main issue is the lack of reliable informations as soon as you are not using WPF nor managed code.
Being a SDK programmer I had to find everything by myself, but fortunatly DWM is also written in plain SDK procedural mode for the purpose of speed and optimization.
Last thing, if you want to create graphic application that will work with VISTA in DWM composited mode, then move on to GDIPLUS, or switch to GDImage ;)
Patrice
QuoteLast thing, if you want to create graphic application that will work with VISTA in DWM composited mode, then move on to GDIPLUS, or switch to GDImage
i think speed not a problem from BassVis
when use a Picbox in Application for OpenGL think this make the renderring slow
also make a simple sample in PowerBasic for BassVis
BassBox with BassVis think you have a full speed on Vista.
greets Emil
I don't know what a picbox is, nor what it does behind the hood.
About BassVis:
If you want it to work on VISTA, you have to disable the composited mode and work in XP mode compatibility.
Then you got the same speed than on XP.
...
QuoteI don't know what a picbox is, nor what it does behind the hood.
PictureBox is a Container (Control) from any Language C/VB or other.
greets Emil
Emil
If this could console you, C# Visual Studio 2005 PictureBox (indeed i know the name, but not what it does behind the hood) has the same problem. I have no idea if this has been fixed with VS2009 or not.
Patrice
Please can you send me or upload the *.rc or res file from BassBox ?
i have learn any from BassBox not understand that i have no skined button when deaktive resource File *.pbr
i think is a problem BassBox not found the right ID for the Controls.
i will show in the *.rc or *.res File which technik your use.
greets Emil
QuotePlease can you send me or upload the *.rc or res file from BassBox ?
Emil,
There is nothing fancy in the control.pbr resource file as you can see below.
1 - The
control.rc file:
PROGRAM ICON BASSBOX.ICO
// Manifest info for WinXP theme support
#define CREATEPROCESS_MANIFEST_RESOURCE_ID 1
#define RT_MANIFEST 24
#define CONTROL_PANEL_RESOURCE_ID 123
CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "control.man"
2 - The
control.man file:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
version="1.0.0.0"
processorArchitecture="X86"
name="www.zapsolution.com"
type="win32" />
<description>WinXP Manifest For ZAP</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df"
language="*" />
</dependentAssembly>
</dependency>
</assembly>
Added:The use of the manifest file, is to use the Windows XP style as the default when the child controls are not skinned.
...
Thanks Patrice
Sample from BassBox
%ID_BTN_PLAY = 1
Do not has this ID include in the Resource File ?
when deaktivate for testing
#RESOURCE "control.pbr"
then skined PlayButton no longer work when move the mouse over oder click on it.
what i can show is a original button
only for interest how it no longer work when deaktivate this
greets Emil
Emil,
First, you probably don't use the latest zSkin.inc (see BassBox24, or the PhotoSetup project)
Second, the UxTheme.dll trampolin is more versatile than the obsolete API that was responsible to draw the "button" class since Windows 3.01.
Third, move on to VISTA. :)
patrice
Quote from: Patrice Terrier on October 06, 2008, 02:23:03 PM
Emil,
First, you probably don't use the latest zSkin.inc (see BassBox24, or the PhotoSetup project)
Second, the UxTheme.dll trampolin is more versatile than the obsolete API that was responsible to draw the "button" class since Windows 3.01.
Third, move on to VISTA. :)
patrice
please show Pic
that is what i mean ...
my question work BassBox only when aktivate manifest or id this not the problem
Only what i have changed deaktivate the control.pbr in BassBox.pas
greets Emil
There is an extra WM_NC message sent by XP that would cause this,
then it redraws the ugly default button hover my nice skinned one, but this won't occure if you use the UxTheme.dll.
I don't remember exactly if it is WM_NCPAINT or another message that would cause this behavior.
I did spend many days to make BassBox compatible with both XP and VISTA, thus better to keep existing code unchanged, if you won't get into trouble.
...
Quote from: Patrice Terrier on October 06, 2008, 05:32:49 PM
There is an extra WM_NC message sent by XP that would cause this,
then it redraws the ugly default button hover my nice skinned one, but this won't occure if you use the UxTheme.dll.
I don't remember exactly if it is WM_NCPAINT or another message that would cause this behavior.
I did spend many days to make BassBox compatible with both XP and VISTA, thus better to keep existing code unchanged, if you won't get into trouble.
...
BassBox is a great Software and i will nothing change on it..
only i will learn from it no other Software what i use has so a good program style and Interface
i will show in to UxTheme.dll what i can do with my Soft that's paint correctly
sorry for my bad english
greets Emil
QuoteBassBox is a great Software and i will nothing change on it..
only i will learn from it no other Software what i use has so a good program style and Interface
Thanks
i have aktivate the resource back and deaktivate all sub and function used UxTheme.dll in BassBox
All work fine not understand what is the difference that's you have no skined button
only when deaktivate resource file.
greets Emil
Emil,
If you deactivate the whole resource file, then you will have a conflict with this:
wc.hIcon = LoadIcon(wc.hInstance, "PROGRAM")
in such a case the icon must be loaded from file, or use wh.hIcon = 0.
...
I have attached a new Plugin24.zip to the first post of this thread.
These plugins must replace those provided with BassBox24.zip
Purpose of this upgrade:
See new DestroyTexture() subroutine and updated MakeMultipleTexture
SUB MakeMultipleTexture (BYVAL tp AS BBPTEXTURE PTR, BYVAL N AS LONG)
LOCAL mtCount, K, nRet, xSize, ySize, OkDelete AS LONG
DIM mt(1 TO N) AS BBPTEXTURE AT tp
mtCount = UBOUND(mt()) - LBOUND(mt()) + 1
IF mtCount THEN
DIM Texture(1 TO mtCount) AS LONG
FOR K = 1 TO mtCount
Texture(K) = mt(k).Texture: IF Texture(K) THEN OkDelete = -1
NEXT
IF OkDelete THEN CALL glDeleteTextures(mtCount, Texture(1))
CALL glGenTextures(mtCount, Texture(1)): nRet = glGetError()
IF nRet = 0 THEN
FOR K = 1 TO mtCount
REDIM PixelArray(0) AS BYTE
IF BBP_CreateGLTextureFromFile(mt(K).FullName, xSize, ySize, PixelArray(), mt(K).Square) THEN
mt(k).Texture = Texture(K)
CALL glBindTexture(%GL_TEXTURE_2D, Texture(K)): nRet = glGetError
IF nRet = 0 THEN
CALL glTexParameteri(%GL_TEXTURE_2D, %GL_TEXTURE_MAG_FILTER, %GL_LINEAR)
CALL glTexParameteri(%GL_TEXTURE_2D, %GL_TEXTURE_MIN_FILTER, %GL_LINEAR)
CALL glTexImage2D(%GL_TEXTURE_2D, 0, 4, xSize&, ySize&, 0, %GL_RGBA, %GL_UNSIGNED_BYTE, PixelArray(0))
END IF
END IF
NEXT
END IF
END IF
END SUB
...
Thanks Patrice
i have update my archive of BassBox24
greats Emil
great Work Patrice !
do you have posted the sourcefiles too??
the sourcefiles will be a good lesson to me to understand more the basslib and C#.
Thx
Jim
C#? It has been written using PowerBASIC.
The sources are attached to the first post of the thread.
Quotethe sourcefiles will be a good lesson to me to understand more the basslib and C#.
BassBox is not written in C# but in plain low level API using pure SDK style and PowerBASIC.
While being also a C# programmer, i prefer to use plain Win32 to get the maximum speed and smaller code size, and without the hassle to install the Dot.NET framework.
Note: Anyway the source code is already provided and should be easy to translate if you know how to use the flat API.
(see the zip file attached to the first post of this thread)
8)
Added:cross post with José's answer.
Quote from: Jim Panse on November 02, 2008, 12:38:22 PM
great Work Patrice !
do you have posted the sourcefiles too??
the sourcefiles will be a good lesson to me to understand more the basslib and C#.
Thx
Jim
Almost 95% of the source code you will find here is written and compilable with PowerBasic compiler (http://www.powerbasic.com).
Regards
Eros
PS: sorry if I insist on this even if others have already stated it but I just wanted to stress the concept a little more ;)
I have checked BassBox with the latest Bass.dll version 2.4.2.3 and it works well.
You can download Bass.dll 2.4.2.3 there (http://uk.un4seen.com/files/bass24.zip)
Note: version 2.4.2.3 will not work with the older BassBox, you must use it with BassBox24.
...
It has been long since i have not posted a new plugin for BassBox.
Here is Flashback, it is hard to give you a good idea of the result even with this screen shot:
(http://www.zapsolution.com/pictures/Flashback.jpg)
Note: it is intended to work witn the latest BassBox version.
Enjoy!
looks very good :)
greets Emil
While thinking about Petr's MD2 and a Sydney plugin, i come to hat one that i wanted to share with you.
(http://www.zapsolution.com/pictures/Stardust.jpg)
Hi Patrice,
this looks good, reminds me of Star Trek teleportation.
Regarding MD2ing - I am now blocked till Thursday 6th, then I can try to move the MD2 to BassBox. Will be fun :)
Petr
Petr,
Yesterday evening my VISTA graphic card has blown up while i was working on the "Stardust" plugin.
I had no other choice than buying a new laptop this morning :'(
And i am reinstalling everything... thus you can imagine my level of stress.
...
Hi Patrice,
I am really sorry to hear that. My PC died last autumn too, this is always bad situation.
In my case I tried to find something positive about it so I took it as sign it is time for new graphic card.
How did you recovered old data?
Which graphic card your new laptop has?
I am stll fighting with my new computer, however you will find attached to this post a preview version of the Stardust.dll plugin, i shall post the source code there once completed.
Petr,
My new graphic card is a nVidia GeForce 9600M GT with 512 Mb of dedicated DDR2.
And the laptop is a HP HDX18 using a full HD video display (1920 x 1080).
Hi Patrice,
worked well on my PC, just that background was missing as it is not part of download.
I liked it.
Your laptop seems very good one, I have GeForce 9500 GT 512DDR3, I am very happy with it, so I guess 9600 will be "lifetime" choice :)
Maybe you know it already, but GeForce 9xxx can accelerate PhysX (physics simulations), CUDA computing and OpenGL 3.0 in hardware.
At this time, it is really dream card.
Regarding BassBox - what about creating new thread for year 2009? Current 40+ pages of this thread could discourage some people from reading.
Here is the missing Interference background
Hello..
I create this nice Cube as BassBoxplugin!! Enjoy or do more with it!! :o
Source code is included..
Jürgen,
Thank you for posting a new BassBox plugin.
About the ZIP file, please provide only the plugin itself.
Also be aware that the latest BassBox version is 2.50, yours was an older one.
...
Sorry Patrice,
I am really sorry, because i`ve posted also the wrong ZIP file!!
The Version i`ve send with the ZIP file is not tested and only
a saved Backup on the Way to this new BassBox plugin.
Think, i was a bit lazy that time...
The right One has more Functions, less error`s, help.txt and so on..
It`s here with only the plugin itself, help.txt and the Source code included...
Regards,
Jürgen Huhn
Jürgen,
Very important:
To handle the keyboard or mouse messages from within a plugin, you must process the %BBP_KEYBOARD and %BBP_MOUSE messages and NEVER subclass the main BassBox windowproc.
To learn how to do it, please look at these plugins:
Woofer, Spectrum, Laser beam, Genesis, Hal.
Use space bar to restore initial location, and the BBP_SetReg and BBP_GetReg API to save/restore parameters to/from registry.
...
Hello Patrice!
Sorry!!
I did not spend enough time to study the Examples!
But now i think to know the way how to do it right.
I have removed the subclassing of the main BassBox windowproc!!
Also added the Function to save or restore the last used
BLENDING,LIGHTING and COLOR settings to the Registry..
Think, i did it right this time, because it works well.
Additional, i`ve cleaned up the code by removing all not used
Functions and changed the Version to 1.1.
I`m very happy about your help and support to make this little
OpenGL-Demo a real BBplugin! "Thank you!!"
Regards,
Jürgen Huhn
Hi..
By learning more about coding with Powerbasic, i created additional
BassBox plugin Examples based on the Code of JH_ImageCube BBplugin.
Also a new BBplugin:
JH_DancingCubes Version 1.0
I would like to share my work here, because these Examples are so simple and
easy to understand..
To get 300 little dancing Cube`s on the Screen, i've used the "JH_Cube" Function
with the Encounter.bbm file, that`s included in the BassBox Files.
On the Keyboard press B, L or double click the mouse Button`s to
switch blending or Light on and off...
Click the right mouse Button to switch the Background on and off.
Reset to defaults with the spacebar.
Read the Examples to create your own BBPlugin!!
The source Codes are included in the zip.
It`s also possible to render OpenGL and GDI together in the same Window...
Read the MSDN documentation for the use of the OpenGL API!!
Sorry for my bad English!
Regards,
Jürgen Huhn
I have one more...
Really nice!
I`ve used existing and in the BassboxV2.5 included Textures, but i put all needed files into the zip..
This plugin is not ready yet, but the first testet Version.
Enjoy and reply if any Question!!
Jürgen Huhn
Jürgen
That's a good surprise, i like this one!
Don't forget to include the source code of the plugin, when you post here ;)
I have reworked the BassCubeTexture.png to preserve the aspect of the logo, and it is attached to this post.
...
Hello Patrice!
Thank you very much for reworking the BassCubeTexture.png!
This BassCubeTexture.png is really good!
Within my other Plugin`s, it look`s also very nice!!
I like it more as my own one and it fit`s much better into the Scene!
...Well done!! :)
You post this nice Surprise the right Time, because i`ve just finished
the first final Version: "JH_StarDance V1.1.dll " this Weekend.
I hope you like it as well! It`s a bit different, more Light,
more colors on the Crome.jpg, faster color changing and more... see it!
Your "BassCubeTexture.png" gave me the Inspiration to render the BassBox-Logo
as a pumpin or pulsating Part of the Scene. Without changing your new BassCubeTexture.png!!
I've created a new Texture for this Effect... Named it "InfraBassCubeTex.png"
For All and to the BBPlugin:
The included JH_StarDance V1.1.dll was tested 42 Hours non stop running on 2 Systems under
WindowsXP with the small, but really great BassBox-V2.5 without any Problem!!
Both Systems with 4GB-Ram, NVidia-GeForce 8800-Ultra 750MB and Pentium-CPU,
DualCore 3,4Ghz EM64T and one with an extreme Edition P4HT 3.6Ghz.
I put a Help.txt, the new "BassCubeTexture.png" and "InfraBassCubeTex.png", the SourceCode,
the JH_ImageCubeA.INC,JH_StarDance V1.1.dll, the Star.PNG, the Chrome.jpg and
the infraredsky.jpg into the package.
Also the OldBassCubeTexture.png, to switch back to it by double click on the middle Mousebutton.
Take another Texture if you don`t like this, rename it to OldBassCubeTexture.png or
change the SourceCode..
Read the Help.txt how to use the Functions!
For the first time, it`s all..
Do you have a Problem or Question, please Reply to this post!
Sorry for my English..
Enjoy your Music with one more BBPlugin,
Regards and thank`s to Patrice Terrier,
Jürgen Huhn
I have reworked the SourceCode today and modified
the Magic Color Section for the Crome-Texture!
Also adjusted the InfraBassCubeTex.png a bit to get better pulsing Effect!..
Here is the Update..
;)
Jürgen,
Very nice work, thank you for your contribution!
...
Patrice,
i`m just in the Beginning to use Powerbasic, normally i use C++ for programming the OpenGL.
I`ve learned so much about advanced SDK programming with PowerBasic, most out of your Board
and from your shared Examples how to do it with the OpenGL and the GDI graphic library.
I found no other Forum with a Board like yours!!
Also i get your fantastic BassBox with a real openGL-Window... Very fast and usefull!!
I was happy about your reworking the BassCubeTexture.png and your Support on the
Way to this BBPlugin.
What shall i say?
When i get something, i want to give something back!!
That`s why i made this 2.50 BBplugin!!
It`s a Gift to you and if you like, put it into your BassBox 2.50 Package.
It`s not tested on Vista, but i think that`s no Problem.
Let me now if something wrong, i fix it!!
Next i have to install Vista and move my System to it!
Have a nice Day..
Jürgen Huhn
Jürgen,
As you have seen,
BassBox doesn't use any third party OpenGL addon nor any other encapsulation except the DirectSound
Bass.dll from
Ian Luck.
For everything else, it is just plain low level SDK flat API, hence the speed and the size of the resulting EXE.
The good thing about this forum is:
what you will learn here could be use with any Windows programming language, because the core API is the only common denominator to all of them :)
They are also a few OpenGL gurus here:
Petr Schreiber and
Charles Pegge (the ASM guy).
And i would like to give a special dedicace to
José Roca and his wonderful work in making this forum one of the most valuable SDK programming resource place hover the Internet.
Added:
QuoteIt`s not tested on Vista, but i think that`s no Problem.
As long as you respect the BBPlugin specs, then you will not encounter any problem with VISTA, and BassBox.
...
Hi Patrice..
For sure, i`ve used only the openGL and respected the BBPlugin 2.50 Specifications!
It`s exactly the Reason why i think, that`s running on Vista without any Problem..
And then, your BassBox is enhanced for Vista..
To avoid flickering or more Frames per Second as the Frequence of Display Device,
the BBPlugin enables V-Sync by using the pointer wglSwapIntervalEXT..
Because the EXE is running so fast With my GeForce 8800-Ultra that i ask me,
what`s going on with a GeForce 9xxx!? It`s Pretty cool!
I realised, What i learn here could be use with any Windows programming language
and that`s possible to translate most of my C++ codes to the fast SDK-Style.
Thank`s a lot for your confirmation!!
I saw the great OpenGL-Examoles from Petr Schreiber and Charles Pegge, but i didn`t
found the Time to go deeper into the Work of them.
I will do that as soon as it`s possible..
And José Roca and his wonderful work is absolute incredible!!
Deep Respect!!
Enough Reasons for me to say, this Forum is the Best i found in the Net!!
Thank you to the hole Forum Team!
... :) :)
Hey guys,
I am trying to add in support for BassBox plugins into my visual fx library. I have translated the structure from the BBPlugin.inc to c++ and I have come up with the code below. All plugins work except for anything that uses WIMData. My code crashes on the call to BBProc with BBP_RENDER for any plugins that use the WIMData, otherwise all works great.
So I thought it was probably due to an error in my structure translation, maybe a wrong datatype since if I am off by even 1 byte for any datatype before the WIMData then that could cause this crash. However I wrote code to do sizeof() on each member of the struct and it all adds up to 256 bytes which is correct based on the documentation in the header. Everything looks to be in the right order too, however my eyes are now square from starring at this code lol.
So now I am left wondering what I have done wrong. Has anyone else ever translated this struct over to c++? Can anyone here confirm that my structure looks correct for c++?
Thanks,
Greg
typedef struct _BBPLUGIN
{
long Msg;
HWND ParentWindow;
HDC DC;
HGLRC RC;
WORD LeftPeak;
WORD RightPeak;
char Title[32];
char Author[64];
DWORD Version;
long RenderTo;
long BackARGB;
DWORD FFTdata;
WORD FFTsize;
long WinMsg;
long wParam;
long lParam;
DWORD WIMdata;
DWORD MediaLength;
DWORD MediaPos;
char Reserved[98];
}BBPLUGIN;
Greg,
So far i can't see any error in the BBPLUGIN structure.
However there is a problem with the code you sent me about WIMdata.
Quotelong nLevel = BASS_ChannelGetLevel(hStream);
long lPeak, rPeak;
lPeak = SolvePeak(LOWORD(nLevel), 128);
rPeak = SolvePeak(HIWORD(nLevel), 128);
/*
global variables
===========
float bb_fft[256];
short bb_data[1024];
*/
BASS_ChannelGetData(hStream, bb_fft, BASS_DATA_FFT512);
BASS_ChannelGetData(hStream, bb_data, 2048);
bbPlugin.ParentWindow = m_hWnd;
bbPlugin.DC = hDC;
bbPlugin.RC = m_glRC;
bbPlugin.LeftPeak = lPeak;
bbPlugin.RightPeak = rPeak;
bbPlugin.FFTdata = (DWORD)bb_fft;
bbPlugin.FFTsize = 256;
bbPlugin.WIMdata = (DWORD)bb_data;
bbPlugin.MediaLength = BASS_ChannelGetLength(hStream, 0);
bbPlugin.MediaPos = BASS_ChannelGetPosition(hStream, 0);
bbPlugin.Msg = BBP_RENDER;
bbProc(&bbPlugin);
The BBP.WIMdata is a memory pointer to the 4-bit real fft[0:255] array,
the size of the reserved memory holding the array being: 1024 (4-bit real x 256 =
1024),
yours is
2048search MSDN or Google for MM_WIM_DATA
...
Hi!
Ya, I changed my code to this so that it was just like BassBox, but I still have the same crash so that's why I assumed my structure was incorrect, but it must be something else. I have been stepping through the code in powerbasic to check the state of all the variables and it looks the same as mine. I will keep tracing through until I uncover my error :)
Thanks,
Greg
float bb_data[256];
BASS_ChannelGetData(hStream, bb_data, 1024);
Hey Guys,
I got it figured out. The struct needs to be compiled with 1 byte alignment to match up with powerbasic compiler. In case anyone needs to know you can do that as follows:
#pragma pack(push, 1)
typedef struct _BBPLUGIN
{
long Msg;
HWND ParentWindow;
HDC DC;
HGLRC RC;
WORD LeftPeak;
WORD RightPeak;
char Title[32];
char Author[64];
DWORD Version;
long RenderTo;
long BackARGB;
DWORD FFTdata;
WORD FFTsize;
long WinMsg;
long wParam;
long lParam;
DWORD WIMdata;
DWORD MediaLength;
DWORD MediaPos;
char Reserved[98];
}BBPLUGIN;
#pragma pack(pop)
Ok, Greg, thank you for the tip,
it would be useful for other C++ programmers ;)
...