Thread: String to Hex
View Single Post
Old 07-06-2022, 04:26 PM   #6
procedure
Human being with feelings
 
Join Date: Jun 2022
Posts: 11
Default

Thank you very much.
So this is great I now get 2 arguments that are integers from the following code. (This code is completely ridiculous since I'm converting back and forth from floats and strings and integers over and over but I don't know another way...)

Now I just need to convert integers to HEX. You are a hero if you can code that. That would be amazing Thank you.

---------------------
Code:
oscmatch("/NoteOn/",$'s') ? (
  oscparm(idx,type);
  type=='s' ? (
    #note = null; #velocity = null;//must use #variables

    oscparm(0,'s',#note); //string
    oscparm(1,'s',#velocity); //string

    printf(oscstr);
    printf (" Note: ");
    printf (#note);
    printf (" Velocity: ");
    printf(#velocity);
    printf("\n");

    //OSC Arg 1 - note
    match("%i",#note,intNote); //convert string to integer
    sprintf(#string_out1,"%i",intNote); //convert int to string again! printf only prints strings
    printf("this is intNote: ");
    printf(#string_out1);
    printf("\n");

    //OSC Arg 2 - velocity
    match("%f",#velocity,floatVelocity);//convert string to float
    floatVelocity = floor(floatVelocity);//round float to nearest decimal (will be #.00000)
    sprintf(#strVelocity,"%i",floatVelocity);//converts float to string (but will look like integer without #.00000)
    match("%i",#strVelocity,intVelocity);//convert string to integer
    sprintf(#string_out2,"%i",intVelocity); //convert int to string again! printf only prints strings
    printf("this is intVelocity: ");
    printf(#string_out2);
    printf("\n");
  );
);
--------------------------
And the LOG reads:
Code:
/NoteOn/ Note: 60 Velocity: 48.527893
this is intNote: 60
this is intVelocity: 48

Last edited by procedure; 07-07-2022 at 09:48 AM.
procedure is offline   Reply With Quote