Output to file: "1200,1300,1220,1220,"... ect.

This is a discussion on Output to file: "1200,1300,1220,1220,"... ect. within the Windows Programming forums, part of the Platform Specific Boards category; Originally Posted by anonytmouse Code: /* Convert 16 bit signed samples to unsigned. */ pSample->left = (SHORT) pSample->left + 32768; ...

  1. #1
    Registered User
    Join Date
    Mar 2006
    Posts
    19
    Quote Originally Posted by anonytmouse
    Code:
     /*   Convert 16 bit signed samples to unsigned. */
    		pSample->left  = (SHORT) pSample->left  + 32768;
    		pSample->right = (SHORT) pSample->right + 32768;
    	}
    
    	return ret;
    }
    This is probably a stupid question but how come the samples have to converted to signed integers, and when i tried running the program and excluding that part of the code, the samples still appear to be unsigned in the output?

    Split from
    Output to file: "1200,1300,1220,1220,"... ect.

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    The type is unsigned so when you inspect the values, they will be unsigned, even without the conversion. However, without the conversion, they will have the wrong values. For example the signed value -1, when treated as an unsigned number will have the value 65535 (USHRT_MAX). The correct converted value however is 32767.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM
  2. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM
  3. what does this mean to you?
    By pkananen in forum C++ Programming
    Replies: 8
    Last Post: 02-04-2002, 02:58 PM
  4. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 01:58 AM
  5. Simple File Creation Algorithm
    By muffin in forum C Programming
    Replies: 13
    Last Post: 08-24-2001, 03:28 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21