Пример #1
0
static void set_gmem_copy_quad(struct gmem_shadow_t *shadow)
{
	/* set vertex buffer values */
	gmem_copy_quad[1] = uint2float(shadow->height);
	gmem_copy_quad[3] = uint2float(shadow->width);
	gmem_copy_quad[4] = uint2float(shadow->height);
	gmem_copy_quad[9] = uint2float(shadow->width);

	gmem_copy_quad[0] = 0;
	gmem_copy_quad[6] = 0;
	gmem_copy_quad[7] = 0;
	gmem_copy_quad[10] = 0;

	memcpy(shadow->quad_vertices.hostptr, gmem_copy_quad, QUAD_LEN << 2);

	memcpy(shadow->quad_texcoords.hostptr, gmem_copy_texcoord,
		TEXCOORD_LEN << 2);
}
Пример #2
0
/* This routine will be called by the PortAudio engine when audio is needed.
** It may called at interrupt level on some machines so don't do anything
** that could mess up the system like calling malloc() or free().
*/
static int patestCallback( const void *inputBuffer, void *outputBuffer,
                            unsigned long framesPerBuffer,
                            const PaStreamCallbackTimeInfo* timeInfo,
                            PaStreamCallbackFlags statusFlags, 
                            void *userData)
{
    //paTestData *data = (paTestData*)userData;
    struct wav_file *waveData = (struct wav_file*)userData;
    float *out = (float*)outputBuffer;
    unsigned long k;

    (void) timeInfo; /* Prevent unused variable warnings. */
    (void) statusFlags;
    (void) inputBuffer;
    
    unsigned int tempLeft = 0;
    unsigned int tempRight = 0;
    unsigned long int j = 0;

    for( k=0; k<framesPerBuffer; k++ )
    {
        j = waveData->playProgress;
        if((j + 7) < waveData->subChunk3Size)
        {
            tempLeft = waveData->data[j+0] | waveData->data[j+1]<<8 | waveData->data[j+2]<<16 | waveData->data[j+3]<<24;
            tempRight = waveData->data[j+4] | waveData->data[j+5]<<8 | waveData->data[j+6]<<16 | waveData->data[j+7]<<24;
            *out++ = uint2float(tempLeft);
            *out++ = uint2float(tempRight);
            waveData->playProgress += 8;
        }
        else
        {
            *out++ = 0.0;
            *out++ = 0.0;
        }
        
    }
    
    return paContinue;
}
static void set_gmem_copy_quad(struct gmem_shadow_t *shadow)
{
	
	gmem_copy_quad[1] = uint2float(shadow->height);
	gmem_copy_quad[3] = uint2float(shadow->width);
	gmem_copy_quad[4] = uint2float(shadow->height);
	gmem_copy_quad[9] = uint2float(shadow->width);

	gmem_restore_quad[5] = uint2float(shadow->height);
	gmem_restore_quad[7] = uint2float(shadow->width);

	memcpy(shadow->quad_vertices.hostptr, gmem_copy_quad, QUAD_LEN << 2);
	memcpy(shadow->quad_vertices_restore.hostptr, gmem_restore_quad,
		QUAD_RESTORE_LEN << 2);

	memcpy(shadow->quad_texcoords.hostptr, gmem_copy_texcoord,
		TEXCOORD_LEN << 2);
}