Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Converting Hex data to Decimal in WAVE files.

Name: Anonymous 2012-06-09 22:22

Alright so what I'm trying to do is read the data chunks from a .WAV file and convert each chunk to decimal (0 - 65535 was the original range) so that I can manipulate it and use it with my micro controller. Anyway, I'm using fstream and reading the entire contents to a memory block, then unloading the file and transferring data from the memory block to the new file. There only seems to be one problem, the strtol function is not converting the hex data to decimal. I believe it may be because the hex data is being read as ASCII rather than hex values, i.e.  ÷¾ instead of f7be. This is the code I am using to process the data.

for (int i=44; i<dloop; i=i+2)
    {
        // Prepare hex values
        temp[0] = memblock[i+1];
        temp[1] = memblock[i];
        temp[2] = 0;

        // Convert hex to dec
        conv = strtol(temp,&pEnd,16);
        save << temp << " " << conv << "\n";
    }

It outputs the raw hex code then puts a space, then outputs the converted decimal values. This is the output.

ök 0
÷ 0
÷¾ 0
ø+ 0
øT 0

etc
Any suggestions? Also the reversing of the hex bytes before converting is intentional.

Name: Anonymous 2012-06-09 23:50

Wow stop being arseholes, this dude comes in asking for help and none of you comply?
You wonder why we don't get much traffic.
Also I cannot help you as I do not do C related languages, sorry.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List