0

i have a huge file of hexadecimal numbers, from a wav file I opened in a hex editor. Is there a code (i'm using processing) to turn a string of these numbers into a cmyk reference?

My tutor mentioned perhaps writing a code that takes every 4 or so numbers from the hex editor and turns them into a cmyk reference. (i could do this manually but it would take years) I'm somewhat inexperienced with processing so would appreciate the help!

edit: i'm currently taking 8 digit blocks from the editor and putting it into the code to turn it into a colour. Processing then produces a coloured square. I hope to find a code to automate processing to process more than 8 at a time, as i'm doing this for an entire wav file opened in the editor.

1 Answers1

0

In plain Processing you can use unhex() to turn your string into an int, after which you can use str() to turn the int into a String character. Java can do this more efficiently, but falling back to plain Java means you won't be able to run your code in non-JVM environments (like on the web)

Mike 'Pomax' Kamermans
  • 49,297
  • 16
  • 112
  • 153
  • okay, so far i have: String hs = "48865966"; int hi = unhex(hs); fill(hi); rect(30, 20, 55, 55); which gives a coloured square. so i'm still taking 8 numbers at a time and pasting them into processing. is it possible to take more (a whole hex file?) and have it output the colours? – Joe Glenister Apr 14 '13 at 12:34
  • you're going to have to update your OP, then, to explain exactly how many bytes per "thing" you expect. Normally you do 2 byte hex->int conversion, if you're using larger hex strings, explain what you think they represent, and I'll update my answer to match. – Mike 'Pomax' Kamermans Apr 14 '13 at 14:57
  • i'd looking for a code to take more numbers and use them in the same process, one that takes numbers at a time to produce more coloured squares. – Joe Glenister Apr 14 '13 at 17:36