Accessing/Assigning data buffer from pointer
-
I am converting a wave file for which my boss gave me the calculations for. I have two PUCHAR buffers alloocated with GLOBALALLOC. One is input buffer which I have loaded from the file, the other is an output buffer which I will store the converted data into. The buffers are defined as follows: PUCHAR m_pbyDemoBuffer; PWORD m_pwOutDemoAudio; I need to convert m_pbyDemoBuffer to 16-bit (PWORD), then perform calculation on it before storing it in m_pwOutDemoAudio. I need to do this by indexing each 16-bit element. My question is, how do I convert the input buffer to PWORD and how would I assign the value (plus whatever calculations I make) of index 0 of m_pbyDemoBuffer to the value of index 0 of m_pwDemoOutAudio? My boss is having me do the following: m_pwDemoOutAudio[0] = m_pbyDemoInBuffer[0] * 128 I think this is wrong because both variables are pointers. Wouldn't the above code assign the "memory address times 128" to m_pwDemoOutAudio? Thanks. Bill Dennis Orlando, FL
-
I am converting a wave file for which my boss gave me the calculations for. I have two PUCHAR buffers alloocated with GLOBALALLOC. One is input buffer which I have loaded from the file, the other is an output buffer which I will store the converted data into. The buffers are defined as follows: PUCHAR m_pbyDemoBuffer; PWORD m_pwOutDemoAudio; I need to convert m_pbyDemoBuffer to 16-bit (PWORD), then perform calculation on it before storing it in m_pwOutDemoAudio. I need to do this by indexing each 16-bit element. My question is, how do I convert the input buffer to PWORD and how would I assign the value (plus whatever calculations I make) of index 0 of m_pbyDemoBuffer to the value of index 0 of m_pwDemoOutAudio? My boss is having me do the following: m_pwDemoOutAudio[0] = m_pbyDemoInBuffer[0] * 128 I think this is wrong because both variables are pointers. Wouldn't the above code assign the "memory address times 128" to m_pwDemoOutAudio? Thanks. Bill Dennis Orlando, FL
billiam904 wrote: Wouldn't the above code assign the "memory address times 128" to m_pwDemoOutAudio? It won't. If the code was
m_pbyDemoInBuffer * 128
, then you'd be correct. m_pbyDemoInBuffer[0] is the same as *(m_pbyDemoInBuffer + 0), so yeah, it does access whatever is pointed to by m_pbyDemoInBuffer. Regards Senthil _____________________________ My Blog | My Articles | WinMacro -
billiam904 wrote: Wouldn't the above code assign the "memory address times 128" to m_pwDemoOutAudio? It won't. If the code was
m_pbyDemoInBuffer * 128
, then you'd be correct. m_pbyDemoInBuffer[0] is the same as *(m_pbyDemoInBuffer + 0), so yeah, it does access whatever is pointed to by m_pbyDemoInBuffer. Regards Senthil _____________________________ My Blog | My Articles | WinMacroThank you. I got it working and you cleared some things up. Bill Dennis Orlando, FL