<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Custom DLLs for use in JSL in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Custom-DLLs-for-use-in-JSL/m-p/358517#M60860</link>
    <description>&lt;P&gt;Maybe you can get something from tech support; there might be a file called ExtFunctionTests that is a C++ program with a complete set of examples for passing data types in and out of a DLL.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or maybe this will steer in the right direction (this was built in 2009 with whatever version of visual studio was popular at the time. Here are the important sections. "sound" because this DLL was used to let JMP play sound)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The JMP interface functions in the DLL:&lt;/P&gt;&lt;PRE&gt;EXPORTFUNC int __cdecl init( int nCols, int channelMask, int samplesPerSecond, int nRows )
{
	if ( theApp.mSoundThread == NULL )
	{
		theApp.mSoundThread = (SoundThread*)AfxBeginThread( RUNTIME_CLASS(SoundThread), 0, 0, CREATE_SUSPENDED, 0 );
		theApp.mSoundThread-&amp;gt;init( nCols, channelMask, samplesPerSecond, nRows );
		theApp.mSoundThread-&amp;gt;ResumeThread();
		return 1;
	}
	return 0;
}

EXPORTFUNC double __cdecl feed( double * matrix, int elements )
{
	return theApp.mSoundThread-&amp;gt;feed( matrix, elements );
}

LPWSTR g_Declarations = L"\
DeclareFunction(\"init\", Convention( CDECL ), \n\
	Arg( Int32, \"nCols\" ),	Arg( Int32, \"channelMask\" ),	Arg( Int32, \"samplesPerSecond\" ),	Arg( Int32, \"nRows\" ),	Returns( Int32 ) ) &amp;lt;&amp;lt; \n\
DeclareFunction(\"feed\", Convention( CDECL ),\n\
	Arg(Double, Array, \"array of nCols channels X nRows samples, -1..+1 \"), Arg(Int32), Returns(Double) );\n\
";



LPCWSTR __stdcall _JMP_Declarations()
{
	return g_Declarations;
}&lt;/PRE&gt;&lt;P&gt;The .DEF file&lt;/P&gt;&lt;PRE&gt;; JMPSound.def : Declares the module parameters for the DLL.

LIBRARY      "JMPSound"

EXPORTS
    ; Explicit exports can go here
	_JMP_Declarations
	&lt;/PRE&gt;&lt;P&gt;The JSL to init the DLL is simple because of the g_Declarations above:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dll = loaddll("C:\Documents and Settings\L\Desktop\JMPSound.dll");
dll&amp;lt;&amp;lt;init(6,1+2+4+8+16+32,48000,3*fullStroke);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;"init()" just works. And "feed()" is similar, passing arrays...&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;	data = leftchan || rightchan || col1:*alternate || col2:*alternate || col3:*alternate || col4:*alternate;
	dll &amp;lt;&amp;lt; feed( data, 0 );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;(The purpose of the DLL was to accept audio samples through the feed function and play them...while JMP was computing the next set of samples. The threading stuff was specific to this DLL, you don't need to use threads.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 12 Feb 2021 15:51:01 GMT</pubDate>
    <dc:creator>Craige_Hales</dc:creator>
    <dc:date>2021-02-12T15:51:01Z</dc:date>
    <item>
      <title>Custom DLLs for use in JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Custom-DLLs-for-use-in-JSL/m-p/358407#M60846</link>
      <description>&lt;P&gt;I want to use the &lt;A href="https://www.jmp.com/support/help/Dynamic_Link_Libraries.shtml" target="_self"&gt;&lt;EM&gt;Load DLL()&lt;/EM&gt;&lt;/A&gt; with my own DLL built in Visual Studio. Has anyone done this successfully?&lt;/P&gt;&lt;P&gt;Where can I find sample source code for that shows how to do this on the DLL side.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 22:06:04 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Custom-DLLs-for-use-in-JSL/m-p/358407#M60846</guid>
      <dc:creator>phillipmilne</dc:creator>
      <dc:date>2023-06-09T22:06:04Z</dc:date>
    </item>
    <item>
      <title>Re: Custom DLLs for use in JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Custom-DLLs-for-use-in-JSL/m-p/358474#M60850</link>
      <description>&lt;P&gt;If you do 'Help &amp;gt; Scripting Index' and search for 'DLL' you should see a number of examples to get you started:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2021-02-12 at 10.49.04.png" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/30204iB16A6850E4B4927A/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2021-02-12 at 10.49.04.png" alt="Screenshot 2021-02-12 at 10.49.04.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Feb 2021 10:53:21 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Custom-DLLs-for-use-in-JSL/m-p/358474#M60850</guid>
      <dc:creator>ian_jmp</dc:creator>
      <dc:date>2021-02-12T10:53:21Z</dc:date>
    </item>
    <item>
      <title>Re: Custom DLLs for use in JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Custom-DLLs-for-use-in-JSL/m-p/358489#M60854</link>
      <description>&lt;P&gt;And there is &lt;A href="https://www.jmp.com/support/help/en/15.2/#page/jmp/dynamic-link-libraries.shtml" target="_self"&gt;this entry&lt;/A&gt; in the JMP Help for DLLs.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Feb 2021 13:43:10 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Custom-DLLs-for-use-in-JSL/m-p/358489#M60854</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2021-02-12T13:43:10Z</dc:date>
    </item>
    <item>
      <title>Re: Custom DLLs for use in JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Custom-DLLs-for-use-in-JSL/m-p/358491#M60856</link>
      <description>&lt;P&gt;See Mark's link for JMP-aware DLLs. I made one, a long time ago. To be clear, there are two kinds: JMP-aware DLLs, and all the rest. A JMP-aware DLL has some extra information that makes it a little easier to use, and probably doesn't have entry points that are unusable. Entry points that use complicated structures and pointers that don't map nicely into JMP data types are probably unusable.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'll look and see if I can find it, it is pretty dusty wherever I left it...&lt;/P&gt;&lt;P&gt;Here's an example of a non-aware use of "&lt;SPAN&gt;PlaySound in the multimedia DLL"&amp;nbsp;&lt;LI-MESSAGE title="Audio Note in an Envelope" uid="282011" url="https://community.jmp.com/t5/Uncharted/Audio-Note-in-an-Envelope/m-p/282011#U282011" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-blog-thread lia-fa-icon lia-fa-blog lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/1492"&gt;@jschroedl&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Feb 2021 14:32:27 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Custom-DLLs-for-use-in-JSL/m-p/358491#M60856</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2021-02-12T14:32:27Z</dc:date>
    </item>
    <item>
      <title>Re: Custom DLLs for use in JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Custom-DLLs-for-use-in-JSL/m-p/358517#M60860</link>
      <description>&lt;P&gt;Maybe you can get something from tech support; there might be a file called ExtFunctionTests that is a C++ program with a complete set of examples for passing data types in and out of a DLL.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or maybe this will steer in the right direction (this was built in 2009 with whatever version of visual studio was popular at the time. Here are the important sections. "sound" because this DLL was used to let JMP play sound)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The JMP interface functions in the DLL:&lt;/P&gt;&lt;PRE&gt;EXPORTFUNC int __cdecl init( int nCols, int channelMask, int samplesPerSecond, int nRows )
{
	if ( theApp.mSoundThread == NULL )
	{
		theApp.mSoundThread = (SoundThread*)AfxBeginThread( RUNTIME_CLASS(SoundThread), 0, 0, CREATE_SUSPENDED, 0 );
		theApp.mSoundThread-&amp;gt;init( nCols, channelMask, samplesPerSecond, nRows );
		theApp.mSoundThread-&amp;gt;ResumeThread();
		return 1;
	}
	return 0;
}

EXPORTFUNC double __cdecl feed( double * matrix, int elements )
{
	return theApp.mSoundThread-&amp;gt;feed( matrix, elements );
}

LPWSTR g_Declarations = L"\
DeclareFunction(\"init\", Convention( CDECL ), \n\
	Arg( Int32, \"nCols\" ),	Arg( Int32, \"channelMask\" ),	Arg( Int32, \"samplesPerSecond\" ),	Arg( Int32, \"nRows\" ),	Returns( Int32 ) ) &amp;lt;&amp;lt; \n\
DeclareFunction(\"feed\", Convention( CDECL ),\n\
	Arg(Double, Array, \"array of nCols channels X nRows samples, -1..+1 \"), Arg(Int32), Returns(Double) );\n\
";



LPCWSTR __stdcall _JMP_Declarations()
{
	return g_Declarations;
}&lt;/PRE&gt;&lt;P&gt;The .DEF file&lt;/P&gt;&lt;PRE&gt;; JMPSound.def : Declares the module parameters for the DLL.

LIBRARY      "JMPSound"

EXPORTS
    ; Explicit exports can go here
	_JMP_Declarations
	&lt;/PRE&gt;&lt;P&gt;The JSL to init the DLL is simple because of the g_Declarations above:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dll = loaddll("C:\Documents and Settings\L\Desktop\JMPSound.dll");
dll&amp;lt;&amp;lt;init(6,1+2+4+8+16+32,48000,3*fullStroke);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;"init()" just works. And "feed()" is similar, passing arrays...&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;	data = leftchan || rightchan || col1:*alternate || col2:*alternate || col3:*alternate || col4:*alternate;
	dll &amp;lt;&amp;lt; feed( data, 0 );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;(The purpose of the DLL was to accept audio samples through the feed function and play them...while JMP was computing the next set of samples. The threading stuff was specific to this DLL, you don't need to use threads.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Feb 2021 15:51:01 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Custom-DLLs-for-use-in-JSL/m-p/358517#M60860</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2021-02-12T15:51:01Z</dc:date>
    </item>
    <item>
      <title>Re: Custom DLLs for use in JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Custom-DLLs-for-use-in-JSL/m-p/358592#M60867</link>
      <description>&lt;P&gt;This is the direction that I want to go. Thanks!&lt;BR /&gt;It would be great to have a sample VS Solution/Project to download and compile.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Feb 2021 18:47:03 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Custom-DLLs-for-use-in-JSL/m-p/358592#M60867</guid>
      <dc:creator>phillipmilne</dc:creator>
      <dc:date>2021-02-12T18:47:03Z</dc:date>
    </item>
  </channel>
</rss>

