Thread: Bit Masking

  1. #1
    Matt Conway bobthebullet990's Avatar
    Join Date
    Nov 2005
    Location
    Cambridge
    Posts
    122

    Bit Masking

    Below is a better description!!!
    Last edited by bobthebullet990; 01-07-2007 at 06:53 PM.
    Many junglists take pride in their belongin to what may be referred to as a globalised drum & bass subculture, as a subculture though, it is not nearly as distinct at gothic or punk!

  2. #2
    Matt Conway bobthebullet990's Avatar
    Join Date
    Nov 2005
    Location
    Cambridge
    Posts
    122
    To put it better...
    Code:
    unsigned int flanged=0;
    short int x=0;
    short int y=0;
    short int inputL, inputR;
    
    inputL=readAudio();
    inputR=readAudio();
    
    flanged = inputL << 16;
    flanged |= inputR;
    x = flanged >> 16;
    y &= flanged;
    
    writeAudio(x);
    writeAudio(y);
    But this is not working! ...there is sound in the right channel output, but zero in the left!
    Many junglists take pride in their belongin to what may be referred to as a globalised drum & bass subculture, as a subculture though, it is not nearly as distinct at gothic or punk!

  3. #3
    Matt Conway bobthebullet990's Avatar
    Join Date
    Nov 2005
    Location
    Cambridge
    Posts
    122
    Ha!!! ...Im being an idiot (probably because i've been staring at my screen for over 10hours now)!!!

    ...why Im trying to extract information and'ing with the variable I don't have a clue!!!! wot was i thinking!!!! ...well... for anyone that would ever want to do this! here is the solution!

    Code:
    short int inputL;
    short int inputR;
    
    unsigned int flanged=0;
    short int x=0;
    short int y=0;
    
    //stuff the two values into the int
    flanged = inputL<<16;
    flanged = inputR | flanged;
    // extract the information
    x = flanged >> 16;
    y = flanged & 0x00000000FFFFFFFF;
    //print result
    printf("L: %5d, R: %5d, x: %5d, y: %5d\n",inputL, inputR, x, y);
    Many junglists take pride in their belongin to what may be referred to as a globalised drum & bass subculture, as a subculture though, it is not nearly as distinct at gothic or punk!

  4. #4
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    You typed twice as many 0's and F's as you should have for that.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. bit value check efficiency
    By George2 in forum C Programming
    Replies: 5
    Last Post: 11-05-2007, 07:59 AM
  2. porting application from 32 bit to 64 bit error
    By gandalf_bar in forum Linux Programming
    Replies: 1
    Last Post: 09-14-2005, 09:20 AM
  3. Bit processing in C
    By eliomancini in forum C Programming
    Replies: 8
    Last Post: 06-07-2005, 10:54 AM
  4. Bit Manipulation Questions
    By CPPNewbie in forum C++ Programming
    Replies: 7
    Last Post: 08-12-2003, 02:17 PM
  5. Array of boolean
    By DMaxJ in forum C++ Programming
    Replies: 11
    Last Post: 10-25-2001, 11:45 PM