Author Topic: TSampleDisplay3D Delphi component  (Read 30018 times)

3delite

  • Posts: 926
TSampleDisplay3D Delphi component
« on: 18 Mar '06 - 14:21 »
Yess! It's finally here! Now available for everyone! The 3D sample display for Delphi BASS applications!


From the docs:

TSampleDisplay3D is a Delphi component for use in Win32 (9x/ME/2K/XP) software. It's purpose is to provide the most powerful and efficient (yet easy to use), 3D sample functions like displaying the sample in 3D with configurable colors, native support for ID3v2 SESC, making a selection, zooming, quick-playing from click, configurable selection playback repeat count, edit and create Subsong seekpoints, etc. all on a powerfull Direct3D display.


Requirements:
=============
DirectX9 installed.

Clootie DX9 package (included)
http://clootie.narod.ru/

BASS 2.2 package (included)
http://www.un4seen.com/bass.html

ID3 and ID3v2 unit (included)
http://audioxl.com/


Copyright, Disclaimer, and all that other jazz
==============================================
The TSampleDisplay3D component is free for non-money making use... if you are not charging for the software, then you can use TSampleDisplay3D in it for free (a mention in the credits would be nice though!). If you wish to use TSampleDisplay3D in shareware or commercial products, then see the next section.


TSampleDisplay3D in shareware and commercial software?
==========================================
TSampleDisplay3D is available for use in your shareware and commercial software. The license types available are as follows:
SHAREWARE: 50Eur Allows the usage of TSampleDisplay3D in an unlimited number of your shareware products.
SINGLE COMMERCIAL: 500Eur Allows the usage of TSampleDisplay3D in a single commercial product.
If you're an individual selling your own software, then the SHAREWARE license is the one for you. If you're a commercial entity (or your software is published/sold by one), then a COMMERCIAL license is required.
One license covers one person or entity and is not transferable.
These licenses do not allow reselling of TSampleDisplay3D, ie. as part of another development library. If none of these licenses match your requirements, or if you have any questions about using TSampleDisplay3D in shareware/commercial software, then please get in touch (email: 3delite@3delite.hu).
Note: If you plan using TSampleDisplay3D in you programs (shareware or commercial), you'll also need a BASS license available separatelly from:
http://www.un4seen.com/bass.html

Docs: www.3delite.hu
Download: TSampleDisplay3D package
« Last Edit: 12 May '09 - 10:22 by 3delite »

Ian @ un4seen

  • Administrator
  • Posts: 21133
Re: TSampleDisplay3D Delphi component
« Reply #1 on: 19 Mar '06 - 18:00 »
Ian, could you make this a sticky topic?

Maybe, if it's a beta, looking for bug reports? :)

You could add it to the "BASS showcase" though, if you want.

3delite

  • Posts: 926
Re: TSampleDisplay3D Delphi component
« Reply #2 on: 19 Mar '06 - 19:57 »
Maybe, if it's a beta, looking for bug reports? :)

Definetly! ;D
I mean it's a professional sample display for BASS applications. :)
It's fast, beautiful (especially with 4xAntiAliasing) and very easy to use.
« Last Edit: 20 Mar '06 - 02:55 by 3delite »

Bert

  • Posts: 176
Re: TSampleDisplay3D Delphi component
« Reply #3 on: 22 Mar '06 - 14:20 »
I would like to see it working,
but i cant (and wont) install the complete libraries before.
The precompiled "Tutorial1.exe" gives me "Error: Creating D3D Device" on my notebook.
DX9 is installed.

 ???

3delite

  • Posts: 926
Re: TSampleDisplay3D Delphi component
« Reply #4 on: 22 Mar '06 - 18:15 »
The precompiled "Tutorial1.exe" gives me "Error: Creating D3D Device" on my notebook.

Does your notebook's gfx chipset support hardware vertexprocessing?
Default is to initialize the D3D device with flags:
Code: [Select]
D3DCREATE_HARDWARE_VERTEXPROCESSING OR D3DCREATE_MULTITHREADED

The zip is updated!
I now added a property D3DVertexProcessingMode and you can set it in the Tutorial too. See if it works!
For some mysterious reason here doesn't work the Software mode! :o It works in MP3SE, and the same code doesn't work here. :D (TSampleDisplay3D is the enhanced 3D sample display that can be found in MP3SE.)
Also the triangle count is limited to 50 000 (300 000 by default) now in the Tutorial project.
 
« Last Edit: 22 Mar '06 - 18:36 by 3delite »

Bert

  • Posts: 176
Re: TSampleDisplay3D Delphi component
« Reply #5 on: 22 Mar '06 - 19:51 »
With the software mode the picture disappears, no error, but no waveform is displayed.
I just can see the empty panel or canvas with "TSampleDisplay3D by 3delite" in the center.

3delite

  • Posts: 926
Re: TSampleDisplay3D Delphi component
« Reply #6 on: 22 Mar '06 - 23:18 »
Same here! I'll experiment with it.
I know it works with software vertex processing too, becouse MP3SE works fine, just don't know what's the problem yet! :)
If you don't get the "Error: Creating D3D Device" message that means the device has initialized properly, and that's a good news.

3delite

  • Posts: 926
Re: TSampleDisplay3D Delphi component
« Reply #7 on: 23 Mar '06 - 00:08 »
Mysterious!
It just won't render a frame in software mode!
But I have no idea why! :'(
Any luck with "mixed" mode?

3delite

  • Posts: 926
Re: TSampleDisplay3D Delphi component
« Reply #8 on: 23 Mar '06 - 16:59 »
With the software mode the picture disappears, no error, but no waveform is displayed.
I just can see the empty panel or canvas with "TSampleDisplay3D by 3delite" in the center.

An update is now available at the given link, with support for software vertex processing! ;)
Delphi didn't show the error yesterday but it did today... No comment... ::) How can it be?  ???
I managed to fix it in no time now when I am aware where the problem is.
I was drawing matrices that weren't initialised (if I'm right), but how come it was no problem in HW mode? ::)
Ah... forget it... now you can use it in software vertex processing mode or hardware vertex processing mode too! If I am right (it works here! :)).
« Last Edit: 23 Mar '06 - 18:09 by 3delite »

Bert

  • Posts: 176
Re: TSampleDisplay3D Delphi component
« Reply #9 on: 24 Mar '06 - 00:51 »
I'm sorry,
the tutorial1.exe behaves like before.
Only working in software-mode, not displaying anything.
If i hold down the mouse and "scrub" over the empty display, the samplepos-label is changing.

Good Luck! (not you, Ian,  ;D)

3delite

  • Posts: 926
Re: TSampleDisplay3D Delphi component
« Reply #10 on: 24 Mar '06 - 03:14 »
I'm sorry,
the tutorial1.exe behaves like before.
Only working in software-mode, not displaying anything.

Sorry again! I somehow forgot to update the Tutorial1.exe... :-[
Please try the latest, it is working here wonderfuly in software mode too.

Good Luck! (not you, Ian,  ;D)

:)
Well I am not having luck right now... I updated the optional picture to handle mouse clicks and now my TSampleDisplay3D object is disapearing somehow... :D
I open a stream, it works, it even draws one frame, but when it comes to calling the .Render; function in a Timer my SampleDisplay3D object is nil!??? ???
I am very angry right now... :D
Thanx for the wishes, but I don't need it!
« Last Edit: 24 Mar '06 - 14:02 by 3delite »

3delite

  • Posts: 926
Re: TSampleDisplay3D Delphi component
« Reply #11 on: 24 Mar '06 - 16:37 »
 
The .zip is updated with the 1.1 version!
The optional picture that can be specified to be shown when no sample gfx is rendered now supports mouse interaction like OnMove() and OnClick() etc.

I had an error that one of my properties's name was the same as the function's variable name, and that caused that my object became nil... :P Put that together!

Let me know if it works! 8)

3delite

  • Posts: 926
Re: TSampleDisplay3D Delphi component
« Reply #12 on: 27 Mar '06 - 12:49 »
 
Soon as I get 3 shareware registrations I can buy the source for ID3 units, so I can make a (BDS2006) Delphi compatible component too of it, if anyone's intrested (beside me)!!! :)
 
« Last Edit: 28 Mar '06 - 00:53 by 3delite »

3delite

  • Posts: 926
Re: TSampleDisplay3D Delphi component
« Reply #13 on: 29 Mar '06 - 15:39 »
I updated it a bit. Here is a snap for you to see it in action:
 

 
The parameters are the default. Black background, green-blue sample, red-yellow FFT. 4xFSAA is turned on. You can see the sample on the major part of the display, and the FFT at the bottom.
On the picture you can see three vertical lines. The first (it's a gradient, not a line actually) shows current playing position. The second and the third are Subsong seekpoints, the mouse is above the second (white one), that's why it's white.

You can use TSampleDisplay in many ways, becouse it's compact and very easy to use. Actually for a basic usage, you need only four (!) lines of code:

Code: [Select]
    //* Open a file in slot 0
    //* We use the BASS_STREAM_PRESCAN BASS flag to have a precise playback positon display
    SampleDisplay3D1.StreamOpen(FileName, 0, BASS_STREAM_PRESCAN);
    //* Make 0 the active slot
    SampleDisplay3D1.ActiveIndex := 0;
    //* Init slot 0 for rendering
    SampleDisplay3D1.InitD3D(0);

...and somewhere you need to render the frames (eg. in a Timer):

Code: [Select]
    //* Draw the frame
    SampleDisplay3D1.Render;

You can use it as a small 100x50 preview display, to show visually where the playback is actually, in a serious audio editor as the sample display, you can have more the one display on one form, etc...
You can turn many of the feature off, and use it as a simple display too (without clicks, selection, FFT etc.).
But the best features is accesing the actual selection properties. Using TSampleDisplay you can offer the user the selection possibility, and get the selected positions in two lines! Or a single position from a Subsong seekpoint. Ideal for any visual interaction between the user and the audio stream. The user has the abbility to take a look at any part of the sample as she/he can zoom it and scroll it.

TSampleDisplay3D works with normal and 32bit channels too.

TSampleDisplay3D has one problem tough, it cannot be used for sample precise editing sadly, because it uses sample cache to display the audio, and the resolution of the cache is at most length/256 (average of a BASS_DATA_FFT512 call makes one sample cache value - that's why it is so small and can be stored with great efficiency in ID3v2 tag, and the SESC frame is even compressed to reduce the size even more). But for an every day application you don't need sample precise resolution tough. For a brutally dense resolution you would need a brutally good 3D card which can display as many triangles as you want (TSampleDisplay3D can be made very easily sample precise, but that requres a 3D card supporting that many - eg. as the audio file - triangles in one go), but that's not an every day requirement, and it is not implemented. My GF4Ti4200 supports around 450 000 triangles in one go, and that's more than enough for an ordinary use.

And to tease you even more the same way as BASS does, TSampleDisplay3D can display music modules too, which is quite a feature. :)
« Last Edit: 29 Mar '06 - 15:52 by 3delite »

3delite

  • Posts: 926
Re: TSampleDisplay3D Delphi component
« Reply #14 on: 1 Apr '06 - 02:26 »
 
TSampleDisplay3D V1.2 is ready! 8)

Now you can use it with Delphi 2005 or 2006 too, just remove the compiler directive:
 
Code: [Select]
{$DEFINE DELPHI7}

from the 34th line of SampleDisplay3D.pas!
You won't have ID3v1 & ID3v2 Tag support nor can use the SESC and the MP3 Stream Editor Subsongs and Helium Subtracks feature yet, but everything else is fully functional! ;)

New function added:
 
Code: [Select]
    function StreamSaveCUE(Index: Cardinal; FileName: String): Boolean;

which generates a .cue sheet, from the actual Subsong data for the slot specified by Index!
Just a little feature! ;)
 
« Last Edit: 1 Apr '06 - 02:28 by 3delite »

se

  • Posts: 22
Re: TSampleDisplay3D Delphi component
« Reply #15 on: 3 Apr '06 - 23:21 »
Nice result indeed!
I used some personal waveform components, not in directX, for a main task: assigning fade in and fade out, and creating crossfade between 2 songs.
For each event I had a set of lines I was addding inside the canvas of the waveform.

Do you tihnk we can simply add simple lines to your component? is there any canvas or "gotoline" function which can be used?

best

3delite

  • Posts: 926
Re: TSampleDisplay3D Delphi component
« Reply #16 on: 4 Apr '06 - 01:46 »
 
Theoretically you can use the:

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

.BeforeD3DRender: is called when the D3D surface is cleared and ready for drawing.
   You can draw on the surface with
   .Streams.Index[Index].g_pd3dDevice
   that will be behind the sample graphics.

and draw anything "Direct3D" you want! :)
For example (the middle line is rendered like this):

Code: [Select]
    with .Streams.Index[Index].g_pd3dDevice do begin
        //* Create a vertex buffer and set the projection matrix
        SetupMatrices(Index);
        //* Setup propperties of the draw
        SetRenderState(D3DRS_ALPHABLENDENABLE, 1);
        SetRenderState(D3DRS_DESTBLEND, D3DBLEND_SRCCOLOR);
        SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
        //* Vertex buffer to use
        SetStreamSource(0, Streams.Index[Index].VertexBuffer_Coords, 0, SizeOf(TCustomVertex));
        //* Draw our vertexes as lines
        DrawPrimitive(D3DPT_LINELIST, 6, 1);
    end;

See the SampleDisplay3D.pas on how it is used!
Other solution that came across my mind was drawing on the Panel.Canvas after D3D rendering. This has not been implemented, becouse as the same, never tested, but could be, easily if it's a good way, or needed.

Do you tihnk we can simply add simple lines to your component? is there any canvas or "gotoline" function which can be used?

You could also see if you can use the Subsong feature as a line "setter" (it's not so precise as the selection, but you can add Subsongs as in the Tutorial, and access the positions in:

Code: [Select]
    SampleDisplay3D1.Streams.Index[SampleDisplay3D1.ActiveIndex].Subsongs.Seeks[n];

(milliseconds) And use:

Code: [Select]
    SampleDisplay3D1.Streams.Index[SampleDisplay3D1.ActiveIndex].Subsongs.Clear;

to clear the lines! :)
« Last Edit: 4 Apr '06 - 01:56 by 3delite »

3delite

  • Posts: 926
Re: TSampleDisplay3D Delphi component
« Reply #17 on: 28 Apr '06 - 15:19 »
 
There is now an ActiveX component made from TSampleDisplay3D (SampleDisplay3DX), that I made following the article: Creating ActiveX controls with Delphi
Please check if you have any luck with it! I don't have VB or any experience with ActiveX so far...

It can be found in the zip file (first post) as \SampleDisplay3DX\SampleDisplay3DX.ocx
 

Bert

  • Posts: 176
Re: TSampleDisplay3D Delphi component
« Reply #18 on: 28 Apr '06 - 18:58 »
Does the loading of Files longer than 3 minutes works at your machines?
At mine not...  :(

3delite

  • Posts: 926
Re: TSampleDisplay3D Delphi component
« Reply #19 on: 29 Apr '06 - 01:15 »
 
Just tried a 213MB MP3 file and it looks good here.
Open SampleDisplay3D.pas and try debugging where the problem is, on which line?
 

3delite

  • Posts: 926
Re: TSampleDisplay3D Delphi component
« Reply #20 on: 12 May '09 - 10:24 »
New unicode enabled version is available for Delphi 2009.

See the first post on how to download.

3delite

kloosterj

  • Posts: 7
Re: TSampleDisplay3D Delphi component
« Reply #21 on: 20 May '09 - 08:23 »
Is it possible to use TSampleDisplay3D with BASS_ASIO? How would I do that?
Thanks in advance!

Jan

3delite

  • Posts: 926
Re: TSampleDisplay3D Delphi component
« Reply #22 on: 20 May '09 - 15:32 »
It is possible to use TSampleDisplay3D with BASS ASIO but BASS is still needed (bass.dll).

You have to implement four events: OnPlay, OnPause, OnStop and OnNeedPlaybackPosition.
Implement the according functions with BASS ASIO and set Handled to True.

It's in experimantal stage, please tell me how you get on with it and I help you!

Download the update in the first post.

3delite
« Last Edit: 20 May '09 - 15:48 by 3delite »

3delite

  • Posts: 926
Re: TSampleDisplay3D Delphi component
« Reply #23 on: 2 Feb '11 - 14:53 »
New version 1.5.3 of the component is up on the download page.

It contains many bugfixes and enhancements:
- Default is now threaded sample cahing
- No need to call InitD3D() (is now called internally)
- Fixed loading files with ID3v2 tags
- Fixed writing SESC