bindings-sc3 0.3.0 → 0.4.1
raw patch · 7 files changed
+418/−33 lines, 7 files
Files
- Bindings/Sound/SC3.hsc +70/−8
- README.md +28/−4
- bindings-sc3.cabal +20/−21
- include/SC_Export.h +51/−0
- include/SC_Reply.h +58/−0
- include/SC_Types.h +76/−0
- include/SC_WorldOptions.h +115/−0
Bindings/Sound/SC3.hsc view
@@ -5,8 +5,10 @@ #strict_import +-- | Synthesis engine handle. #opaque_t World +-- | Synthesis engine options. #starttype struct WorldOptions #field mPassword , CString #field mNumBuffers , CUInt@@ -44,27 +46,87 @@ #field mSharedMemoryID , CInt #stoptype +-- | Default synthesis engine options. #cinline kDefaultWorldOptions , IO (Ptr <struct WorldOptions>) +-- | Reply address. #opaque_t struct ReplyAddress +-- | Access the callback data pointer in a reply address.+#ccall ReplyAddress_ReplyData , Ptr <ReplyAddress> -> IO (Ptr ())++-- | Reply function callback.+--+-- Arguments:+--+-- * 'Ptr' 'C'ReplyAddress' - Reply address handle+--+-- * 'Ptr' 'CChar' - OSC packet data+--+-- * 'CInt' - OSC packet size in bytes #callback ReplyFunc , Ptr <ReplyAddress> -> Ptr CChar -> CInt -> IO () --- | Access the data pointer in reply address.-#ccall ReplyAddress_ReplyData , Ptr <ReplyAddress> -> IO (Ptr ())+-- | Create a new synthesis engine.+#ccall World_New , Ptr <WorldOptions> -> IO (Ptr <World>) --- | Create a new world.-#ccall World_New , Ptr <WorldOptions> -> IO (Ptr <World>)-#ccall World_Cleanup , Ptr <World> -> IO ()+-- | Free the synthesis engine.+--+-- This function should only be called after 'c'World_WaitForQuit' has returned.+#ccall World_Cleanup , Ptr <World> -> IO ()++-- | Perform non-realtime synthesis with the given 'C'WorldOptions'. #ccall World_NonRealTimeSynthesis , Ptr <World> -> Ptr <WorldOptions> -> IO ()-#ccall World_OpenUDP , Ptr <World> -> CInt -> IO CInt-#ccall World_OpenTCP , Ptr <World> -> CInt -> CInt -> CInt -> IO CInt-#ccall World_WaitForQuit , Ptr <World> -> IO ()++-- | Open a UDP input port for receiving OSC commands.+--+-- Returns non-zero if the call was successful.+#ccall World_OpenUDP , Ptr <World> -> CInt -> IO CInt++-- | Open a TCP input port for receiving OSC commands.+--+-- Returns non-zero if the call was successful.+#ccall World_OpenTCP , Ptr <World> -> CInt -> CInt -> CInt -> IO CInt++-- | Wait for the synthesis engine to quit.+--+-- In order to stop the synthesis engine, send a \"/quit\" OSC message with+-- 'c'World_SendPacket', 'c'World_SendPacketWithContext' or through an open+-- network port.+#ccall World_WaitForQuit , Ptr <World> -> IO ()++-- | Send an OSC packet to the synthesis engine.+--+-- Returns 'True' if the packet was sent successfully.+--+-- Arguments:+--+-- * 'CInt' - OSC packet size in bytes+--+-- * 'Ptr' 'CChar' - OSC packet data+--+-- * 'C'ReplyFunc' - Reply function callback. #ccall World_SendPacket , Ptr <World> -> CInt -> Ptr CChar -> <ReplyFunc> -> IO Bool++-- | Send an OSC packet to the synthesis engine with callback data.+--+-- Returns 'True' if the packet was sent successfully.+--+-- Arguments:+--+-- * 'CInt' - OSC packet size in bytes+--+-- * 'Ptr' 'CChar' - OSC packet data+--+-- * 'C'ReplyFunc' - Reply function callback.+--+-- * 'Ptr' () - Reply function callback data. #ccall World_SendPacketWithContext , Ptr <World> -> CInt -> Ptr CChar -> <ReplyFunc> -> Ptr () -> IO Bool -- | Haskell print function. #callback HaskellPrintFunc , Ptr CChar -> IO () -- | Set the global Haskell print function.+--+-- This function, when set, is called by the synthesis engine to print+-- character strings to an appropriate output channel. #ccall SetHaskellPrintFunc , <HaskellPrintFunc> -> IO ()
README.md view
@@ -1,6 +1,30 @@-**bindings-sc3** is a Haskell library that provides lowlevel bindings to the [SuperCollider][] synthesis engine library `libscsynth`.+**bindings-sc3** is a Haskell library that provides low-level bindings to the [SuperCollider][] synthesis engine library `libscsynth`. -For more information please visit the [website][].+### Installation -[supercollider]: http://supercollider.sourceforge.net-[website]: http://space.k-hornz.de/software/bindings-sc3+Currently, **bindings-sc3** requires [SuperCollider][] to be built from source (at least revision `12838871d99ff72cfa047aa07e1a53ba2b1c8f5b`). See the [SuperCollider development page][sc_development] for information on how to get the sources from the git repository and build SuperCollider (you need to pass `-DLIBSCSYNTH=ON` to `cmake` in order to build the shared library).++#### MacOS X++Assuming the environment variable `SC` points to the SuperCollider source tree, the bindings can then be installed as follows:++ DYLD_LIBRARY_PATH=$SC/server/scsynth \+ cabal install --extra-include-dirs=$SC/include/common \+ --extra-include-dirs=$SC/include/plugin_interface \+ --extra-include-dirs=$SC/include/server \+ --extra-lib-dirs=$SC/server/scsynth/++### Reporting bugs++Please report bugs in our [issue tracker][issues].++### Development++**bindings-sc3**'s source code is hosted at [github][]. You can check out a copy of the repository with the following command:++ git://github.com/kaoskorobase/bindings-sc3.git++[supercollider]: http://supercollider.sourceforge.net/+[sc_development]: http://supercollider.sourceforge.net/developers/+[issues]: https://github.com/kaoskorobase/bindings-sc3/issues/+[github]: https://github.com/kaoskorobase/bindings-sc3/
bindings-sc3.cabal view
@@ -1,29 +1,23 @@ Name: bindings-sc3-Version: 0.3.0-Synopsis: Bindings to the SuperCollider synthesis engine library.+Version: 0.4.1+Synopsis: Low-level bindings to the SuperCollider synthesis engine library. Description:+ DEPRECATED. This library is looking for a new maintainer.+ . This library provides low level bindings to the SuperCollider synthesis engine library (@libscsynth@). If you are looking for a higher level- Haskell interface, please use the hsc3-process package+ Haskell interface, please use the /hsc3-process/ package (<http://hackage.haskell.org/package/hsc3-process>). . ChangeLog: <https://github.com/kaoskorobase/bindings-sc3/blob/master/ChangeLog.md> .- In order to build this package, you need to first build the dynamic library- version of SuperCollider <supercollider.sourceforge.net> by passing- @-DLIBSCSYNTH=ON@ to @cmake@. Then build this library by passing the- location of the SuperCollider header files and dynamic library directory to- cabal:- .- @- cabal install bindings-sc3 \- --extra-include-dirs=$SC_SOURCES/include/common \- --extra-include-dirs=$SC_SOURCES/include/plugin_interface \- --extra-include-dirs=$SC_SOURCES/include/server \- --extra-library-dirs=$SC_SOURCES/server/scsynth- @+ In order to use this package, you need to build the dynamic library version+ of SuperCollider <supercollider.sourceforge.net> by passing+ @-DLIBSCSYNTH=ON@ to @cmake@ and put it in a location where it can be found by the+ linker (e.g. @/usr/local/lib@ on Unix systems, alternatively use the @--extra-lib-dirs@+ flag of @cabal configure@). .- If you copy @libscsynth@ to a system library location, you may omit @--extra-library-dirs@.+ The required SuperCollider version is 3.5. License: GPL License-File: LICENSE Category: FFI, Sound@@ -31,21 +25,26 @@ Author: Stefan Kersten <sk@k-hornz.de> Maintainer: Stefan Kersten <sk@k-hornz.de> Stability: experimental-Homepage: http://space.k-hornz.de/software/bindings-sc3/-Bug-Reports: http://github.com/kaoskorobase/bindings-sc3/issues/-Tested-With: GHC == 6.12+Homepage: https://github.com/kaoskorobase/bindings-sc3/+Bug-Reports: https://github.com/kaoskorobase/bindings-sc3/issues/+Tested-With: GHC == 6.12, GHC == 7.0, GHC == 7.2 Build-Type: Simple Cabal-Version: >= 1.6 Data-Files: README.md+ include/SC_Export.h+ include/SC_Reply.h+ include/SC_Types.h+ include/SC_WorldOptions.h Library Extensions: ForeignFunctionInterface Exposed-Modules: Bindings.Sound.SC3- C-Sources: cbits/helper_functions.c+ C-Sources: cbits/helper_functions.c Build-Depends: base >= 3 && < 5 , bindings-DSL >= 1.0 && < 1.1+ Include-Dirs: ./include Extra-Libraries: scsynth Source-Repository head
+ include/SC_Export.h view
@@ -0,0 +1,51 @@+/*+ SuperCollider real time audio synthesis system+ Copyright (c) 2010 Tim Blechmann. All rights reserved.++ This program is free software; you can redistribute it and/or modify+ it under the terms of the GNU General Public License as published by+ the Free Software Foundation; either version 2 of the License, or+ (at your option) any later version.++ This program is distributed in the hope that it will be useful,+ but WITHOUT ANY WARRANTY; without even the implied warranty of+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ GNU General Public License for more details.++ You should have received a copy of the GNU General Public License+ along with this program; if not, write to the Free Software+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA+*/++#ifndef _SC_EXPORTS_+#define _SC_EXPORTS_++#if defined _WIN32 || defined __CYGWIN__+# define SC_API_IMPORT __declspec(dllimport)+# define SC_API_EXPORT __declspec(dllexport)+#else+# if __GNUC__ >= 4+# define SC_API_IMPORT __attribute__ ((visibility("default")))+# define SC_API_EXPORT __attribute__ ((visibility("default")))+# else+# define SC_API_IMPORT+# define SC_API_EXPORT+# endif+#endif++#ifdef __cplusplus+# define C_LINKAGE extern "C"+#else+# define C_LINKAGE+#endif++#ifdef BUILDING_SUPERCOLLIDER // if SuperCollider is being built, instead of used+# define SC_DLLEXPORT_C C_LINKAGE SC_API_EXPORT+# define SC_DLLEXPORT SC_API_EXPORT+#else+# define SC_DLLEXPORT_C C_LINKAGE SC_API_IMPORT+# define SC_DLLEXPORT SC_API_IMPORT+#endif++#endif+
+ include/SC_Reply.h view
@@ -0,0 +1,58 @@+/*+ SuperCollider real time audio synthesis system+ Copyright (c) 2002 James McCartney. All rights reserved.+ http://www.audiosynth.com++ This program is free software; you can redistribute it and/or modify+ it under the terms of the GNU General Public License as published by+ the Free Software Foundation; either version 2 of the License, or+ (at your option) any later version.++ This program is distributed in the hope that it will be useful,+ but WITHOUT ANY WARRANTY; without even the implied warranty of+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ GNU General Public License for more details.++ You should have received a copy of the GNU General Public License+ along with this program; if not, write to the Free Software+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA+*/+++#ifndef _SC_Reply_+#define _SC_Reply_++#include <stdio.h>+#include <stdlib.h>++#if defined(_WIN32)+# include <winsock2.h>+#else+# include <netinet/in.h>+#endif // _WIN32++struct ReplyAddress;++typedef void (*ReplyFunc)(struct ReplyAddress *inReplyAddr, char* inBuf, int inSize);++void null_reply_func(struct ReplyAddress* addr, char* msg, int size);++struct ReplyAddress+{+ struct sockaddr_in mSockAddr;+ int mSockAddrLen;+ int mSocket;+ ReplyFunc mReplyFunc;+ void *mReplyData;+};++#if defined(__cplusplus)+bool operator==(const ReplyAddress& a, const ReplyAddress& b);+#endif // __cplusplus++inline void SendReply(struct ReplyAddress *inReplyAddr, char* inBuf, int inSize)+{+ (inReplyAddr->mReplyFunc)(inReplyAddr, inBuf, inSize);+}++#endif
+ include/SC_Types.h view
@@ -0,0 +1,76 @@+/*+ SuperCollider real time audio synthesis system+ Copyright (c) 2002 James McCartney. All rights reserved.+ http://www.audiosynth.com++ This program is free software; you can redistribute it and/or modify+ it under the terms of the GNU General Public License as published by+ the Free Software Foundation; either version 2 of the License, or+ (at your option) any later version.++ This program is distributed in the hope that it will be useful,+ but WITHOUT ANY WARRANTY; without even the implied warranty of+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ GNU General Public License for more details.++ You should have received a copy of the GNU General Public License+ along with this program; if not, write to the Free Software+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA+*/++#ifndef _SC_Types_+#define _SC_Types_++#include <sys/types.h>++#if !defined(__cplusplus)+# include <stdbool.h>+#endif // __cplusplus++typedef int SCErr;++#ifdef _WIN32+typedef __int64 int64;+typedef unsigned __int64 uint64;+#else+typedef long long int64;+typedef unsigned long long uint64;+#endif++typedef int int32;+typedef unsigned int uint32;++typedef short int16;+typedef unsigned short uint16;++typedef signed char int8;+typedef unsigned char uint8;++typedef float float32;+typedef double float64;++typedef union {+ uint32 u;+ int32 i;+ float32 f;+} elem32;++typedef union {+ uint64 u;+ int64 i;+ float64 f;+} elem64;++const unsigned int kSCNameLen = 8;+const unsigned int kSCNameByteLen = 8 * sizeof(int32);++#ifdef __GXX_EXPERIMENTAL_CXX0X__+#define sc_typeof_cast(x) (decltype(x))+#elif defined(__GNUC__)+#define sc_typeof_cast(x) (__typeof__(x))+#else+#define sc_typeof_cast(x) /* (typeof(x)) */+#endif++#endif+
+ include/SC_WorldOptions.h view
@@ -0,0 +1,115 @@+/*+ SuperCollider real time audio synthesis system+ Copyright (c) 2002 James McCartney. All rights reserved.+ http://www.audiosynth.com++ This program is free software; you can redistribute it and/or modify+ it under the terms of the GNU General Public License as published by+ the Free Software Foundation; either version 2 of the License, or+ (at your option) any later version.++ This program is distributed in the hope that it will be useful,+ but WITHOUT ANY WARRANTY; without even the implied warranty of+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ GNU General Public License for more details.++ You should have received a copy of the GNU General Public License+ along with this program; if not, write to the Free Software+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA+*/+++#ifndef _SC_WorldOptions_+#define _SC_WorldOptions_++#include <stdarg.h>+#include "SC_Reply.h"+#include "SC_Types.h"+#include "SC_Export.h"++typedef int (*PrintFunc)(const char *format, va_list ap);++struct WorldOptions+{+ const char* mPassword;+ uint32 mNumBuffers;+ uint32 mMaxLogins;+ uint32 mMaxNodes;+ uint32 mMaxGraphDefs;+ uint32 mMaxWireBufs;+ uint32 mNumAudioBusChannels;+ uint32 mNumInputBusChannels;+ uint32 mNumOutputBusChannels;+ uint32 mNumControlBusChannels;+ uint32 mBufLength;+ uint32 mRealTimeMemorySize;++ int mNumSharedControls;+ float *mSharedControls;++ bool mRealTime;+ bool mMemoryLocking;++ const char *mNonRealTimeCmdFilename;+ const char *mNonRealTimeInputFilename;+ const char *mNonRealTimeOutputFilename;+ const char *mNonRealTimeOutputHeaderFormat;+ const char *mNonRealTimeOutputSampleFormat;++ uint32 mPreferredSampleRate;+ uint32 mNumRGens;++ uint32 mPreferredHardwareBufferFrameSize;++ uint32 mLoadGraphDefs;++ const char *mInputStreamsEnabled;+ const char *mOutputStreamsEnabled;+ const char *mInDeviceName;++ int mVerbosity;++ bool mRendezvous;++ const char *mUGensPluginPath;++ const char *mOutDeviceName;++ const char *mRestrictedPath;++ int mSharedMemoryID;+};++const struct WorldOptions kDefaultWorldOptions =+{+ 0,1024,64,1024,1024,64,128,8,8,4096,64,8192, 0,0, 1, 0, 0,0,0,0,0+#if defined(_WIN32)+ ,44100+#else+ ,0+#endif+ ,64, 0, 1+ ,0, 0, 0+ ,0+ ,1+ ,0+ ,0+ ,0+ ,0+};++struct SndBuf;++SC_DLLEXPORT_C void SetPrintFunc(PrintFunc func);+SC_DLLEXPORT_C struct World* World_New(struct WorldOptions *inOptions);+SC_DLLEXPORT_C void World_Cleanup(struct World *inWorld);+SC_DLLEXPORT_C void World_NonRealTimeSynthesis(struct World *inWorld, struct WorldOptions *inOptions);+SC_DLLEXPORT_C int World_OpenUDP(struct World *inWorld, int inPort);+SC_DLLEXPORT_C int World_OpenTCP(struct World *inWorld, int inPort, int inMaxConnections, int inBacklog);+SC_DLLEXPORT_C void World_WaitForQuit(struct World *inWorld);+SC_DLLEXPORT_C bool World_SendPacket(struct World *inWorld, int inSize, char *inData, ReplyFunc inFunc);+SC_DLLEXPORT_C bool World_SendPacketWithContext(struct World *inWorld, int inSize, char *inData, ReplyFunc inFunc, void *inContext);+SC_DLLEXPORT_C int World_CopySndBuf(struct World *world, uint32 index, struct SndBuf *outBuf, bool onlyIfChanged, bool *didChange);+SC_DLLEXPORT_C int scprintf(const char *fmt, ...);++#endif // _SC_WorldOptions_