From 9eecc6df5283ffeecdb4f572a3847a741469926c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Tue, 13 Jul 2004 16:33:26 +0000 Subject: This commit was generated by cvs2svn to compensate for changes in r1849, which included commits to RCS files with non-trunk default branches. svn path=/trunk/externals/hardware/; revision=1850 --- memPIO/README.txt | 34 +++++++++ memPIO/help-memPIO.pd | 52 ++++++++++++++ memPIO/memPIO.cpp | 187 ++++++++++++++++++++++++++++++++++++++++++++++++++ memPIO/memPIO.dsp | 67 ++++++++++++++++++ memPIO/memPIO.dsw | 29 ++++++++ 5 files changed, 369 insertions(+) create mode 100644 memPIO/README.txt create mode 100644 memPIO/help-memPIO.pd create mode 100644 memPIO/memPIO.cpp create mode 100644 memPIO/memPIO.dsp create mode 100644 memPIO/memPIO.dsw (limited to 'memPIO') diff --git a/memPIO/README.txt b/memPIO/README.txt new file mode 100644 index 0000000..8551169 --- /dev/null +++ b/memPIO/README.txt @@ -0,0 +1,34 @@ +memPIO: an external to read from/write to the "mem-PIO"-device by bmcm ( httP://www.bmcm.de ) with pure-data. + +the "mem-PIO" is a USB-device that offers digital (this is: 1 & 0) I/O. +there are 3 ports, each 8 channels. +each port can be set to either input or output +(not quite true: port3 is split into 2 subports (4 channels each) that can be set to input resp. output +separately; however this is not supported by this external) + + + +general:: +memPIO is a plugin for miller.s.puckette's realtime-computermusic-environment "puredata" (or abbreviated "pd") +this software will be of no use, if you don't have a running version of pd on your system. +check out for http://pd.iem.at to learn more about pd and how to get it. + +note: [memPIO] should be published under the Gnu General Public License. +However, it is heavily based on the example-code provided by bmcm, which does not come with a copyright notice +(at least i didn't find one) + +unfortunately [memPIO] is windows only (there are no drivers for other OS! shame on bmcm) + +win32 : +extract the memPIO-0_x.zip. +start pd with the extraction path included (e.g: pd -path PATH\TO\MY\MEMPIO\) +create an object [memPIO] +there is a helpfile help-memPIO.pd that explains what is happening. + +compiling: +if you want to compile it for yourself, use the workspace memPIO.dsw. i am not sure, whether it works with anything but m$ visual-c++ 6.0 + +authors:: +this software is copyleft by iohannes m zmoelnig + + diff --git a/memPIO/help-memPIO.pd b/memPIO/help-memPIO.pd new file mode 100644 index 0000000..1353d07 --- /dev/null +++ b/memPIO/help-memPIO.pd @@ -0,0 +1,52 @@ +#N canvas 0 0 963 494 12; +#X msg 49 90 bang; +#X obj 49 40 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1 +; +#X floatatom 92 243 5 0 0 1 port3 - -; +#X msg 303 87 mode \$1; +#X obj 303 68 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1 +; +#X msg 635 107 set \$1; +#X floatatom 635 167 3 0 255 1 8bit - -; +#X msg 635 190 set 255 \$1 0; +#X msg 303 129 mode 0 1 1; +#X obj 49 210 memPIO; +#X floatatom 70 264 5 0 0 1 port2 - -; +#X floatatom 49 285 5 0 0 1 port1 - -; +#X obj 49 64 metro 50; +#X text 57 109 read readable ports; +#X text 59 7 reading; +#X text 633 23 writing; +#X text 307 4 set port-direction:; +#X text 302 23 0__readable (default); +#X text 302 39 1__writeable; +#X text 325 64 set all ports; +#X text 306 113 set ports independently; +#X floatatom 635 85 3 0 255 1 8bit - -; +#X text 604 41 mode must be set to "writable"; +#X text 592 69 set all writable ports to the same value; +#X text 617 150 write ports independently; +#X text 238 325 note: to understand the values \, you will need some +knowledge about bits.; +#X floatatom 49 341 1 0 0 0 - - -; +#X obj 49 318 & 1; +#X text 65 342 line1 of port1; +#X text 89 418 IMPORTANT NOTE: do not (un)plug the device while using +[memPIO] !!; +#X msg 251 242 help; +#X connect 0 0 9 0; +#X connect 1 0 12 0; +#X connect 3 0 9 0; +#X connect 4 0 3 0; +#X connect 5 0 9 0; +#X connect 6 0 7 0; +#X connect 7 0 9 0; +#X connect 8 0 9 0; +#X connect 9 0 11 0; +#X connect 9 1 10 0; +#X connect 9 2 2 0; +#X connect 11 0 27 0; +#X connect 12 0 0 0; +#X connect 21 0 5 0; +#X connect 27 0 26 0; +#X connect 30 0 9 0; diff --git a/memPIO/memPIO.cpp b/memPIO/memPIO.cpp new file mode 100644 index 0000000..aa9aaf2 --- /dev/null +++ b/memPIO/memPIO.cpp @@ -0,0 +1,187 @@ +/* ...this is an external for the memPIO interface... + * + * memPIO is a USB-interface with 3 8bit ports + * each port can be either input or output + * (honestly: port3 is divided into 2 subports of 4bits with independent directions, + * however, this is not yet implemented) + * + * + * "mode " : mode can be either 0 (input) or 1 (output) + * "mode ": like above, but set all ports at once to the same value + * "bang": manual polling + * "set ": write values to ports in output-mode + * "set " write the same value to all ports + * + * TODO: currently two [memPIO]s interfere + * + * + * copyleft:forum::für::umläute:2004 +*/ + +#include + +#include "m_pd.h" + + +// IMPORTANT: Adjust this path to your needs +//#import "c:\windows\system\memx.ocx" +#import "c:\winnt\system32\memx.ocx" + +/* do a little help thing */ + +typedef struct memPIO +{ + t_object x_obj; + MEMXLib::_DmeMPIOPtr pio; + int input[3]; + t_outlet *outlet[3]; +} t_memPIO; + +t_class *memPIO_class; + +static void memPIO_help(void) +{ + post("\n\n...mem-PIO for pd" + "\n\n(l) forum::für::umläute 2004\n" + "this software is under the GnuGPL that is provided with these files\n"); + post("usage:"); + post("\t'mode <1|0>': set all ports to writable(1) or readable(0=default)"); + post("\t'mode <1|0> <1|0> <1|0>': set the read/write-mode of the individual ports"); + post("\t'bang': returns the values of all readable ports"); + post("\t'set ': set all writable ports to the 8bit-value"); + post("\t'set ': set writable ports to the corresponding value"); +} + +static void memPIO_bang(t_memPIO*x){ + int port=3; + + x->pio->UpdateCache (); + + while(port--){ + if (!x->input[port]){ + long l=x->pio->CachedPort [port+1]; + outlet_float(x->outlet[port], l); + } + } +} + + +static void memPIO_mode(t_memPIO*x, t_symbol *s, int argc, t_atom*argv){ + MEMXLib::IO dir; + bool out; + + switch(argc){ + default: + error("memPIO: \"mode\" message needs 1 or 3 arguments, have %d", argc); + return; + case 1: + out=(atom_getfloat(argv)>0.f); + dir=(out)?MEMXLib::DirOut:MEMXLib::DirIn; + x->pio->DirPort1 =dir; x->input[0]=out; + x->pio->DirPort2 =dir; x->input[1]=out; + x->pio->DirPort3H=dir; x->input[2]=out; + x->pio->DirPort3L=dir; + break; + case 3: + out=(atom_getfloat(argv+0)>0.f); + x->pio->DirPort1 =(out)?MEMXLib::DirOut:MEMXLib::DirIn; x->input[0]=out; + out=(atom_getfloat(argv+1)>0.f); + x->pio->DirPort2 =(out)?MEMXLib::DirOut:MEMXLib::DirIn; x->input[1]=out; + out=(atom_getfloat(argv+2)>0.f); + x->pio->DirPort3H=(out)?MEMXLib::DirOut:MEMXLib::DirIn; x->input[2]=out; + x->pio->DirPort3L=(out)?MEMXLib::DirOut:MEMXLib::DirIn; + } +} + + +static void memPIO_set(t_memPIO*x, t_symbol*s, int argc, t_atom*argv){ + int port=3; + + char val[4]={0,0,0,0}; + + switch(argc){ + case 1: + val[0]=val[1]=val[2]=val[3]=atom_getfloat(argv); + break; + case 3: + val[0]=atom_getfloat(argv+0); + val[1]=atom_getfloat(argv+1); + val[2]=atom_getfloat(argv+2); + break; + default: + break; + } + + while(port--) + if(x->input[port]){ + x->pio->port[port+1]=val[port]; + } + +} + + +static void memPIO_free(t_memPIO*x) +{ + x->pio.Release (); +} + +void *memPIO_new(void) +{ + int i; + bool found=false; + t_memPIO *x = (t_memPIO *)pd_new(memPIO_class); + // because we use a ActiveX we need to initialize OLE for this app + OleInitialize (NULL); + // try to create the ActiveX-instance + x->pio.CreateInstance (__uuidof(MEMXLib::meMPIO)); + // on error, there is no meM-ActiveX installed + if (x->pio == NULL) + { + error("meM ActiveX not installed!"); + return 0; + } + + found=false; + // search until the highest-possible Card-ID + for(i = 0; i < x->pio->LastAttached; i++) + { + // select a device + x->pio->CardId = i+1; + // if selected device is attached, return + if (x->pio->Attached){ + found=true; + break; + } + } + i++; + if(!found){ + memPIO_free(x); + return 0; + } + + /* these are all outputs */ + for (int n=0; n<3; n++) { + x->outlet[n] = outlet_new(&x->x_obj, 0); + x->input[n]=0; + } + + return (void *)x; +} + +void memPIO_setup(void) +{ + post("\t the memPIO external"); + post("\t (l) forum::für::umläute"); + post("\t compiled: "__DATE__""); + + memPIO_class = class_new(gensym("memPIO"), + (t_newmethod)memPIO_new, + (t_method)memPIO_free, + sizeof(t_memPIO), + 0, A_NULL); + class_addmethod(memPIO_class, (t_method)memPIO_help, gensym("help"), A_NULL); + class_addmethod(memPIO_class, (t_method)memPIO_mode, gensym("mode"), A_GIMME, A_NULL); + class_addmethod(memPIO_class, (t_method)memPIO_set, gensym("set"), A_GIMME, A_NULL); + + class_addbang(memPIO_class, (t_method)memPIO_bang); +} diff --git a/memPIO/memPIO.dsp b/memPIO/memPIO.dsp new file mode 100644 index 0000000..50aa524 --- /dev/null +++ b/memPIO/memPIO.dsp @@ -0,0 +1,67 @@ +# Microsoft Developer Studio Project File - Name="memPIO" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** NICHT BEARBEITEN ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=memPIO - WIN32 RELEASE +!MESSAGE Dies ist kein gültiges Makefile. Zum Erstellen dieses Projekts mit NMAKE +!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und führen Sie den Befehl +!MESSAGE +!MESSAGE NMAKE /f "memPIO.mak". +!MESSAGE +!MESSAGE Sie können beim Ausführen von NMAKE eine Konfiguration angeben +!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel: +!MESSAGE +!MESSAGE NMAKE /f "memPIO.mak" CFG="memPIO - WIN32 RELEASE" +!MESSAGE +!MESSAGE Für die Konfiguration stehen zur Auswahl: +!MESSAGE +!MESSAGE "memPIO - Win32 Release" (basierend auf "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 1 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "" +# PROP Intermediate_Dir "obj\" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "memPIO_EXPORTS" /YX /FD /c +# ADD CPP /nologo /MT /W3 /GX /I "..\..\pd\src" /D "WIN32" /D "NT" /D "_WINDOWS" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /win32 +# SUBTRACT MTL /mktyplib203 +# ADD BASE RSC /l 0xc07 /d "NDEBUG" +# ADD RSC /l 0xc07 +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 +# ADD LINK32 pd.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib ole32.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"..\mempio.dll" /libpath:"../../pd/bin" /export:memPIO_setup +# SUBTRACT LINK32 /pdb:none /nodefaultlib +# Begin Target + +# Name "memPIO - Win32 Release" +# Begin Group "Quellcodedateien" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\memPIO.cpp +# End Source File +# End Group +# End Target +# End Project diff --git a/memPIO/memPIO.dsw b/memPIO/memPIO.dsw new file mode 100644 index 0000000..3ef1c58 --- /dev/null +++ b/memPIO/memPIO.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNUNG: DIESE ARBEITSBEREICHSDATEI DARF NICHT BEARBEITET ODER GELÖSCHT WERDEN! + +############################################################################### + +Project: "memPIO"=.\memPIO.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + -- cgit v1.2.1