Welcome to %s forums

BrainModular Users Forum

Login Register

testing module

Create your own modules in C++
Post Reply
nelson
Member
Posts: 36
Contact:

Unread post by nelson » 31 Dec 2008, 12:34

hi all

1. How to test user module in visual c++? how to trace variables etc ... I never work with dll's... its impossible to make module testing it like this: compile, copy to usine, restart usine, test in patch just to look at one variable state.

2. how to send data to ArrayOut?

for (i = 0; i < 8; i++) {
pPrototype->PArrayOut->DATA = tab;
}

it's good way to do that? it's not work ....

martignasse
Site Admin
Posts: 611
Location: Lyon, FRANCE
Contact:

Unread post by martignasse » 31 Dec 2008, 13:56

Hi nelson
nelson wrote:1. How to test user module in visual c++? how to trace variables etc ... I never work with dll's... its impossible to make module testing it like this: compile, copy to usine, restart usine, test in patch just to look at one variable state.
What do you mean by 'to test user module' ?
Normally, compile, copy to usine, restart usine should let you see your module and use it. After that, the simplest way to trace values is to look what you have on the module pin. For intermediate or internal values, module with panel who write the concerned value seems to be the way.
2. how to send data to ArrayOut?

for (i = 0; i < 8; i++) {
pPrototype->PArrayOut->DATA = tab;
}
it's good way to do that? it's not work ....

You're nearly good (assuming you do this in the Process methode), but did you tell usine the length of the pArrayOut array, like this ?

Code: Select all

void Process &#40;void* pModule&#41; &#123;

	// make convenient pointer to the module
	TArrayTest* pArrayTest = &#40;&#40;TArrayTest*&#41;pModule&#41;;

	// used for loop
	int i;

	// test to fill the array
	pArrayTest->PArrayOut->len = 8;

	for &#40;i = 0; i < pArrayTest->PArrayOut->len; i++&#41; &#123;
		pArrayTest->PArrayOut->DATA&#91;i&#93; = i;
	&#125;
&#125;
tested and working for me, tell me if you want i upload an example project on the wiki.

a+
Martin FLEURENT - Usine Developer - SDK maintainer

LevraiBernardo
Site Admin
Posts: 110
Contact:

Unread post by LevraiBernardo » 16 Aug 2009, 03:32

To test a value, here is the way I do :
#include <sstream>

then, in the function, create a stream string and a string formatting the message :
std::ostringstream Oss;
std::string msg;

Go on filling the stream with a message containing the var value, then make it a string :
Oss << "m_var value :" << m_var;
msg = Oss.str();

To finish, show a modal window with the message :
MessageBox(NULL,msg.data(), TEXT("Title of the window"), MB_OK );

(One window can contain several values : Oss << "m_var1 value :" << m_var1 << "m_var2 value :" << m_var2 ... No matter the var type this way.)

martignasse
Site Admin
Posts: 611
Location: Lyon, FRANCE
Contact:

Unread post by martignasse » 17 Aug 2009, 12:09

hi LevraiBernardo,

and thanks for the trick,
To finish, show a modal window with the message :
MessageBox(NULL,msg.data(), TEXT("Title of the window"), MB_OK );
just to let you know, next version will have trace functions to write directly in the usine console.

You can also debug your module with some VC++ breakpoints.

Short version :
To do that, there is some infos to add to the Project properties panel.
in 'Configuration properties->debug->command ' add the path to the UsineMain.exe (not the Usine.exe, but UsineMain.exe)
example : 'E:AudioUsine Pro StandAlone 4.22dFilesUsineMain.exe'

and in the 'build event->Post-build event->command line' add a shell command to copy the generated .usr file in the usine folder
example : 'xcopy /e /i /y "$(OutDir)$(ProjectName)_D.usr" "E:AudioUsine Pro StandAlone 4.22dFilesModulesUserExamples"'

like that, when you start debug your module (F5), VC++ automatically copy it in the usine module folder and start usine.
make sure usine has the autoload option to on in the setup panel, and make a workspace that use your module, save it.

and if you place breakpoint in your module code, you can inspect the code execution at runtime.

to finish the debug session, simply close usine and you are back in VC++

PS : I began a wiki page on this chapter
http://www.sensomusic.com/wiki/doku.php?id=sdk:cpp_area:how_to:debug
Martin FLEURENT - Usine Developer - SDK maintainer

LevraiBernardo
Site Admin
Posts: 110
Contact:

Unread post by LevraiBernardo » 19 Aug 2009, 04:44

Yeah !
It works great, and it's much more efficient than my "french" cooking.
Thanx a lot, Mister Tignasse.
See you !

martignasse
Site Admin
Posts: 611
Location: Lyon, FRANCE
Contact:

Unread post by martignasse » 19 Aug 2009, 09:49

well, thanks to Senso, has he give me the trick :)
Martin FLEURENT - Usine Developer - SDK maintainer

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests