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-10 1:10

>>40
WATCH YOUR PRIVILEGE, MALE PROGRAMMER.

Name: Anonymous 2012-06-10 1:12

>>41
WATCH YOUR PRIVILEGE, MALE PROGRAMMER.

Name: Anonymous 2012-06-10 1:16

>>42
WATCH YOUR PRIVILEGE, MALE PROGRAMMER.

Name: Anonymous 2012-06-10 1:30

>>43
WYPMP

Name: Anonymous 2012-06-10 1:42

WATCH YOUR PRIVILEGE, FEMINIST SPAMMER.

Name: Anonymous 2012-06-10 2:05

NYJMUA

Name: Anonymous 2012-06-10 2:11

>>40
WATCH YOUR PRIVILEGE, FEMALE PROGRAMMER.

Name: Cudder !MhMRSATORI!FBeUS42x4uM+kgp 2012-06-10 8:45

save << temp << " " << conv << "\n";
This is what happens when we teach high-level languages before basic stuff like data representation.

OP needs to learn a whole lot more of the latter first.

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