Using Loris and CSL via SWIG

Loris is a sound analysis/resynthesis package written by Kelly Fitz that uses the model of time-reassigned bandwidth-enhanced partial lists to allow one flexible resynthesis control and sound morphing. Siren uses the SWIG-generated interface and glue code to create Smalltalk classes with methods for modeling Loris analyzers and partial lists. To get the current Loris release, see http://sourceforge.net/projects/loris

To build it from scratch (not necessary unless you change the C++ code), first declare the shared variable for the interface, then load all the SSI files.

[Siren.Loris defineSharedVariable: #LorisNI
private: false
constant: false
category: 'external'
initializer: nil
attributes: #( #(#package 'Siren'))] d

To import the Loris interface (the SSI files generated by swig), execute the following.

[AMLImporter new
baseDirectoryName: 'Siren7.5/SWIG_Loris/'; "Edit your folder name in here"
namespace: Smalltalk.Siren.Loris ; "put it in its own namespace"
import: 'Loris'] d

Look at the class definition for LorisNIExternalInterface and make certain the DLL or dylib name is right for your platform, and that the path is correct; I paste in the following lines,

#(#libraryFiles #('loris_smalltalk.dylib')) "Edit your DLL name in here"
#(#libraryDirectories #('Siren7.5/SWIG_Loris')) "Edit your folder name in here"
#(#beVirtual false)
#(#optimizationLevel #full))

and accept the change. You might want to file in ./Siren7.5/Loris-freeModule.st

For normal usage, set-up with this
[Siren.Loris.Loris initializeModule] d
[Siren.Loris.LorisNI] i "inspect the interface if you're interested"

Test with this (prints the Loris version string)
[Siren.Loris.Loris version] p

Clean up utilities
Siren.Loris.Loris freeModule
Siren.Loris.LorisNIExternalInterface unloadLibraries
Siren.Loris.LorisNIExternalInterface instanceCount
Siren.LorisSound instanceCount
Siren.LorisSound allInstances

Using the SWIG Interface to CSL

The CREATE Signal Library (CSL) is a C++ framework for building digital audio synthesis and processing applications. Siren uses the SWIG-generated CSL interface and glue code together with CSL.dylib to create CSL object networks (DSP flow graphs) from within Smalltalk.

Get CSL
http://FASTLabInc.com/CSL

The C++ code still has lots of multiple inheritance (i.e., Scalable, Phased, etc.), which makes some problems in the generated (single inheritance) Smalltalk models; I've added some utility messages to UnitGenerator (e.g., setScale: and setOffset:), but these might cause problems if used incorrectly.

To build it from scratch (not necessary unless you change the C++ code), first declare the shared variable for the interface, then load all the SSI files.

[Siren.CSL defineSharedVariable: #CslNI
private: false
constant: false
category: 'external'
initializer: nil
attributes: #( #(#package 'Siren'))] d

[AMLImporter new
baseDirectoryName: 'Siren7.5/SWIG_CSL/'; "Edit your folder name in here"
namespace: Smalltalk.Siren.CSL ;
import: 'CSL']

Look at the class definition for LorisNIExternalInterface and make certain the DLL or dylib name is right for your platform, and that the path is correct.
#(#libraryFiles #('CSL_SWIG_wrap.so'))
#(#libraryDirectories #('Siren7.5/SWIG_CSL')) "Edit your folder name in here"
#(#beVirtual false)
#(#optimizationLevel #full))

To test CSL, try the following,

Set-up
[Siren.CSL.CSL initializeModule] d

First test; print a random number
[Siren.CSL.CSL fRand ] p

Test the logging
[Siren.CSL.CSL logMsg: 'Testing logging from Smalltalk'] d

House-keeping
[Siren.CSL.CslNI] i
Siren.CSL.CSL freeModule
Siren.CSL.CslNIExternalInterface unloadLibraries
Siren.CSL.CslNIExternalInterface instanceCount

The CSL IO classes cache the singleton IO object, so you might have to explicitly flush it from time to time
[Siren.CSL.IO release]