[chuck-users] Chuck + Snow Leopard??

Jim Menard jim.menard at gmail.com
Mon Sep 14 08:44:26 EDT 2009


Andrew,

On Sun, Sep 13, 2009 at 10:23 PM, Andrew C. Smith
<acsmith at willamette.edu> wrote:
> Hey Jim, thanks (to know you're looking at Snow Leopard as well). What
> did you end up adding to the fork of ChucK? I'm using all the new
> array methods, as well as the FileIO, so did you just use the CVS
> 1.2.1.3-whatever or do you have your own thing going?

You can see http://github.com/jimm/chuck for the details. I call it my
"ChucK hack fork".

I added a few String methods that did not exist or did not work the
way I liked. For example, I implemented String.ch and added
String.substr.

  // "foo".ch(0) returns "f"
  // Note that it returns a string, not an int. Returning an int was useless
  // to me. Now that I've implemented substr, this seems silly. I might switch
  // it back to returning an int.
  <<< "\"foo.ch(0)\" = ", "foo".ch(0) >>>;

  // "foo".ch(0, "abc") returns "abcoo"
  <<< "\"foo.ch(0, \"abc\")\" = ", "foo".ch(0, "abc") >>>;

  // "foo".substr(1) return "oo"
  <<< "\"foo.substr(1)\" = ", "foo".substr(1) >>>;

  // "foobar".substr(3, 2) returns "ba"
  <<< "\"foobar.substr(3, 2)\" = ", "foobar".substr(3, 2) >>>;

  // "foobar".substr(1, -2) returns "ooba"
  <<< "\"foobar.substr(1, -2)\" = ", "foobar".substr(1, -2) >>>;

  // Hmm...it's time to write some unit tests.

This lets me write methods like these in ChucK, without resorting to C
or other tricks:

  // Given a note/octave name string, returns MIDI note number.
  //
  // NOTE: this function requires my hacked version of ChucK which implements
  // string.at and string.substr.
  fun int n(string str) {
      str.lower() => str;
      str.ch(0) => string note_name;
      str.ch(1) => string accidental;

      0 => int offset;
      2 => int octave_str_index;
      if (accidental == "b")
          -1 => offset;
      else if (accidental == "#")
          1 => offset;
      else
          1 => octave_str_index;

      Std.atoi(str.substr(octave_str_index)) => int oct;

      int val;
      if (note_name == "c")
          0 => val;
      else if (note_name == "d")
          2 => val;
      else if (note_name == "e")
          4 => val;
      else if (note_name == "f")
          5 => val;
      else if (note_name == "g")
          7 => val;
      else if (note_name == "a")
          9 => val;
      else if (note_name == "b")
          11 => val;

      return val + offset + (oct + 1) * 12;
  }

  // Given a note/octave name string, returns float frequency. Calls n().
  fun float nf(string str) {
      return Std.mtof(n(str));
  }

I also implemented the File I/O methods. However I have NOT TESTED
THEM. I'm thinking of adding MIDI file I/O so I can play MIDI files
using ChucK to generate the sound.

Jim

>
> Andrew
>
> On Sun, Sep 13, 2009 at 9:49 PM, Jim Menard <jim.menard at gmail.com> wrote:
>> A follow up: advice in another thread suggested I use "-arch i386". I
>> added that to CXX_LINK and FLAGS in makefile.osx, and it worked
>> perfectly.
>>
>> Jim
>>
>> On Fri, Sep 4, 2009 at 1:56 PM, Jim Menard <jim.menard at gmail.com> wrote:
>>> I'm having problems compiling ChucK on SnowLeopard. (I have my own
>>> fork at https://github.com/jimm/chuck/tree where I've added a few
>>> String methods and implemented some File I/O methods.)
>>>
>>> The error---which has nothing to do with my code---is this:
>>>
>>> gcc -D__MACOSX_CORE__ -c -O3 rtmidi.cpp
>>> rtmidi.cpp: In function 'int get_device_name(SInt32, char*, int)':
>>> rtmidi.cpp:295: error: cannot convert 'void**' to 'MIDIObjectRef*' for
>>> argument '2' to 'OSStatus MIDIObjectFindByUniqueID(MIDIUniqueID,
>>> MIDIObjectRef*, MIDIObjectType*)'
>>> ...snip...
>>> make[1]: *** [rtmidi.o] Error 1
>>> make: [osx] Error 2 (ignored)
>>>
>>> The offending line of code:
>>>
>>>    ret = MIDIObjectFindByUniqueID(uniqueid, &object, &type);
>>>
>>> It's saying that object, which is a void, can't be cast to
>>>
>>>
>>> There are a TON of other warnings for this and other files, mainly
>>> around the size of ints vs. longs and casting warnings. I may have
>>> some time to look into this and see if a few header tweaks will help
>>> or not.
>>>
>>> Jim
>>> --
>>> Jim Menard, jimm at io.com, jim.menard at gmail.com
>>> http://www.io.com/~jimm/
>>>
>>
>>
>>
>> --
>> Jim Menard, jimm at io.com, jim.menard at gmail.com
>> http://www.io.com/~jimm/
>> _______________________________________________
>> chuck-users mailing list
>> chuck-users at lists.cs.princeton.edu
>> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>>
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>



-- 
Jim Menard, jimm at io.com, jim.menard at gmail.com
http://www.io.com/~jimm/


More information about the chuck-users mailing list