 
 			shiftUV[k + 0] = (uint16_t)(l & mask);
 			shiftUV[k + 1] = (uint16_t)(r & mask);
-			
+
 			l >>= shift;
 			r >>= shift;
 

	{
		/* Conventional separated stereo. */

/*		printf("\n\n---------NEW---------\n\nNumber of Samples: %d\n", numSamples);

		for (int i = 0; i < 10; i++){
			printf("%x\t\t%d\t\t%d\t\t\t%d\t\t%d\n", ip + stride*i, ip[0], ip[1], u[i], v[i]);
		}

		printf("\n\n---------AFTER---------\n\n");*/
		
/*		int32_t *d_u, *d_v;
		int16_t *d_ip;

		cudaMalloc(&d_u, numSamples * sizeof(int32_t));
		cudaMalloc(&d_v, numSamples * sizeof(int32_t));
//		cudaMalloc(&d_ip, numSamples * sizeof(int16_t));

		cudaMemcpy(d_u, u, numSamples * sizeof(int32_t), cudaMemcpyHostToDevice);
		cudaMemcpy(d_v, v, numSamples * sizeof(int32_t), cudaMemcpyHostToDevice);
//		cudaMemcpy(d_ip, ip, numSamples * sizeof(int16_t), cudaMemcpyHostToDevice);

		int rem = (numSamples / SIZE) + 1;

		gpu_mix16<<< rem, SIZE>>>(ip, stride, d_u, d_v, numSamples);

		cudaMemcpy(u, d_u, numSamples * sizeof(int32_t), cudaMemcpyDeviceToHost);
		cudaMemcpy(v, d_v, numSamples * sizeof(int32_t), cudaMemcpyDeviceToHost);
//		cudaMemcpy(ip, d_ip, numSamples * sizeof(int16_t), cudaMemcpyDeviceToHost);

		ip += stride * numSamples ;

		for (int i = 0; i < 10; i++){
			printf("%x\t\t%d\t\t%d\t\t\t%d\t\t%d\n", ip + stride*i, ip[0], ip[1], u[i], v[i]);
		}


		cudaFree(d_u);
		cudaFree(d_v);
		cudaFree(d_ip);*/

/*		printf("\n\n---------NEW---------\n\nNumber of Samples: %d\n", numSamples);

		for (int i = 0; i < 10; i++){
			printf("%x\t\t%d\t\t%d\t\t\t%d\t\t%d\n", ip + stride*i, ip[0], ip[1], u[i], v[i]);
		}

		printf("\n\n---------AFTER---------\n\n");*/
		int16_t *dip = (int16_t *)malloc(numSamples * sizeof(int16_t) * 2);
		memcpy(dip, ip, numSamples * sizeof(int16_t));
		printf("%x \t\t %x \t\t %d \t\t %d \n", ip, ip + 2, ip[0], (ip + 2)[0]);
		printf("%x \t\t %x \t\t %d \t\t %d \n\n", dip, dip + 2, dip[0], (dip + 2)[0]);
		free(dip);
		for ( j = 0; j < numSamples; j++ )
		{
			u[j] = (int32_t) ip[0];
			v[j] = (int32_t) ip[1];
			ip += stride;
		}


/*		for (int i = 0; i < 10; i++){
			printf("%x\t\t%d\t\t%d\t\t\t%d\t\t%d\n", ip + stride*i, ip[0], ip[1], u[i], v[i]);
		}*/
	}
}

#include "matrixlib.h"
#include "ALACAudioTypes.h"

#define SIZE 512

// up to 24-bit "offset" macros for the individual bytes of a 20/24-bit word
#if TARGET_RT_BIG_ENDIAN
#define LBYTE	2
#define MBYTE	1
#define HBYTE	0
#else
#define LBYTE	0
#define MBYTE	1
#define HBYTE	2
#endif

/*
There is no plain middle-side option; instead there are various mixing
modes including middle-side, each lossless, as embodied in the mix()
and unmix() functions.  These functions exploit a generalized middle-side
transformation:

u := [(rL + (m-r)R)/m];
v := L - R;

where [ ] denotes integer floor.  The (lossless) inverse is

L = u + v - [rV/m];
R = L - v;
*/

// 16-bit routines

__global__ void gpu_mix16(int16_t * ip, uint32_t stride, int32_t * u, int32_t * v, int32_t numSamples)
{
	int z = threadIdx.x + blockIdx.x * blockDim.x;
	if (z < numSamples)
	{
		ip += stride * z;
