- In Delphi menu: File/New/Package Delphi
- Unpack the ClootieDX9 folder, all the files inside are needed in the search path.
- Put bass.dll and d3dx9ab.dll in Delphi's \bin folder.
- In project manager (in the upper-right corner by default), right-click on "Package1.dproj" and select "Add..."
- Unit file name: click "Browse" and select "GraphDisplay3D.pas" and click "Ok"
- In project manager (in the upper-right corner by default), right-click on "Package1.dproj" and select "Install..."
- Save the package.
If everything went smooth, you can access the TGraphDisplay3D component on 3delite's tab.
The audio sample display tutorial supports audio file formats: MP3, MP2, MP1, OGG, WAV and music modules. Yes, it supports music modules too! :, MO3, IT, XM, S3M, MTM, MOD, UMX
If you want your application to handle many more audio file formats, check the great BASS add-ons on the BASS page: BASS Add-ons
- ActiveIndex: Specifies which graph is displayed on the 3D panel.
- AllowAmplitudeChangeWithKey: Turn on/off possibility to change the display sample amplitude with + and - keys.
- AllowQuickPlay: Turn on/off middle-mouse button quick play and space-bar play/pause possibility.
- AllowSelect: Turn on/off selection possibility.
- AllowWhhelZoom: Turn on/off mouse-wheel zoom in/out possibility.
- Animate: Turn on/off animated startup rotation, zoom and show all possibility.
- Antialiasing: Turn on/off Direct3D antialiasing. Result slower display but better image quality.
- AutoReInit: If set to True Direct3D is re-initialized every time when the panel is resized. Very slow, but gives always precise 1:1 resolution.
- D3DVertexProcessingMode: Select vertex processing mode. Defaults to hardware (fastest). Most up-to-date 3D gfx cards support hardware vertex processing.
- FollowCursor: When zoomed in display will scroll to keep the cursor in the middle of the display.
- MaximumVertexCount: Max. triangle/line count for the sample's object. Default is 500000. You may need to lower this to 100000 or even 50000 on some old graphic cards. The bigger the resolution the slower the rendering but the sample graphics is more detailed when zoomed. Modern graphics cards can display about 8 million triangles in one go.
gd3dAutomaticMaximum: On Direct3D initialization query the graphics card for maximum vertex count and use that value for MaximumVertexCount. If set MaximumVertexCount value is ignored. Not recommended becouse it may result a very slow rendering.
gd3dCustom: Specify manually MaximumVertexCount (see above).
- Panel3DPicture: Specify a picture to display when 3D display is not active.
- SampleInSeparateThread: Specifies wether to run the sampling (OnNeedSamplesInThread) in separate thread. False by default. Note that when not set use the OnNeedSamples event.
gdsmFlush: Default. After the 3D object has been created clear the Samples array. Recommended, results lower memory usage.
gdsmKeep: Do not clear the Samples array after the 3D object has been created. Usefull if you need the sample data afterwards.
- ScrollBarHeight: Height of the scroll bar for scrolling the display. Set to 0 if you don't need the scroll bar.
- ShowCursor: For audio sample display, show the current playback position cursor.
- ShowMarkers: Turn on/off display of markers.
- ShowSelection: Turn on/off display of selection. If you don't want selection possibility set it to False.
- SolidCursor: When True audio current playback position cursor is a solid white line, else a gradient rectangle.
- SuppressErrors: Do not raise exceptions.
- AfterD3DRender: is called when the sample and all the graphics had been drawn on the surface. You can draw on the surface that will be on top of the sample graphics.
You can draw on the surface with .Items.Item[x].g_pd3dDevice
- BeforeD3DRender: is called when the D3D surface is cleared and ready for drawing.
You can draw on the surface with .Items.Item[x].g_pd3dDevice that will be behind the sample graphics.
- OnD3DDestroy: is called before freeing the Direct3D object.
- OnMarkerChange: is called when a marker is hovered or moved or deleted.
- OnNeedPlaybackPosition: is called when ShowCursor is True and the cursor needs a playback position. If you want playback position display you need to implement this event.
- OnNeedPlayStatus: is called when AllowQuickPlay is True, and middle mouse button is clicked or space bar is pressed. Depending on the result of this event OnPause or OnPlay ievent is called.
- OnNeedAxisXText: If you want to customize the X axis texts you have to implement this event. Is usefull for example for audio sample display to display time formatted values.
- OnNeedAxisYText: If you want to customize the Y axis texts you have to implement this event.
- OnNeedSamples: When calling Initialize() or manually CreateVertexesFromSamples this event is called to fill up the graph values. If you manually fill up the values do not use this event.
- OnNeedSamplesInThread: Same as above, if SampleInSeparateThread is set to True this event is called. Note that is event will run inside a thread so things that apply to threads apply here too. For example VCL access is not available.
- OnPause: is called when the user presses the space bar and OnNeedPlayStatus reports psPlaying or psPaused.
- OnPlay: is called when the user presses the space bar or middle mouse clicks on the display and OnNeedPlayStatus reports psStoped.
- OnSampleThreadFinished: is called when the sampling thread has finished thus the display is ready. Only called when CacheSampleInSeparateThread is True.
- OnSelection: is called when the user changes the selection on the sample display.
Functions and procedures
- Initialize(Index: Cardinal): Boolean;
Initialize and display stream in slot "Index".
Result is True if successfull.
Draw the frame. The slot specified with .ActiveIndex is drawn.
This should be called about every 30th msec (or more often) if you want smooth 3D graphics. Another good idea is to call it in OnIdle().
Zoom to the selection. The slot specified with .ActiveIndex is zoomed.
Is animated if Animate is True.
Display the whole sample. The slot specified with .ActiveIndex is showed all.
Is animated if Animate is True.
My application using TGraphDisplay3D uses too much CPU power and/or is very slow!
- Reduce the MaximumVertexCount (in object inspector or by code) to 5000 (minimally recommended - else should be around 500 000)
- Call Render() less - Setting the timer to 100ms should be still enough for smooth graphics
- Turn off antialiasing