Announcement

Collapse
No announcement yet.

syntax for controlling wiimote LEDs

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • syntax for controlling wiimote LEDs



    I am successfully using Csound to improvise experimental music, using OSCulator and the wiimote+nunchuk. Many thanks for providing this reliable tool! BTW, you are welcome to include my Csound code in your example-set if you like (although it is fairly complex.)


    I would like to control the LEDs from csound but I haven't been able to figure the exact syntax of the OSC message I should be sending to OSCulator. I understand that most people don't use Csound, but I'd like to present you with an example of the code I've written (which does not work.) Perhaps you can tell me what's wrong with what I'm doing.


    The standard command for sending from csound to OSC is:


    OSCsend kwhen, ihost, iport, idestination, itype [, kdata1, kdata2, ...]


    kwhen will be 0, meaning execute this command immediately

    ihost will be an empty string, meaning the host is the same computer as is running csound

    iport is the wiimote's port which is 8000 (the OSCUlator default)

    idestination is a string designating the destination of the message. I think this should be "osculator/wiimote/1" but I'm not sure about this

    itype is a string of letters that tell csound what datatypes to send in the parameters that follow, so if I want to send a string and then a floating point number, I would write "sf".

    then there are parameters, which perhaps would be "led" followed by 15.0 (to set all the LEDs to ON)


    So the entire command might be:


    OSCsend 0, "", 8000, "osculator/wiimote/1", "sf", "led", 15.0


    OR maybe it should be:


    OSCsend 0, "", 8000, "osculator", "ssf", "wiimote/1", "led", 15.0


    OR maybe it should be:


    OSCsend 0, "", 8000, "osculator", "sfsf", "wiimote", 1.0, "led", 15.0


    Or maybe it should be:


    OSCsend 0, "", 8000, "osculator", "sisf", "wiimote", 1, "led", 15.0


    OR maybe it should be:


    OSCsend 0, "", 8000, "osculator/", "sisf", "wiimote/", 1, "/led/", 15.0


    ...OR....OR....


    Any ideas? Is there any way I can see what message osculator is actually receiving, and what part of the message is correct?


    best,

    Lou Cohen


  • #2


    Hi Lou,


    You are no very far from finding the solution.

    Actually you can send any OSC message to OSCulator, and then assign it the event you wish. In your case, an event Wiimote LEDs with a value of Level (value ranging from 0. to 1.) or Numeric (values from 0 to 15).


    So, I would suggest you try something like :


    OSCsend 0, "", 8000, "/wii/led/1", "i", 15
    and attach a "LEDs / Numeric" event.


    or


    OSCsend 0, "", 8000, "/wii/led/1", "f", 0.35
    and attach a "LEDs/Level" event.


    This is the simplest you can get. Note that your OSC message must start with a slash character (/). There is no need to specify any string argument, a float or integer (at your choice / need) will be enough.


    Best,

    Cam

    Comment


    • #3
      Many thanks for your response.

      Unfortunately I don't understand part of your explanation. What do you mean by "attach a "LEDs / Numeric" event?

      best,
      Lou Cohen

      Comment


      • #4
        Sorry that was maybe a shortcut in the thinking.

        I meant send the OSC message I suggested, and once it pops up in OSCulator, use the "Event Type" drop down menu and select LEDs under the Wiimote category. Then in the Value colum use the menu to select Numeric (1) or Level (1) depending on what you want to do.

        More information on Wiimote control events.

        Comment


        • #5
          Camille,

          Thanks again for your help. I did manage to set the LEDs, but the behavior was not reliable. After a certain point, my code stopped changing the LED pattern. This might be a bug in my csound code, or a problem with the wiimote, but I don't yet know enough to be sure. I have inserted a snapshot of the OSCulator window in case this clarifies my questions.

          osculatorsnapshot.jpg

          So I have these questions:
          1. How frequently should I send a message, such as
            Code:
            OSCsend 0, "", 8000, "/wii/led/1", "i", gkpatchGroupID
          2. Do these messages go into an OSCulator buffer or a wiimote buffer? can the buffer overflow? how often are these messages received by the wiimote?
          3. What is the purpose of the "enable" function? The OSCulator manual says:
            This event controls the activation of the Wiimote. It is an equivalent to clicking the “enable” button in the Wiimote drawer.
            BUT there is no "enable" button visible in the wwimote drawer.
          4. Is the "enable" function a toggle? Do I send it exactly once to enable LEDs? or has OSCulator already sent this message, and perhaps I should not send it at all, or should I send it continuously?
          5. If I send the "enable" message like this:
            Code:
            OSCsend 0, "", 8000, "/wii/led/enable", "i", 15
            ...is the syntax correct? what effect will the value of "15" or any other value have?



          again, thanks for all your help.
          -Lou
          Last edited by camille; 10-16-2010, 07:37 PM.

          Comment


          • #6
            Hi Lou,
            1. You can send it whenever you want the led to change on the Wiimote. You don't need to send it again to make it 'sticky'. Think of this as a on/off switch.

            2. When a Wiimote/LEDs event is triggered, it sends some kind of command to the Wiimote. There is nothing really special here, just a request to turn on the LEDs.

            3. The Wiimote/Enable function turns on or off the messages sent by the Wiimote. In the Wiimote drawer, at the top, you have the list of known Wiimotes. On the left of their addresses the checkboxes are used to change the enable state. If the checkbox is unchecked, the Wiimote will globally stop to send messages. If the checkbox is checked the Wiimote will work normally.

            4. The Wiimote/Enable event, like all triggered events in OSCulator is expecting an argument with a value of 1.0 to enable the Wiimote, and 0.0 to disable it (checkbox unchecked). Just send a message with an argument value of 1 (no matter if it is an integer or a float), and that's all that's needed.

            5. The value 15 will be the same as the value 1. Unless you need to control the flow of messages coming from the Wiimote, I don't think you need to use this event. Sending the messages /wii/led/1, /wii/led/2, and /wii/led/3 is just enough to control the LEDs of the Wiimote.



            Best,
            Cam

            Comment


            • #7
              Thanks again! your answers are very helpful. I want to double-check one item.

              In your last note you said:
              "Sending the messages /wii/led/1, /wii/led/2, and /wii/led/3 is just enough to control the LEDs of the Wiimote."

              In my code, I have assumed /wii/led/1 sends messages to wiimote #1, and that the LED configuration is determined by the value which follows this string. For example:

              /wii/led/1, "i", 5 will set this LED pattern: 1010 for wiimote #1.
              /wii/led/1, "i", 8 will set this LED pattern: 0001 for wiimote #1.

              If I am only working with one wiimote, I do not need to send messages such as /wii/led/2 or /wii/led/3.
              Is that correct?

              Also, I discovered that the LED configuration shows low-order binary digit on the left, high-order on the right (crazy! but true!)

              -Lou

              Comment


              • #8
                Originally posted by loucohen View Post
                If I am only working with one wiimote, I do not need to send messages such as /wii/led/2 or /wii/led/3.
                Is that correct?
                Yes, this is correct.

                Originally posted by loucohen View Post
                Also, I discovered that the LED configuration shows low-order binary digit on the left, high-order on the right (crazy! but true!)
                Hey, let's that a typical Osculator idiosyncrasy :-)

                Comment

                Working...
                X