Csound Csound-dev Csound-tekno Search About

[Csnd] csoundAPI_examples for racket on osx

Date2014-04-11 17:24
FromMark Millikan
Subject[Csnd] csoundAPI_examples for racket on osx
1. In the cs6ffi.rkt file:

(define-ffi-definer define-csound (ffi-lib "libcsound64"))

the name of the dynamic library < libcsound64> is specific to linux, no?

On osx 10.7.5 it appears to be <libcsnd6> and/or <libcsnd6.6.0>, 

2. example1.rkt executes without error if invoked as:

racket example1.rkt or  gracket example1.rkt 
     -- from the terminal with the pwd set to <path/to/racket/examples>

3. Creating an executable from within DrRacket works and the resulting executable runs ok.

4. Running example1.rkt within DrRacket results in:

Welcome to DrRacket, version 6.0.0.6--2014-04-06(e08ffde1/d) [3m].
Language: racket [custom].
-1
-1

i.e., the two function calls with integer result codes return <generic error>.

Am I stumbling toward enlightenment?




Date2014-04-11 18:35
FromSteven Yi
SubjectRe: [Csnd] csoundAPI_examples for racket on osx
Hi Mark,

I'm somewhat new to Racket and am really using this as a learning
project.  That said, I'm happy to have any suggestions for
improvements for these examples!

I'll answer inline below, thanks!

steven

On Fri, Apr 11, 2014 at 12:24 PM, Mark Millikan  wrote:
> 1. In the cs6ffi.rkt file:
>
> ...
> (define-ffi-definer define-csound (ffi-lib "libcsound64"))
> ...
>
> the name of the dynamic library < libcsound64> is specific to linux, no?
>
> On osx 10.7.5 it appears to be  and/or ,

libcsnd6 and libcsnd6.6.0 are two different libraries from
libcsound64.  One is the native component of the API wrappers in other
languages, the other is the C++ library. libcsound64 should be the
name of the library on Linux and Windows. On OSX, I have this in my
/usr/local/lib:

lrwxr-xr-x  1 stevenyi  admin  68 Aug  3  2013
/usr/local/lib/libcsound64.dylib ->
/Users/stevenyi/Library/Frameworks/CsoundLib64.framework/CsoundLib64

I think this symlink might have been something I had created myself.
I have been working on those examples with things rendering correctly;
if they are not working there, maybe try creating that symlink too?
(but pointing to /Library... instead of ~/Library... if you have
installed using the OSX installer, rather than building yourself).

I'm looking into loading the library from the CsoundLib64.framework
now. I'll reply here once I can get it going.

> 2. example1.rkt executes without error if invoked as:
>
> racket example1.rkt or  gracket example1.rkt
>      -- from the terminal with the pwd set to 

I have been testing from the command-line (well, within vim using
":!racket %"). Good that it is working there for you!

> 3. Creating an executable from within DrRacket works and the resulting
> executable runs ok.

I tested using raco from the commandline and also found it working
with the generated executable.

> 4. Running example1.rkt within DrRacket results in:
>
> Welcome to DrRacket, version 6.0.0.6--2014-04-06(e08ffde1/d) [3m].
> Language: racket [custom].
> -1
> -1
>>
>
> i.e., the two function calls with integer result codes return  error>.
>
> Am I stumbling toward enlightenment?

Hopefully?  I don't use DrRacket myself. I just tried and it works
with example 2 and 3, but I get nothing with example 1.  My guess is
that DrRacket will run the project from some other directory than
where the example files are and that the code in example 1 that loads
the test.csd is not finding the file.  Example 2 and 3 are working as
they run code from strings.  I suspect then that the require statement
is also loading the cs6ffi.rkt file just fine as the loading mechanism
would resolve relative to the file.

I think this is alright then.  You could try modifying example 1 to
use a full path to the test.csd file.



>
>

Date2014-04-11 19:10
FromSteven Yi
SubjectRe: [Csnd] csoundAPI_examples for racket on osx
Update: I tried working on the library loading one way which was a
mess (tried to use with-handlers... that was not fun!).  I did realize
I could just check for the existence of the CsoundLib64.framework.
The startup code is now checking for the framework in
~/Library/Frameworks, then in /Library/Frameworks, then finally
falling back to libcsound64.  This should hopefully work now on all
operating systems. (Change is pushed to Git)

On Fri, Apr 11, 2014 at 1:35 PM, Steven Yi  wrote:
> Hi Mark,
>
> I'm somewhat new to Racket and am really using this as a learning
> project.  That said, I'm happy to have any suggestions for
> improvements for these examples!
>
> I'll answer inline below, thanks!
>
> steven
>
> On Fri, Apr 11, 2014 at 12:24 PM, Mark Millikan  wrote:
>> 1. In the cs6ffi.rkt file:
>>
>> ...
>> (define-ffi-definer define-csound (ffi-lib "libcsound64"))
>> ...
>>
>> the name of the dynamic library < libcsound64> is specific to linux, no?
>>
>> On osx 10.7.5 it appears to be  and/or ,
>
> libcsnd6 and libcsnd6.6.0 are two different libraries from
> libcsound64.  One is the native component of the API wrappers in other
> languages, the other is the C++ library. libcsound64 should be the
> name of the library on Linux and Windows. On OSX, I have this in my
> /usr/local/lib:
>
> lrwxr-xr-x  1 stevenyi  admin  68 Aug  3  2013
> /usr/local/lib/libcsound64.dylib ->
> /Users/stevenyi/Library/Frameworks/CsoundLib64.framework/CsoundLib64
>
> I think this symlink might have been something I had created myself.
> I have been working on those examples with things rendering correctly;
> if they are not working there, maybe try creating that symlink too?
> (but pointing to /Library... instead of ~/Library... if you have
> installed using the OSX installer, rather than building yourself).
>
> I'm looking into loading the library from the CsoundLib64.framework
> now. I'll reply here once I can get it going.
>
>> 2. example1.rkt executes without error if invoked as:
>>
>> racket example1.rkt or  gracket example1.rkt
>>      -- from the terminal with the pwd set to 
>
> I have been testing from the command-line (well, within vim using
> ":!racket %"). Good that it is working there for you!
>
>> 3. Creating an executable from within DrRacket works and the resulting
>> executable runs ok.
>
> I tested using raco from the commandline and also found it working
> with the generated executable.
>
>> 4. Running example1.rkt within DrRacket results in:
>>
>> Welcome to DrRacket, version 6.0.0.6--2014-04-06(e08ffde1/d) [3m].
>> Language: racket [custom].
>> -1
>> -1
>>>
>>
>> i.e., the two function calls with integer result codes return > error>.
>>
>> Am I stumbling toward enlightenment?
>
> Hopefully?  I don't use DrRacket myself. I just tried and it works
> with example 2 and 3, but I get nothing with example 1.  My guess is
> that DrRacket will run the project from some other directory than
> where the example files are and that the code in example 1 that loads
> the test.csd is not finding the file.  Example 2 and 3 are working as
> they run code from strings.  I suspect then that the require statement
> is also loading the cs6ffi.rkt file just fine as the loading mechanism
> would resolve relative to the file.
>
> I think this is alright then.  You could try modifying example 1 to
> use a full path to the test.csd file.
>
>
>
>>
>>