Wednesday, April 28, 2010

Support VibraSeq patterns in your app!

I've just released a nice step sequencer app for your phone vibrator. It is a lot of fun to play with it and it can also export the "pattern" as a short string. (see the export menu in the app)



Install VibraSeq now:

qrcode

If you want to support VibraSeq patterns in your own call manager / SMS manager app (like ChompSMS, etc...), you only have to let the user to paste VibraSeq patterns into a text box somewhere in your app (around the place where you're letting the user to choose from simple vibrator patterns already).

You can parse and play the VibraSeq patterns very easily. See this example code and build in support now ;)



   //plays the given VibraSeq pattern looped forever
   private void playVibraSeqPattern(String vibraSeqPattern) {
       //parse the VibrsSeq pattern into a long array
       long[] pattern = parseVibraSeqPattern(vibraSeqPattern);
       //get the vibrator instance
       Vibrator vibrator =
            (Vibrator)getSystemService(VIBRATOR_SERVICE);
       //play the pattern in a loop forever
       vibrator.vibrate(pattern, 0);
   }

   //returns the Vibrator.vibrate() compatible long array
   private long[] parseVibraSeqPattern(String vibraSeqPattern)
   {
       try {
           String[] strarr = vibraSeqPattern.split(",");
           int cnt = strarr.length;
           long[] result = new long[cnt];
           for (int a=0;a<cnt;a++) {
               result[a] = Long.parseLong(strarr[a], 16);
           }
           return result;
       } catch (NumberFormatException e) {
           return null;
       }
   }

8 comments:

  1. I have put a message in chompsms forum

    ReplyDelete
  2. A few food samples would be great

    ReplyDelete
  3. it still won't let me use my pattern

    ReplyDelete
  4. Feels amaaazing... ;) the battery starts to get a bit warm too my touch slide

    ReplyDelete
  5. Bring it back to the Market please! It was erased when I wiped my phone, can't find it anymore! :/

    ReplyDelete