XBMC Community Forum  

Go Back   XBMC Community Forum > Development > XBMC Development

XBMC Development Developers forums for XBMC related development. Programmers/Coders only!
No end-user support, no bug reports, and no feature/function requests here!
Please, add platform prefix for suggestions that are not platform-independent!:
Thread prefixes; "[LINUX]", "[LIVE]", "[MAC]", "[WINDOWS]", and "[XBOX]"

Reply
 
Thread Tools Search this Thread Display Modes
Old 2003-10-12, 20:07   #1
Frodo
Team MediaPortal
 
Join Date: Sep 2003
Posts: 509
Frodo is on a distinguished road
Thumbs up Visualisation plugin API for XBMC

hi,

i'm setting up an architecture which allows other devs to develop a visualisation plugin for xbmc

from the settings->music the end-user can select which visz. he/she wants and xbmc will use that one.
so how does it work?
first :
1. visz. plugins are normal .dlls but with the extension .vis
2. visz. plugins should b copied into the visualisations/ subdirectory on your xbox
3. visz. plugins must use a minimal set of dependencies. they should not depend on windows kernel/gdi or other things!


so how to program one?
here's a skeleton of a visz. plugin .dll:
Quote:
// spectrum.cpp: implementation of the cspectrum class.
//
//////////////////////////////////////////////////////////////////////

#include <xtl.h>
#pragma comment (lib, "lib/xbox_dx8.lib" )

extern "c"
{
struct vis_info {
bool bwantsfreq;
int isyncdelay;
// int iaudiodatalength;
// int ifreqdatalength;
};
};

vis_info vinfo;
static lpdirect3ddevice8 m_pd3ddevice;
extern "c" void create(lpdirect3ddevice8 pd3ddevice, int iscreenwidth, int iscreenheight, const char* szvisname)
{
}

extern "c" void start(int ichannels, int isamplespersec, int ibitspersample, const char* szsongname)
{
}


extern "c" void audiodata(short* paudiodata, int iaudiodatalength, float *pfreqdata, int ifreqdatalength)
{
}

extern "c" void render()
{
}


extern "c" void stop()
{
}


extern "c" void getinfo(vis_info* pinfo)
{
memcpy(pinfo,&vinfo,sizeof(struct vis_info ) );
}
extern "c"
{
struct visualisation
{
public:
// gets called once during initialisation. allows vis. plugin to initialize itself
// pd3ddevice is a pointer to the dx8 device which you can use for dx8
// iscreenwidth/iscreenheight are the gui's screenwidth/screenheight in pixels
// szvisualisationname contains the name of the visualisation like goom or spectrum,...
void (--cdecl* create)(lpdirect3ddevice8 pd3ddevice, int iscreenwidth, int iscreenheight, const char* szvisualisationname);

// gets called at the start of a new song
// ichannels = number of audio channels
// ibitspersample = bits of each sample ( 8 or 16)
// isamplespersec = number of samples / sec.
// szsongname = name of the current song
void (--cdecl* start)(int ichannels, int isamplespersec, int ibitspersample, const char* szsongname);

// gets called if xbmc has new audio samples for the vis. plugin
// paudiodata is a short [channels][iaudiodatalength] array of raw audio samples
// pfreqdata is a array of float[channels][ifreqdatalength] of fft-ed audio samples
void (--cdecl* audiodata)(short* paudiodata, int iaudiodatalength, float *pfreqdata, int ifreqdatalength);

// gets called if vis. plugin should render itself
void (--cdecl* render) ();

// gets called if vis. should stop & cleanup
void (--cdecl* stop)();

// gets called if xbmc wants to know the visz. parameters specified by the vis_info struct
void (--cdecl* getinfo)(vis_info* pinfo);
};

void --declspec(dllexport) get_module(struct visualisation* pvisz)
{
pvisz->create = create;
pvisz->start = start;
pvisz->audiodata = audiodata;
pvisz->render = render;
pvisz->stop = stop;
pvisz->getinfo = getinfo;
}
};
please note that due to a bug in the forums i cant post any underscores. so i replaced the underscores with --
xbmc will first call get_module() to retrieve the visualisation struct. the plugin will give xbmc the visualisation struct filled with function pointers to all visz. routines needed by xbmc


well thats it for now. remember this is all premature.
no plugins are available yet, but hopefully we'll see one soon

frodo



__________________
XBMC Project Founder (Retired), now head programmer of MediaPortal
Frodo is offline   Reply With Quote
Old 2003-10-12, 23:45   #2
jmarshall
Team-XBMC Developer
 
Join Date: Oct 2003
Posts: 15,077
jmarshall is on a distinguished road
Default

frodo:

what a great interface! i wonder how long it will take me to port the spectrum analyser...

perhaps having the possibility to transfer other information regarding the audio would be a good feature - things such as track, album, artist info etc. might be an idea?

i'll look at compiling up the spectrum analyser plugin - the only other dependencies are xmldocument for loading the config file iirc.

cheers,
jonathan
__________________
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


jmarshall is offline   Reply With Quote
Old 2003-10-13, 08:52   #3
Frodo
Team MediaPortal
 
Join Date: Sep 2003
Posts: 509
Frodo is on a distinguished road
Default

hehehe, yeah i must admit i copied the ideas from you visz. classes :d
about copying more info, i'll see if i can come up with something

frodo
__________________
XBMC Project Founder (Retired), now head programmer of MediaPortal
Frodo is offline   Reply With Quote
Old 2003-10-13, 09:59   #4
jmarshall
Team-XBMC Developer
 
Join Date: Oct 2003
Posts: 15,077
jmarshall is on a distinguished road
Default

that's cool. have you implemented the fft code + delay stuff? if so, i'll look at having a play with getting the sa into a dll. (i haven't done any dll based stuff before, so this should be an adventure - i may ask some questions when i get stuck)

cheers,
jonathan
__________________
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


jmarshall is offline   Reply With Quote
Old 2003-10-13, 11:03   #5
Frodo
Team MediaPortal
 
Join Date: Sep 2003
Posts: 509
Frodo is on a distinguished road
Default

Quote:
have you implemented the fft code + delay stuff?
yes, well you did. i just copied it into xbmc
anyway i forgot 2 add a method to pass the vis_info struct.
its added now (see updated skeleton above)

when we got a basic plugin working i'll add other things like the album/artist etc info.

about the dll, yes its tricky.
compiling a .dll is easy, but we dont want any dependencies on windows. so i'm writing my own import libraries now which you can use. when its working i'll put it in cvs together with an complete working example plugin project

frodo
__________________
XBMC Project Founder (Retired), now head programmer of MediaPortal
Frodo is offline   Reply With Quote
Old 2003-10-13, 15:58   #6
Gamester17
Team-XBMC Project Manager
 
Gamester17's Avatar
 
Join Date: Sep 2003
Location: Sweden
Posts: 10,582
Gamester17 will become famous soon enough
Unhappy

very cool, but just wondering how the customizable part in viz such as jmarshall's spectrum analyzer gonna work?
(maybe add a set of parameters inside that can be selected from within gui, and/or a seprate xml file for it?)
__________________
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Gamester17 is offline   Reply With Quote
Old 2003-10-13, 15:59   #7
Frodo
Team MediaPortal
 
Join Date: Sep 2003
Posts: 509
Frodo is on a distinguished road
Default

Quote:
but just wondering how the customizable part in viz such as jmarshall's spectrum analyzer gonna work?
for version 1 :seperate xml

frodo
__________________
XBMC Project Founder (Retired), now head programmer of MediaPortal
Frodo is offline   Reply With Quote
Old 2003-10-13, 16:07   #8
Gamester17
Team-XBMC Project Manager
 
Gamester17's Avatar
 
Join Date: Sep 2003
Location: Sweden
Posts: 10,582
Gamester17 will become famous soon enough
Exclamation

Quote:
Originally Posted by (frodo @ oct. 13 2003,13:59)
Quote:
but just wondering how the customizable part in viz such as jmarshall's spectrum analyzer gonna work?
for version 1 :seperate xml
k, for v2 maybe devide xml into sections (each which own name) & make those selectable from gui
__________________
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Gamester17 is offline   Reply With Quote
Old 2003-10-14, 00:01   #9
jmarshall
Team-XBMC Developer
 
Join Date: Oct 2003
Posts: 15,077
jmarshall is on a distinguished road
Default

sounds good, frodo.

the vis_info struct i figured might be the way to transfer info in the future, but i hadn't really thought about it all that much, though.

i had a play with doing some dll stuff last night. i basically just generated a .dll project, then "modified" it via editing the .vcproj file to use xbox stuff. had to muck around with .lib files to include when linking + still didn't get all the stuff it needed - i was kind of shooting in the dark to be honest!

let me know when you have some import libraries sorted + the example project and i'll do the sa.

cheers,
jonathan
__________________
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


jmarshall is offline   Reply With Quote
Old 2003-10-14, 08:32   #10
Frodo
Team MediaPortal
 
Join Date: Sep 2003
Posts: 509
Frodo is on a distinguished road
Default

well here's the status so far.
1. i ported your spectrum analyser to a visz. dll
2. xbmc can load it
3. all the function calls seem 2 work (create/stop/start/render...)

but the 2nd time i call render() it crashes
my guess is that there's something wrong with the directx linking, so i'll look into it

frodo
__________________
XBMC Project Founder (Retired), now head programmer of MediaPortal
Frodo is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
LinVDR video/control client built-into XBMC (ex. streamdev plugin) Boxler XBMC Feature Suggestions 31 2008-09-11 17:14
Xbmc locks on to one plugin tigerclaw XBMC for Xbox Specific Support 2 2005-08-13 03:56
G-Force vis-plugin porting to XBMC, need help plz questor/fused XBMC Development 24 2004-04-15 16:21
Audioscrobbler plugin for xbmc italic_dj XBMC Feature Suggestions 0 1970-01-01 02:00


All times are GMT +2. The time now is 17:54.


Protected by Akismet, We recommend WordPress blogs
Copyright © 2008, XBMC Project