binaryencode question

jbv at jbv at
Mon Dec 7 04:53:42 EST 2020

Hi list,

I have a script that opens a binary file (actually a .wav) file,
converts binary data to hex, do some processing on parts of the
data, and then saves the result as a new .wav file.
I managed to convert the binary data to hex and do the processing,
but now I'm stuck trying to convert hex back to binary using the
binaryencode function, to get a playable .wav file.

Here's the code that works so far :
    put "/sounds/my.wav" into path
    open file path for binary read
    read from file path at 45 for 200
    close file path
    put it into mybin

    put "" into tHex
    put 1 into tCount

    repeat until tCount=155
       put byte tCount of mybin into theByte

       put binarydecode("H*", theByte, tHex) into theNumConversions
       put tHex after theHex
       add 1 to tCount
    end repeat

After processing the content of theHex, I need to save it as a .wav 
I am aware of all the requirements for a .wav header, my only problem is
to convert the whole thing to binary before saving.

Can someone help ?
Thanks in advance.


More information about the use-livecode mailing list