Quick Sign In:  

 Djcel
My philosophy: Work is the key to success and communication is the first step of life.

About me: click here [level Professional edition user]

My computers: click here [level Professional edition user]

Sat 25 Mar 23 @ 10:45 pm

Direct3D11 Pipeline Stages (in orange, the additional stages versus Direct3D10)

(c) Microsoft

IA : Input-Assembler stage
VS : Vertex Shader stage
HS : Hull Shader stage
DS : Domain Shader stage
GS : Geometry Shader stage
SO : Stream Output stage
RS : Rasterizer Stage (including Fill/culling mode, scissor Rects and viewports, etc)
PS : Pixel Shader stage
OM : Output-Merger stage (including blending setup, depth, stencil, render target views, etc)
CS : Computer Shader stage
--------------------------------------------------------------------------------------------
#include <d3d11.h>
#pragma comment (lib, "d3d11.lib")
-------- Interfaces --------
ID3D11Device
ID3D11DeviceContext
ID3D11ShaderResourceView
ID3D11RenderTargetView
ID3D11DepthStencilView
ID3D11UnorderedAccessView
ID3D11Resource
ID3D11Buffer [vertex buffer, index buffer or shader-constant buffer]
ID3D11Texture1D
ID3D11Texture2D
ID3D11Texture3D
ID3D11VertexShader
ID3D11GeometryShader
ID3D11PixelShader
ID3D11InputLayout
ID3D11DepthStencilState
ID3D11BlendState
ID3D11RasterizerState
ID3D11SamplerState
ID3D11HullShader
ID3D11DomainShader
ID3D11ComputeShader
ID3D11VideoContext
ID3D11VideoDecoder
ID3D11VideoDecoderOutputView
ID3D11VideoDevice
ID3D11VideoProcessor
ID3D11VideoProcessorEnumerator
ID3D11VideoProcessorInputView
ID3D11VideoProcessorOutputView
ID3D11Asynchronous
ID3D11Query
ID3D11Predicate
ID3D11Counter
ID3D11ClassLinkage
ID3D11ClassInstance
ID3DBlob
-------- Structures / Enumerations --------
D3D11_FEATURE
D3D11_FEATURE_LEVEL
D3D11_DEVICE_CONTEXT_TYPE
D3D11_BUFFER_DESC
D3D11_FORMAT_SUPPORT
D3D11_SUBRESOURCE_DATA
D3D11_BIND_FLAG
D3D11_SHADER_RESOURCE_VIEW_DESC
D3D11_RENDER_TARGET_VIEW_DESC
D3D11_RENDER_TARGET_BLEND_DESC
D3D11_DEPTH_STENCIL_VIEW_DESC
D3D11_DEPTH_STENCIL_DESC
D3D11_RASTERIZER_DESC
D3D11_RESOURCE_DIMENSION
D3D11_TEXTURE1D_DESC
D3D11_TEXTURE2D_DESC
D3D11_TEXTURE3D_DESC
D3D11_VIEWPORT
D3D11_FILTER
D3D11_BLEND_DESC
D3D11_BOX
D3D11_RECT
D3D11_COUNTER_INFO
D3D11_COUNTER_DESC
D3D11_COUNTER_TYPE
--------------------------------------------------------------------------------------------
#include <d3d11_1.h>
-------- Interfaces --------
ID3D11Device1
ID3D11DeviceContext1
ID3DDeviceContextState
ID3D11RasterizerState1
ID3D11BlendState1
ID3D11VideoDevice1
ID3D11VideoContext1
ID3D11VideoProcessorEnumerator1
--------------------------------------------------------------------------------------------
#include <d3d11_2.h>
-------- Interfaces --------
ID3D11Device2
ID3D11DeviceContext2
--------------------------------------------------------------------------------------------
#include <d3d11_3.h>
-------- Interfaces --------
ID3D11Device3
ID3D11DeviceContext3
ID3D11DeviceContext4
ID3D11ShaderResourceView1
ID3D11RenderTargetView1
ID3D11RasterizerState2
ID3D11Texture2D1
ID3D11Texture3D1
--------------------------------------------------------------------------------------------
#include <d3d11_4.h>
-------- Interfaces --------
ID3D11Device4
ID3D11Device5
ID3D11VideoDevice2
ID3D11VideoContext3
ID3D11Multithread
--------------------------------------------------------------------------------------------
#include <dxgi.h>
-------- Interfaces --------
IDXGIFactory
IDXGIAdapter
IDXGIDevice
IDXGIOutput
IDXGIResource
IDXGISurface
IDXGISwapChain
-------- Structures / Enumerations --------
DXGI_ADAPTER_DESC
DXGI_SWAP_CHAIN_DESC
DXGI_OUTPUT_DESC
DXGI_SURFACE_DESC
DXGI_SHARED_RESOURCE
DXGI_FORMAT
DXGI_SAMPLE_DESC
--------------------------------------------------------------------------------------------
Additional libraries:
--------
1) The DirectX Tool Kit (aka DirectXTK) is a collection of helper classes for writing DirectX 11.x code in C++
https://walbourn.github.io/directxtk/
=> Additional package to download with NuGet in Visual Studio 2022: "directxtk_desktop_win10"

2) DirectXTex texture processing library
https://walbourn.github.io/directxtex/
=> Additional package to download with NuGet in Visual Studio 2022: "directxtex_desktop_win10"



Sun 31 May 20 @ 3:23 pm

Slide3D8.h wrote :
#ifndef SLIDE3D8_H
#define SLIDE3D8_H

#pragma warning (disable : 4068 ) /* disable unknown pragma warnings */
#pragma warning (disable : 4163 ) /* disable '_InterlockedExchangeAdd8' : not available as an intrinsic function*/


#include "VdjVideo8.h"

#if (defined(VDJ_WIN))
#if (defined(_M_X64) || defined(__amd64__))
#define VDJ_WIN64
#define VDJ_D3D11
#include <D3D11_4.h>
#pragma comment (lib, "D3D11.lib")
typedef DWORD D3DCOLOR;
#define D3DCOLOR_RGBA(r,g,b,a) ((D3DCOLOR)((((a)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff)))
#else
#define VDJ_D3D9
#include <d3d9.h>
#pragma comment(lib, "d3d9.lib")
#endif
#ifndef SAFE_RELEASE
#define SAFE_RELEASE(p) { if (p) { (p)->Release(); (p)=NULL; } }
#endif
#elif (defined(VDJ_MAC))
#define VDJ_OPENGL
#include <OpenGL/OpenGL.h>
#endif

//-------------------------------------------------------------------------------------------
class CSlide3D8 : public IVdjPluginVideoTransition8
{
public:
HRESULT VDJ_API OnLoad();
HRESULT VDJ_API OnGetPluginInfo(TVdjPluginInfo8 *info);
ULONG VDJ_API Release();
HRESULT VDJ_API OnDeviceInit();
HRESULT VDJ_API OnDeviceClose();
HRESULT VDJ_API OnDraw(float crossfader);

private:
HRESULT Compose(float crossfader);
HRESULT RenderSurface(int deck, bool bDefault);
void VideoScaling(int deck);

float m_Width;
float m_Height;
TVertex8 m_DefaultVertices[2][4];
TVertex8 m_Vertices[2][4];

#if (defined(VDJ_D3D9))
static const EVdjVideoEngine VDJVIDEOENGINE = VdjVideoEngineDirectX9;
typedef IDirect3DDevice9 VDJVIDEODEVICE;
typedef IDirect3DTexture9 VDJVIDEOTEXTURE;
VDJVIDEODEVICE *pVdjVideoDevice;
#elif (defined(VDJ_D3D11))
static const EVdjVideoEngine VDJVIDEOENGINE = VdjVideoEngineDirectX11;
typedef ID3D11Device VDJVIDEODEVICE;
typedef ID3D11ShaderResourceView VDJVIDEOTEXTURE;
VDJVIDEODEVICE *pVdjVideoDevice;
#elif (defined(VDJ_OPENGL))
static const EVdjVideoEngine VDJVIDEOENGINE = VdjVideoEngineOpenGL;
typedef GLuint VDJVIDEOTEXTURE;
#endif

}
#endif


Slide3D8.cpp wrote :
#include "Slide3D8.h"


//---------------------------------------------------------------------------------------------
HRESULT VDJ_API CSlide3D8::OnGetPluginInfo(TVdjPluginInfo8 *infos)
{
infos->Author = "DJ CEL";
infos->PluginName = "Slide3D";
infos->Description = " A slide effect in 3D";
infos->Flags = VDJFLAG_VIDEOTRANSITION_CONTINOUS | VDJFLAG_VIDEO_MASTERONLY;

#if (defined(VDJ_WIN64) || defined(VDJ_MAC))
infos->Version = "3.0 (64-bit)";
#else
infos->Version = "3.0 (32-bit)";
#endif

#if (defined(VDJ_WIN))
infos->Bitmap = LoadBitmap(hInstance,MAKEINTRESOURCE(100));
#elif (defined(VDJ_MAC))
infos->Bitmap = "bitmap.bmp";
#endif

return S_OK;
}
//---------------------------------------------------------------------------------------------
HRESULT VDJ_API CSlide3D8::OnLoad()
{
m_Width = 0.0f;
m_Height = 0.0f;
for(int deck=1;deck<=2;deck++)
{
memset(m_DefaultVertices[deck-1],0,4*sizeof(TVertex8));
memset(m_Vertices[deck-1],0,4*sizeof(TVertex8));
}

return S_OK;
}
//---------------------------------------------------------------------------------------------
ULONG VDJ_API CSlide3D8::Release()
{
delete this;
return 0;
}
//---------------------------------------------------------------------------------------------
HRESULT VDJ_API CSlide3D8::OnDeviceInit()
{
#if (defined(VDJ_D3D9) || defined(VDJ_D3D11))
HRESULT hr = S_FALSE;
void *device = NULL;
hr = GetDevice(VDJVIDEOENGINE, &device);
if(hr!=S_OK || device==NULL) return S_FALSE;
pVdjVideoDevice = reinterpret_cast<VDJVIDEODEVICE*>(device);
#endif

m_Width = (float) width;
m_Height = (float) height;

return S_OK;
}
//---------------------------------------------------------------------------------------------
HRESULT VDJ_API CSlide3D8::OnDeviceClose()
{
return S_OK;
}
//---------------------------------------------------------------------------------------------
HRESULT VDJ_API CSlide3D8::OnDraw(float crossfader)
{
HRESULT hr = S_FALSE;

m_Width = (float) width;
m_Height = (float) height;

memcpy(m_Vertices[0],GetVertices(1),4*sizeof(TVertex8));
memcpy(m_Vertices[1],GetVertices(2),4*sizeof(TVertex8));

hr = Compose(crossfader);

return hr;
}
//---------------------------------------------------------------------------------------------
HRESULT CSlide3D8::Compose(float crossfader)
{
HRESULT hr;

float compressor_rate = 0.0f;
int alpha = 0;

#if (defined(VDJ_D3D9))
// pVdjVideoDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
#endif

if (crossfader<=0.5f)
{
compressor_rate = crossfader/0.5f;
alpha = (int) (compressor_rate * 255.0f);

// Video 1
m_Vertices[0][0].position.x = 0.0f * m_Width;
m_Vertices[0][0].position.y = (0.0f + compressor_rate * 0.25f ) * m_Height; // de 0 à 0.25;

m_Vertices[0][1].position.x = (1.0f - compressor_rate * 0.5f) * m_Width; // de 1 à 0.5
m_Vertices[0][1].position.y = (0.0f + compressor_rate * 0.25f) * m_Height; // de 0 à 0.25

m_Vertices[0][2].position.x = (1.0f - compressor_rate * 0.5f) * m_Width; // de 1 à 0.5
m_Vertices[0][2].position.y = (1.0f - compressor_rate * 0.25f) * m_Height; // de 1 à 0.75;

m_Vertices[0][3].position.x = 0.0f * m_Width ;
m_Vertices[0][3].position.y = (1.0f - compressor_rate * 0.25f) * m_Height; // de 1 à 0.75;

//Video 2
m_Vertices[1][0].position.x = 0.5f * m_Width;
m_Vertices[1][0].position.y = 0.25f * m_Height;
m_Vertices[1][0].color = D3DCOLOR_RGBA(255,255,255,alpha);

m_Vertices[1][1].position.x = 1.0f * m_Width;
m_Vertices[1][1].position.y = 0.25f * m_Height;
m_Vertices[1][1].color = D3DCOLOR_RGBA(255,255,255,alpha);

m_Vertices[1][2].position.x = 1.0f * m_Width;
m_Vertices[1][2].position.y = 0.75f * m_Height;
m_Vertices[1][2].color = D3DCOLOR_RGBA(255,255,255,alpha);

m_Vertices[1][3].position.x = 0.5f * m_Width;
m_Vertices[1][3].position.y = 0.75f * m_Height;
m_Vertices[1][3].color = D3DCOLOR_RGBA(255,255,255,alpha);

hr = RenderSurface(2,false);
hr = RenderSurface(1,false);

}
else
{
compressor_rate=(1.0f-crossfader)/0.5f;
alpha = (int) (compressor_rate * 255.0f);

//Video 1
m_Vertices[0][0].position.x=0.0f * m_Width;
m_Vertices[0][0].position.y=0.25f * m_Height;
m_Vertices[0][0].color = D3DCOLOR_RGBA(255,255,255,alpha);

m_Vertices[0][1].position.x=0.5f * m_Width;
m_Vertices[0][1].position.y=0.25f * m_Height;
m_Vertices[0][1].color = D3DCOLOR_RGBA(255,255,255,alpha);

m_Vertices[0][2].position.x=0.5f * m_Width;
m_Vertices[0][2].position.y=0.75f * m_Height;
m_Vertices[0][2].color = D3DCOLOR_RGBA(255,255,255,alpha);

m_Vertices[0][3].position.x=0.0f * m_Width;
m_Vertices[0][3].position.y=0.75f * m_Height;
m_Vertices[0][3].color = D3DCOLOR_RGBA(255,255,255,alpha);

// Video 2
m_Vertices[1][0].position.x=(0.0f + compressor_rate * 0.5f) * m_Width; // de 0.5 à 0.0
m_Vertices[1][0].position.y=(0.0f + compressor_rate * 0.25f) * m_Height; // de 0.25 à 0.0

m_Vertices[1][1].position.x=1.0f * m_Width;
m_Vertices[1][1].position.y=(0.0f + compressor_rate * 0.25f) * m_Height; // de 0.25 à 0.0

m_Vertices[1][2].position.x=1.f * m_Width;
m_Vertices[1][2].position.y=(1.f - compressor_rate * 0.25f) * m_Height; // de 0.75 à 1.0

m_Vertices[1][3].position.x=(0.f + compressor_rate * 0.5f) * m_Width; // de 0.5 à 0.0
m_Vertices[1][3].position.y=(1.f - compressor_rate * 0.25f) * m_Height; // de 0.75 à 1.0

hr = RenderSurface(1,false);
hr = RenderSurface(2,false);
}

return S_OK;
}
//---------------------------------------------------------------------------------------------
HRESULT CSlide3D8::RenderSurface(int deck, bool bDefault)
{
HRESULT hr = S_OK;

VideoScaling(deck);

if (bDefault==true)
{
hr = DrawDeck(deck, NULL); // (pass NULL to DrawDeck() to use the default vertices)
}
else
{
hr = DrawDeck(deck, m_Vertices[deck-1]);
}

return hr;
}
//---------------------------------------------------------------------------------------------
void CSlide3D8::VideoScaling(int deck)
{
float WidthOriginalVideo, HeightOriginalVideo;
float WidthVideo, HeightVideo;
float NewWidthVideo, NewHeightVideo;
float RatioOriginalVideo;
bool b_CropVideoW,b_CropVideoH;
float dx,dy;

memcpy(m_DefaultVertices[deck-1],GetVertices(deck),4*sizeof(TVertex8));

WidthOriginalVideo = m_DefaultVertices[deck-1][1].position.x - m_DefaultVertices[deck-1][0].position.x;
HeightOriginalVideo = m_DefaultVertices[deck-1][3].position.y - m_DefaultVertices[deck-1][0].position.y;

b_CropVideoW = (WidthOriginalVideo != m_Width);
b_CropVideoH = (HeightOriginalVideo != m_Height);

RatioOriginalVideo = HeightOriginalVideo / WidthOriginalVideo;

WidthVideo = m_Vertices[deck-1][1].position.x - m_Vertices[deck-1][0].position.x;
HeightVideo = m_Vertices[deck-1][3].position.y - m_Vertices[deck-1][0].position.y;

if (b_CropVideoW)
{
NewWidthVideo = HeightVideo / RatioOriginalVideo;
dx = (WidthVideo - NewWidthVideo) * 0.5f;

m_Vertices[deck-1][0].position.x += dx;
m_Vertices[deck-1][1].position.x -= dx;
m_Vertices[deck-1][2].position.x -= dx;
m_Vertices[deck-1][3].position.x += dx;
}
else if (b_CropVideoH)
{
NewHeightVideo = WidthVideo * RatioOriginalVideo;
dy = (HeightVideo - NewHeightVideo) * 0.5f;

m_Vertices[deck-1][0].position.y += dy;
m_Vertices[deck-1][1].position.y += dy;
m_Vertices[deck-1][2].position.y -= dy;
m_Vertices[deck-1][3].position.y -= dy;
}
}





Sat 17 Nov 07 @ 1:44 pm

Standard compression is "Zip 2.0"

If you try to use a higher compression "Zip 2.1", you have to know the following thing, clearly explained by Winzip:




1) VirtualDJ only reads Zip 2.0

2) MP3+G Toolz .NET uses Zip 2.1

3) To know the compression format with Winzip:
...a) Open the Zip file with Winzip (Classic interface)
...b) "File" -> "Properties"
...c) Click on the button "Details"
...d) Read the version here after "unzip software version needed to extract"

4) You can convert the format by unzipping and reziping the file with the normal compression (Zip 2.0)

5) If you have a lot of Zip to convert and want to convert all your zip files in once, you can use a software like Songverter

KJMikey1 wrote :

MP3+G Toolz uses the same alogrhythm as Winzip 9, all you need to do is go into options, zip compression in Toolz and set compression to normal (5=default compression). By default, it is set at 9-maximun compression.

As is the case with KJ, VirtualDJ will not play any zip files that contain comments in them. This is from my experience from using KJ for last couple years and from working with demo of VJ. Make sure you are using version 4.0.1.5 of Toolz. Older versions will insert comment "Created by MP3+G Toolz" in the zip file.




Sun 10 Dec 06 @ 12:21 am

The core audio APIs are:

  • Multimedia Device (MMDevice) API
    Clients use this API to enumerate the audio endpoint devices in the system.
    => "For enumerating and managing audio endpoints"
  • Windows Audio Session API (WASAPI)
    Clients use this API to create and manage audio streams to and from audio endpoint devices.
    => "Very low level API for rendering audio, render/capture audio streams, adjust volume etc. This API also provides low latency for audio professionals"
  • DeviceTopology API
    Clients use this API to directly access the topological features (for example, volume controls and multiplexers) that lie along the data paths inside hardware devices in audio adapters.
    => "For discovering the internals of an audio card's topology"
  • EndpointVolume API
    Clients use this API to directly access the volume controls on audio endpoint devices. This API is primarily used by applications that manage exclusive-mode audio streams.




The audio core APIs are implemented in the Mmdevapi.dll and Audioses.dll system components, both of which run in user mode.

Here is a video to explain the new system:
video

©2006 Microsoft Corporation. All rights reserved.


Fri 01 Sep 06 @ 2:56 pm

The video engine of VirtualDJ is based on 3 different engines:
- For Windows 32-bit, it uses Direct3D 9
- For Windows 64-bit, it uses Direct3D 11
- For Mac OS, it uses OpenGL

This topic is dedicated to Direct3D only.

1) Direct3D device

First we advise you to define the following lines in your CMyPlugin class (for easier compatibility):

#if (defined(VDJ_WIN))
#if (defined(_M_X64) || defined(__amd64__))
#define VDJ_D3D11
#include <D3D11_4.h>
#pragma comment (lib, "D3D11.lib")
#else
#define VDJ_D3D9
#include <d3dx9.h>
#pragma comment(lib, "d3dx9.lib")
#endif
#ifndef SAFE_RELEASE
#define SAFE_RELEASE(x) { if (x!=NULL) { x->Release(); x=NULL; } }
#endif
#elif (defined(VDJ_MAC))
#define VDJ_OPENGL
#include <OpenGL/OpenGL.h> // you have to import OpenGL.framework in the XCode project
#endif



class CMyPlugin : public IVdjPluginVideoXXXXXX
{
public:
//…………...

private:

#if (defined(VDJ_D3D9))
static const EVdjVideoEngine VDJVIDEOENGINE = VdjVideoEngineDirectX9;
typedef IDirect3DDevice9 VDJVIDEODEVICE;
typedef IDirect3DTexture9 VDJVIDEOTEXTURE;
VDJVIDEODEVICE *pVDJDevice;
VDJVIDEOTEXTURE *pVDJTexture;
#elif (defined(VDJ_D3D11))
static const EVdjVideoEngine VDJVIDEOENGINE = VdjVideoEngineDirectX11;
typedef ID3D11Device VDJVIDEODEVICE;
typedef ID3D11ShaderResourceView VDJVIDEOTEXTURE;
VDJVIDEODEVICE *pVDJDevice;
VDJVIDEOTEXTURE *pVDJTexture;
ID3D11DeviceContext* pDeviceContext;
// ID3D11RenderTargetView* pRenderTargetView;
// ID3D11DepthStencilView* pDepthStencilView;
// ID3D11Resource* texResource ;
// ID3D11Texture2D* pTexture;
#elif (defined(VDJ_OPENGL))
static const EVdjVideoEngine VDJVIDEOENGINE = VdjVideoEngineOpenGL;
#endif
};


As VDJVIDEODEVICE is defined inside of VirtualDJ, you have to use the following function from the VirtualDJ video plugins SDK to get a pointer to it:
HRESULT VDJ_API CMyPlugin::OnDeviceInit()
{
#if (defined(VDJ_D3D9) || defined(VDJ_D3D11))
HRESULT hr = S_FALSE;
void *device = NULL;

hr = GetDevice(VDJVIDEOENGINE, &device);
if(hr!=S_OK || device==NULL) return S_FALSE;
pVDJDevice = reinterpret_cast<VDJVIDEODEVICE*>(device);
#endif

return S_OK;
}

Each time you want to use a Direct3D functions "xxxx", you have to use "pVDJDevice->xxxxxx"
You don't need to delete/release the pVDJDevice pointer.

2) Vertex

A vertex is a dot in the space defined by a struct TVertex
(NB: one vertex, two vertices)
3D models in Direct3D are based on triangles:
To define a triangle, you need 3 Vertices: vertices[0], vertices[1], vertices[2]
To define a square so 4 Vertices: vertices[0], vertices[1], vertices[2], vertices[3], you need 2 triangles :
{vertices[0], vertices[1], vertices[2]} and {vertices[1], vertices[3], vertices[2]}

struct TVertex
{
struct {float x,y,z;} position; // The 3D position (coordinates) for the vertex
DWORD color; // The vertex color
float tu,tv; // The texture coordinates
};

TVertex Vertex[4];

// for video fx plugins:
hr = GetTexture(VDJVIDEOENGINE,(void **)&pVDJTexture, &Vertex);

// for video transitions:
int iDeck = 1; // iDeck = 1 (left), 2 (right), ...
memcpy(Vertex,GetVertices(iDeck), 4*sizeof(TVertex));


- For SDK8:

Vertex[0].position.x=0.0f;
Vertex[0].position.y=0.0f;
Vertex[0].position.z=0.5f;
Vertex[0].color=D3DCOLOR_RGBA(255,255,255,255);
Vertex[0].tu=0.0f;
Vertex[0].tv=0.0f;

Vertex[1].position.x=1.0f * width;
Vertex[1].position.y=0.0f;
Vertex[1].position.z=0.5f
Vertex[1].color=D3DCOLOR_RGBA(255,255,255,255);
Vertex[1].tu=1.0f;
Vertex[1].tv=0.0f;

Vertex[2].position.x=1.0f * width;
Vertex[2].position.y=1.0f * height;
Vertex[2].position.z=0.5f;
Vertex[2].color=D3DCOLOR_RGBA(255,255,255,255);
Vertex[2].tu=1.0f;
Vertex[2].tv=1.0f;

Vertex[3].position.x=0.0f;
Vertex[3].position.y=1.0f * height;
Vertex[3].position.z=0.5f;
Vertex[3].color=D3DCOLOR_RGBA(255,255,255,255);
Vertex[3].tu=0.0f;
Vertex[3].tv=1.0f;


you can also define your own vertex to be used with pixel shaders (for Video FX):
struct D3DXCOLOR
{
public:
D3DXCOLOR() = default;
D3DXCOLOR(float r, float g, float b, float a)
{
this->r = r;
this->g = g;
this->b = b;
this->a = a;
}

operator FLOAT* ()
{
return &r;
}

float r, g, b, a;
};

struct TLVERTEX
{
struct { float x, y, z; } position;
D3DXCOLOR color;
float tu, tv;
};


- For SDK6 and previous: [deprecated in SDK8]


Vertex[0].position.x=-1.0f;
Vertex[0].position.y=1.0f;
Vertex[0].position.z=0.5f;
Vertex[0].color=D3DCOLOR_RGBA(255,255,255,255);
Vertex[0].tu=0.0f;
Vertex[0].tv=0.0f;

Vertex[1].position.x=1.0f;
Vertex[1].position.y=1.f;
Vertex[1].position.z=0.5f;
Vertex[1].color=D3DCOLOR_RGBA(255,255,255,255);
Vertex[1].tu=1.0f;
Vertex[1].tv=0.0f;

Vertex[2].position.x=-1.0f;
Vertex[2].position.y=-1.0f;
Vertex[2].position.z=0.5f;
Vertex[2].color=D3DCOLOR_RGBA(255,255,255,255);
Vertex[2].tu=0.0f;
Vertex[2].tv=1.0f;

Vertex[3].position.x=1.0f;
Vertex[3].position.y=-1.0f;
Vertex[3].position.z=0.5f;
Vertex[3].color=D3DCOLOR_RGBA(255,255,255,255);
Vertex[3].tu=1.0f;
Vertex[3].tv=1.0f;


// Color definition
#ifndef D3DCOLOR_DEFINED
#define D3DCOLOR_DEFINED
typedef DWORD D3DCOLOR;
#endif

#define D3DCOLOR_ARGB(a,r,g,b) \
((D3DCOLOR)((((a)&0xFF)<<24)|(((r)&0xFF)<<16)|(((g)&0xFF)<<8)|((b)&0xFF)))
#define D3DCOLOR_RGBA(r,g,b,a) D3DCOLOR_ARGB(a,r,g,b)

// Color definition (0xFF = 255)
#define GetRValue_D3DColor(d3dcolor) ((d3dcolor>>16)&255 )
#define GetGValue_D3DColor(d3dcolor) ((d3dcolor>>8)&255 )
#define GetBValue_D3DColor(d3dcolor) ((d3dcolor)&255 )
#define GetAValue_D3DColor(d3dcolor) ((d3dcolor>>24)&255 )

// Some colors
#define COLOR_BLACK D3DCOLOR_RGBA(0,0,0,255)
#define COLOR_WHITE D3DCOLOR_RGBA(255,255,255,255)
#define COLOR_RED D3DCOLOR_RGBA(255,0,0,255)
#define COLOR_GREEN D3DCOLOR_RGBA(0,255,0,255)
#define COLOR_BLUE D3DCOLOR_RGBA(0,0,255,255)
#define COLOR_YELLOW D3DCOLOR_RGBA(255,255,0,255)
#define COLOR_MAGENTA D3DCOLOR_RGBA(255,0,255,255)
#define COLOR_CYAN D3DCOLOR_RGBA(0,255,255,255)


3) Renderering:

 HRESULT VDJ_API CMyPlugin::OnDrawXXXX(xxxxx,yyyyyy)
{
HRESULT hr;
hr = DrawDeck(iDeck, Vertex);
return S_OK;
}

or
 HRESULT VDJ_API CMyPlugin::OnDraw() 
{
HRESULT hr;

#if (defined(VDJ_D3D11))
if (pVDJDevice)
{
pVDJDevice->GetImmediateContext(&pDeviceContext);
}
#endif


hr = DrawDeck();
return S_OK;
}


return S_FALSE; will automatically render the video for you

if you want to render by yourself, you can use for example the following function:
pVDJDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2,(LPVOID)Vertex,sizeof(Vertex[0]));
and in this case, use return S_OK;

D3D11_PRIMITIVE_TOPOLOGY PrimitiveTypology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
D3D11_BUFFER_DESC.D3D11_CPU_ACCESS_FLAG CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
D3D11_BUFFER_DESC.D3D11_USAGE Usage = D3D11_USAGE_DYNAMIC;
D3D11_BUFFER_DESC.D3D11_BIND_FLAG BindFlags = D3D11_BIND_VERTEX_BUFFER;
D3D11_RASTERIZER_DESC.D3D11_FILL_MODE FillMode = D3D11_FILL_SOLID;
D3D11_RASTERIZER_DESC.D3D11_CULL_MODE CullMode = D3D11_CULL_NONE;


4) Texturing:
D
#if (defined(VDJ_D3D9))
VDJVIDEOTEXTURE *texture;
//IDirect3DSurface9 *surface;
#elif
VDJVIDEOTEXTURE *texture;
#elif (defined(VDJ_OPENGL))
GLuint GLTexture;
#endif


Format = DGXI_FORMAT_B8G8R8A8_UNORM


in the function OnDraw() is the current video texture

Then you apply the texture (video,bitmap,...) on this square with the following function:

pVDJDevice->SetTexture(0,texture);

NB: in this case "0" means the first stage of the video



Fri 24 Mar 06 @ 4:48 pm

Voici 4 articles très importants et qui font la différence entre l'utilisateur lambda et quelqu'un qui maîtrise déjà un peu plus son ordinateur.
copyright 2006 - L'Ordinateur individuel - N°181 - Mars 2006
(dossier réalisé par Alexandre Salque et Alain Steinmann)






Je vous recommande aussi cet utilitaire très performant: PC Wizard 2007 que vous pouvez télécharger gratuitement sur http://www.cpuid.com/pcwizard.php


Voici également un article très intéressant à lire:
http://windows.developpez.com/cours/mem-virtuelle/


Enfin je vous recommande de lire cette explication sur la configuration des performances sous WinXP:
http://support.microsoft.com/default.aspx?scid=kb%3Bfr%3B308417

Quelques définitions:

programme d'arrière-plan:
Un programme d'arrière-plan est un programme qui s'exécute pendant que l'utilisateur effectue une autre tâche. Le microprocesseur de l'ordinateur attribue moins de ressources aux programmes d'arrière-plan qu'aux programmes de premier plan.

programme de premier plan:
Un programme de premier plan est le programme qui s'exécute dans la fenêtre active (fenêtre figurant en première position et dont la barre de titre apparaît en surbrillance). Il répond aux commandes émises par l'utilisateur.


Quelques optimisations:

Performances des applications :
• Sélectionnez sur Les programmes pour attribuer plus de ressources processeur au programme de premier plan qu'au programme d'arrière-plan.
• Sélectionnez sur Les services d'arrière-plan pour attribuer une quantité égale de ressources processeur à l'ensemble des programmes.

Remarques:
• Si vous cliquez sur Les programmes, le programme au premier plan s'exécute de manière plus souple et répond plus rapidement. Si vous souhaitez qu'une tâche en arrière-plan, telle qu'un utilitaire de sauvegarde, s'exécute plus rapidement, cliquez sur Les services d'arrière-plan.
• L'option Les programmes alloue des tranches de durée courtes et variables (appelées également quanta) aux programmes en cours d'exécution et l'option Les services d'arrière-plan attribue des quanta longs et fixes.

Quelques liens externes intéressants:
http://www.hotline-pc.org/



Fri 23 Dec 05 @ 8:19 pm

Rappel sur le son WAVE (.wav), format audio non compressé créé par Microsoft:
=> prenons l'exemple du CD audio avec:
* une fréquence d'échantillonage fe de 44100 samples par seconde (44.1kHz)
* un codage du sample sur 16 bits (bits={0,1} donc 2^16=65536 valeurs possibles)
* un nombre de canaux de 2 (stéréo= 2 x mono)

On en déduit le débit de bit à traiter:
débit=fe*codage_sample*nb_canaux

soit pour le CD audio: débit=1 411 200 bits par seconde [bps] (soit environ 1 411kbps)
(Remarque: si le son était en mono, on aurait eu un débit de 705 600 bps soit environ 706 kbps)

=> Le but de la compression MP3 est de diminuer la taille totale du fichier et pour cela on va diminuer le débit tout en préservant une très bonne qualité d'écoute

=> Pour cela, voici quelques solutions:
* de manière générale, les basses sur les 2 canaux stéréo sont identiques donc on ne garde que les informations d'un canal
* on supprime des fréquences trop élévées car les personnes en générale ne les percoivent pas



Mon 18 Jul 05 @ 1:26 am

Le son:
Le son est une vibration qui se traduit par une variation de la pression de l'air ou de tout autre milieu fluide dans lequel elle se propage (il s'agit donc bien d'une onde physique qui a besoin d'un support pour se propager. Par exemple, dans un vide d'air, le son ne se propage pas)

Les composantes du son:
La diffusion sonore n'est rien moins que la transmission jusqu'à l'oreille d'un certain nombre d'informations définies selon 3 critères:
* la hauteur: (la fréquence est exprimée en Hertz [Hz])
* le timbre: c'est la texture du son (flûte,piano,...)
* le niveau sonore (l'amplitude ou le volume en language courant): (le niveau est exprimé en décibel [dB])

Les fréquences audibles par l'homme sont comprises entre 20Hz (grave) et 20kHz (aigus), les niveaux sonores de 0dB (seuil d'audibilité) [=aucun bruit=vide d'air] à 120dB (seuil de douleur) [par exemple décollage d'une fusée]

La qualité sonore:
Elle est définie par plusieurs critères:
* la bande passante (20Hz-20000Hz pour l'oreille humaine)
* la dynamique (rapport du son le plus fort au son le plus faible)
* la distorsion harmonique (déformation du signal) (inferieure à 0,01%)
* le rapport signal/bruit (rapport entre le signal maximal enregistré et le bruit de fond propre au système) [jusqu'à 96dB]
* la séparation des canaux pour les systèmes multicanaux (2 - 4.1 - 5.1 - 6.1 - 7.1 )


Tue 14 Jun 05 @ 4:29 pm

L'échantillonnage (sampling en anglais):
Comment convertir un signal analogique (le vrai signal, celui qui arrive à vos oreilles) en un signal numérique (celui utilisé pour stocker votre chanson sur votre ordinateur ou un CD)
Pour comprendre cela, nous allons simplifier au maximum en prenant un son sinusoidal de fréquance f=1/T (T est la période exprimée en secondes et f est exprimé en Hertz de symbole Hz qui est donc l'inverse d'un temps)

On considère donc le signal sinusoidal s en fonction du temps t : s(t)=a.sin(w.t+φ) où a est l'amplitude du signal, w=2.п.f=2.п/T est la pulsation du signal et phi φ est ce que l'on appelle la phase du signal (pi: п=3.14.....)

On remarquera au passage que pour une inversion de polarité (déphasage de φ=п=180°) on a: sin(x+п)=sin(x-п)=-sin(x) cela veut dire que l'on a Inversion_de_polarité[s(t)]=-s(t) donc que l'on inverse le signal (on prend son symétrique par rapport à l'axe des abscisses)



Le but de cette conversion consiste à prélever des valeurs de la courbe analogique s(t)=a.sin(w.t+φ) à des intervalles de temps régulier, c'est ce que l'on appelle l'échantillonnage. On note souvent la fréquence d'échantillonage ou taux d'échantillonage (SAMPLE_RATE en anglais) fe=1/Te (c'est donc le nombre d'échantillons par seconde). On recupère donc au final la suite s(n.Te) où n est un entier relatif
Virtual DJ fonctionne à une fréquence d'échantillonage de fe=44100Hz (Te~0.02ms) (sauf à partir de la version 8)

s(n.Te)=a.sin(w.n.Te+φ)=a.sin(w.n/fe+φ)=a.sin(2.п.n.f/fe+φ) car w=2.п.f et fe=1/Te

Sur le dessin, chaque croix bleu est donc un échantillon (sample en anglais) (un échantillon peut donc avoir une valeur positive ou négative)



Le son stéréo consiste à avoir le son en 2 canaux audio (droit et gauche) au lieu de 1 canal (mono) donc vous avez deux courbes sinusoidales différentes, une sur chaque canal, autrement dit 2 suites d'échantillons

Une chanson est en fait une superposition (une addition) d'une multitude de sinusoides de fréquences f différentes (pour plus d'information, lire sur Fourier) et ayant des temps de vies plus ou moins longs selon le style de musique et la fréquence. Par exemple, sur un style techno, la durée de vie des basses est assez périodique et cette période est ce que l'on appelle le beat. On peut ensuite déterminer le bpm (= nombre de beats par minute donc par 60s)

Le quantification (le codage):
Cette étape de la numérisation consiste à remplacer la valeur réelle sur la courbe par l’entier le plus proche (arrondi).



Après échantillonnage, on récupère donc des valeurs qui sont évaluées en fonction d'une échelle de référence, puis exprimées en nombre binaire. Dans le cas du CD, la quantification se fait sur 2^16 niveaux, soit 65536 valeurs de quantification (codage sur 16 bits => 2^16=65536 valeurs de codages)
=> suite de valeurs entières que l'on peut placer dans un vecteur

Remarque (sauf à partir de la version 8): Virtual DJ travaille avec une résolution de 16bits (soit 2 octets) donc 65536 valeurs. C'est pour cela que la macro LIMITER des plugins limite à 32768 en valeurs négatives et à 32767 en valeurs positives (32767 et on ajoute le 0 pour avoir 32768 valeurs positives)



Mon 13 Jun 05 @ 9:31 pm

How to convert an analogical signal to numerical signal:(example of a sinusoidal sound with a frequency f=1/T) (T in second(s) and f in Hertz(Hz))


In fact you get a value on the curve at each Te second: SAMPLE_RATE: (= number of samples by second)
fe=1/Te=44100Hz for Virtual DJ (=> Te~0.02ms)

Each blue cross is a sample (= a value, positive or negative)


A song is a superposition (an addition) of a lot of sinusoidal sound with different frequencies (for more information, read about Fourier) and a "time of life" (depending on the frequency and style of the played song)

A stereo song is composed of two channels = two curves, one for left speaker, another one for right speaker

In the VDJ plugin, a song is represented by a "vector" (a table represented by a pointer in C++) of samples from 1 to songLength where songLength is the number of blue cross in the song. Each case of the table contains the value (integer positive or negative) of the sample. Thanks to this method, you can directly know where you are in the song, the most of the time, we call pos the integer corresponding to the current position in the song. For example: with SongLength + SAMPLE_RATE fe, we can guess the length in seconds of the song, then convert in minutes,etc...




Sun 06 Feb 05 @ 10:01 pm

Une beauté tombée du Siel...

DJ Morris mixant en live sur les vinyls time codé

DJ SpeedLand alias Gwenn à son tour. Vu l'écran que l'on avait, faudrait penser à faire une skin 16/9 ;-)

Sur la gauche des utilisateurs de Virtual DJ avec une belle chemise blanche au couleur de Virtual DJ ( de gauche à droite: Thomas M, dj pedro, nouvo01) et à droite Gwenn