From 0e2151f42d9f0f5a4a25cf8bb90316a16a09191d Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Mon, 6 Jan 2003 04:32:24 +0000 Subject: "" svn path=/trunk/; revision=323 --- externals/grill/flext/examples/source/henon.cpp | 121 ++++++++++++++++++++++++ externals/grill/flext/examples/source/henon.cw | Bin 0 -> 101183 bytes externals/grill/flext/examples/source/henon.dsp | 95 +++++++++++++++++++ 3 files changed, 216 insertions(+) create mode 100644 externals/grill/flext/examples/source/henon.cpp create mode 100644 externals/grill/flext/examples/source/henon.cw create mode 100644 externals/grill/flext/examples/source/henon.dsp (limited to 'externals/grill/flext/examples/source') diff --git a/externals/grill/flext/examples/source/henon.cpp b/externals/grill/flext/examples/source/henon.cpp new file mode 100644 index 00000000..39d446eb --- /dev/null +++ b/externals/grill/flext/examples/source/henon.cpp @@ -0,0 +1,121 @@ +/* +flext examples - henon + +Copyright (c) 2003 Thomas Grill (xovo@gmx.net) +For information on usage and redistribution, and for a DISCLAIMER OF ALL +WARRANTIES, see the file, "license.txt," in this distribution. + +------------------------------------------------------------------------- + +This is a simple external featuring the chaotic Henon attractor. + +See also http://improv.sapp.org/doc/examples/synthImprov/henontune/henontune.html +Thanks to David Casal for the pointer! + +*/ + +// IMPORTANT: enable attribute processing (specify before inclusion of flext headers!) +// For clarity, this is done here, but you'd better specify it as a compiler definition +// FLEXT_ATTRIBUTES must be 0 or 1, +#define FLEXT_ATTRIBUTES 1 + + +// include flext header +#include + +// check for appropriate flext version +#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 401) +#error You need at least flext version 0.4.1 +#endif + + +class henon: + public flext_base +{ + FLEXT_HEADER_S(henon,flext_base,Setup) + +public: + // constructor + henon(int argc,const t_atom *argv); + +protected: + void m_bang(); + void m_reset() { x = y = 0; } + + void m_alpha(float a) { alpha = a; } + void m_beta(float b) { beta = b; } + + float alpha,beta; + float x,y; + +private: + static void Setup(t_classid c); + + // method callbacks + FLEXT_CALLBACK(m_reset) + FLEXT_CALLBACK(m_bang) + FLEXT_CALLBACK_F(m_alpha) + FLEXT_CALLBACK_F(m_beta) + + // define attribute callbacks for variables alpha and beta (with GET and SET properties) + FLEXT_ATTRVAR_F(alpha) + FLEXT_ATTRVAR_F(beta) +}; + +// instantiate the class +FLEXT_NEW_V("henon",henon) + + +henon::henon(int argc,const t_atom *argv): + alpha(0),beta(0),x(0),y(0) // initializations +{ + // define inlets + AddInAnything("reset,bang,..."); + AddInFloat("alpha"); + AddInFloat("beta"); + + // define outlets + AddOutFloat(); + + // processing command line + if(argc == 2 && CanbeFloat(argv[0]) && CanbeFloat(argv[1])) { + // two float args + alpha = GetAFloat(argv[0]); + beta = GetAFloat(argv[1]); + } +} + +void henon::Setup(t_classid c) +{ + // register methods + FLEXT_CADDBANG(c,0,m_bang); + FLEXT_CADDMETHOD_(c,0,"reset",m_reset); + + FLEXT_CADDMETHOD(c,1,m_alpha); + FLEXT_CADDMETHOD(c,2,m_beta); + + // register attributes + FLEXT_CADDATTR_VAR1(c,"alpha",alpha); // register attribute "alpha" + FLEXT_CADDATTR_VAR1(c,"beta",beta); // register attribute "beta" +} + +// Trigger output +void henon::m_bang() +{ + float _alpha_ = alpha*1.5f-2.5f; + float _beta_ = beta-0.5f; + + float newx = 1 + _alpha_ * x * x + _beta_ * y; + float newy = x; + x = newx; + y = newy; + + float output = (x + 1.0f)/2.0f; + if(output < 0) + output = 0; + else if(output > 1) + output = 1; + + // output value to outlet + ToOutFloat(0,output); // (0 stands for the outlet index 0) +} diff --git a/externals/grill/flext/examples/source/henon.cw b/externals/grill/flext/examples/source/henon.cw new file mode 100644 index 00000000..cf880938 Binary files /dev/null and b/externals/grill/flext/examples/source/henon.cw differ diff --git a/externals/grill/flext/examples/source/henon.dsp b/externals/grill/flext/examples/source/henon.dsp new file mode 100644 index 00000000..24cbdfcf --- /dev/null +++ b/externals/grill/flext/examples/source/henon.dsp @@ -0,0 +1,95 @@ +# Microsoft Developer Studio Project File - Name="henon" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** NICHT BEARBEITEN ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=henon - Win32 Debug +!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 "henon.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 "henon.mak" CFG="henon - Win32 Debug" +!MESSAGE +!MESSAGE Für die Konfiguration stehen zur Auswahl: +!MESSAGE +!MESSAGE "henon - Win32 Release" (basierend auf "Win32 (x86) Dynamic-Link Library") +!MESSAGE "henon - Win32 Debug" (basierend auf "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "henon" +# PROP Scc_LocalPath "." +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "henon - Win32 Release" + +# 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 "msvc" +# PROP Intermediate_Dir "msvc" +# 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" /YX /FD /c +# ADD CPP /nologo /W3 /O2 /I "..\..\source" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PD" /YX /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0xc07 /d "NDEBUG" +# ADD RSC /l 0xc07 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib /nologo /dll /machine:I386 +# ADD LINK32 kernel32.lib user32.lib pd.lib flext-pdwin.lib /nologo /dll /machine:I386 /out:"../pd-msvc/henon.dll" /libpath:"..\..\pd-msvc" + +!ELSEIF "$(CFG)" == "henon - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "msvc-debug" +# PROP Intermediate_Dir "msvc-debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /ZI /Od /I "..\..\source" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PD" /FR /YX /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0xc07 /d "_DEBUG" +# ADD RSC /l 0xc07 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib pd.lib flext_d-pdwin.lib /nologo /dll /debug /machine:I386 /pdbtype:sept /libpath:"..\..\pd-msvc" + +!ENDIF + +# Begin Target + +# Name "henon - Win32 Release" +# Name "henon - Win32 Debug" +# Begin Source File + +SOURCE=.\henon.cpp +# End Source File +# End Target +# End Project -- cgit v1.2.1