⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 effect_position.c

📁 SDL_mixer 是一个基于 SDL 的混音器
💻 C
📖 第 1 页 / 共 4 页
字号:
			break;		case 270:        		*(ptr++) = (Sint16) SDL_SwapLE16(swaplr);        		*(ptr++) = (Sint16) SDL_SwapLE16(swapl);        		*(ptr++) = (Sint16) SDL_SwapLE16(swaprr);        		*(ptr++) = (Sint16) SDL_SwapLE16(swapr);			break;	}    }}static void _Eff_position_s16lsb_c6(int chan, void *stream, int len, void *udata){    /* 16 signed bits (lsb) * 6 channels. */    volatile position_args *args = (volatile position_args *) udata;    Sint16 *ptr = (Sint16 *) stream;    int i;    for (i = 0; i < len; i += sizeof (Sint16) * 6) {        Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+0))) *                                    args->left_f) * args->distance_f);        Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+1))) *                                    args->right_f) * args->distance_f);        Sint16 swaplr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+2))) *                                    args->left_rear_f) * args->distance_f);        Sint16 swaprr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+3))) *                                    args->right_rear_f) * args->distance_f);        Sint16 swapce = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+4))) *                                    args->center_f) * args->distance_f);        Sint16 swapwf = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+5))) *                                    args->lfe_f) * args->distance_f);	switch (args->room_angle) {		case 0:        		*(ptr++) = (Sint16) SDL_SwapLE16(swapl);        		*(ptr++) = (Sint16) SDL_SwapLE16(swapr);        		*(ptr++) = (Sint16) SDL_SwapLE16(swaplr);        		*(ptr++) = (Sint16) SDL_SwapLE16(swaprr);        		*(ptr++) = (Sint16) SDL_SwapLE16(swapce);        		*(ptr++) = (Sint16) SDL_SwapLE16(swapwf);			break;		case 90:        		*(ptr++) = (Sint16) SDL_SwapLE16(swapr);        		*(ptr++) = (Sint16) SDL_SwapLE16(swaprr);        		*(ptr++) = (Sint16) SDL_SwapLE16(swapl);        		*(ptr++) = (Sint16) SDL_SwapLE16(swaplr);        		*(ptr++) = (Sint16) SDL_SwapLE16(swapr)/2 + (Sint16) SDL_SwapLE16(swaprr)/2;        		*(ptr++) = (Sint16) SDL_SwapLE16(swapwf);			break;		case 180:        		*(ptr++) = (Sint16) SDL_SwapLE16(swaprr);        		*(ptr++) = (Sint16) SDL_SwapLE16(swaplr);        		*(ptr++) = (Sint16) SDL_SwapLE16(swapr);        		*(ptr++) = (Sint16) SDL_SwapLE16(swapl);        		*(ptr++) = (Sint16) SDL_SwapLE16(swaprr)/2 + (Sint16) SDL_SwapLE16(swaplr)/2;        		*(ptr++) = (Sint16) SDL_SwapLE16(swapwf);			break;		case 270:        		*(ptr++) = (Sint16) SDL_SwapLE16(swaplr);        		*(ptr++) = (Sint16) SDL_SwapLE16(swapl);        		*(ptr++) = (Sint16) SDL_SwapLE16(swaprr);        		*(ptr++) = (Sint16) SDL_SwapLE16(swapr);        		*(ptr++) = (Sint16) SDL_SwapLE16(swapl)/2 + (Sint16) SDL_SwapLE16(swaplr)/2;        		*(ptr++) = (Sint16) SDL_SwapLE16(swapwf);			break;	}    }}static void _Eff_position_u16msb(int chan, void *stream, int len, void *udata){    /* 16 signed bits (lsb) * 2 channels. */    volatile position_args *args = (volatile position_args *) udata;    Uint16 *ptr = (Uint16 *) stream;    int i;    for (i = 0; i < len; i += sizeof (Sint16) * 2) {        Sint16 sampl = (Sint16) (SDL_SwapBE16(*(ptr+0)) - 32768);        Sint16 sampr = (Sint16) (SDL_SwapBE16(*(ptr+1)) - 32768);                Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f)                                    * args->distance_f) + 32768);        Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f)                                    * args->distance_f) + 32768);	if (args->room_angle == 180) {        	*(ptr++) = (Uint16) SDL_SwapBE16(swapr);        	*(ptr++) = (Uint16) SDL_SwapBE16(swapl);	}	else {        	*(ptr++) = (Uint16) SDL_SwapBE16(swapl);        	*(ptr++) = (Uint16) SDL_SwapBE16(swapr);	}    }}static void _Eff_position_u16msb_c4(int chan, void *stream, int len, void *udata){    /* 16 signed bits (lsb) * 4 channels. */    volatile position_args *args = (volatile position_args *) udata;    Uint16 *ptr = (Uint16 *) stream;    int i;    for (i = 0; i < len; i += sizeof (Sint16) * 4) {        Sint16 sampl = (Sint16) (SDL_SwapBE16(*(ptr+0)) - 32768);        Sint16 sampr = (Sint16) (SDL_SwapBE16(*(ptr+1)) - 32768);        Sint16 samplr = (Sint16) (SDL_SwapBE16(*(ptr+2)) - 32768);        Sint16 samprr = (Sint16) (SDL_SwapBE16(*(ptr+3)) - 32768);                Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f)                                    * args->distance_f) + 32768);        Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f)                                    * args->distance_f) + 32768);        Uint16 swaplr = (Uint16) ((Sint16) (((float) samplr * args->left_rear_f)                                    * args->distance_f) + 32768);        Uint16 swaprr = (Uint16) ((Sint16) (((float) samprr * args->right_rear_f)                                    * args->distance_f) + 32768);	switch (args->room_angle) {		case 0:        		*(ptr++) = (Uint16) SDL_SwapBE16(swapl);        		*(ptr++) = (Uint16) SDL_SwapBE16(swapr);        		*(ptr++) = (Uint16) SDL_SwapBE16(swaplr);        		*(ptr++) = (Uint16) SDL_SwapBE16(swaprr);			break;		case 90:        		*(ptr++) = (Uint16) SDL_SwapBE16(swapr);        		*(ptr++) = (Uint16) SDL_SwapBE16(swaprr);        		*(ptr++) = (Uint16) SDL_SwapBE16(swapl);        		*(ptr++) = (Uint16) SDL_SwapBE16(swaplr);			break;		case 180:        		*(ptr++) = (Uint16) SDL_SwapBE16(swaprr);        		*(ptr++) = (Uint16) SDL_SwapBE16(swaplr);        		*(ptr++) = (Uint16) SDL_SwapBE16(swapr);        		*(ptr++) = (Uint16) SDL_SwapBE16(swapl);			break;		case 270:        		*(ptr++) = (Uint16) SDL_SwapBE16(swaplr);        		*(ptr++) = (Uint16) SDL_SwapBE16(swapl);        		*(ptr++) = (Uint16) SDL_SwapBE16(swaprr);        		*(ptr++) = (Uint16) SDL_SwapBE16(swapr);			break;	}    }}static void _Eff_position_u16msb_c6(int chan, void *stream, int len, void *udata){    /* 16 signed bits (lsb) * 6 channels. */    volatile position_args *args = (volatile position_args *) udata;    Uint16 *ptr = (Uint16 *) stream;    int i;    for (i = 0; i < len; i += sizeof (Sint16) * 6) {        Sint16 sampl = (Sint16) (SDL_SwapBE16(*(ptr+0)) - 32768);        Sint16 sampr = (Sint16) (SDL_SwapBE16(*(ptr+1)) - 32768);        Sint16 samplr = (Sint16) (SDL_SwapBE16(*(ptr+2)) - 32768);        Sint16 samprr = (Sint16) (SDL_SwapBE16(*(ptr+3)) - 32768);        Sint16 sampce = (Sint16) (SDL_SwapBE16(*(ptr+4)) - 32768);        Sint16 sampwf = (Sint16) (SDL_SwapBE16(*(ptr+5)) - 32768);                Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f)                                    * args->distance_f) + 32768);        Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f)                                    * args->distance_f) + 32768);        Uint16 swaplr = (Uint16) ((Sint16) (((float) samplr * args->left_rear_f)                                    * args->distance_f) + 32768);        Uint16 swaprr = (Uint16) ((Sint16) (((float) samprr * args->right_rear_f)                                    * args->distance_f) + 32768);        Uint16 swapce = (Uint16) ((Sint16) (((float) sampce * args->center_f)                                    * args->distance_f) + 32768);        Uint16 swapwf = (Uint16) ((Sint16) (((float) sampwf * args->lfe_f)                                    * args->distance_f) + 32768);	switch (args->room_angle) {		case 0:        		*(ptr++) = (Uint16) SDL_SwapBE16(swapl);        		*(ptr++) = (Uint16) SDL_SwapBE16(swapr);        		*(ptr++) = (Uint16) SDL_SwapBE16(swaplr);        		*(ptr++) = (Uint16) SDL_SwapBE16(swaprr);        		*(ptr++) = (Uint16) SDL_SwapBE16(swapce);        		*(ptr++) = (Uint16) SDL_SwapBE16(swapwf);			break;		case 90:        		*(ptr++) = (Uint16) SDL_SwapBE16(swapr);        		*(ptr++) = (Uint16) SDL_SwapBE16(swaprr);        		*(ptr++) = (Uint16) SDL_SwapBE16(swapl);        		*(ptr++) = (Uint16) SDL_SwapBE16(swaplr);        		*(ptr++) = (Uint16) SDL_SwapBE16(swapr)/2 + (Uint16) SDL_SwapBE16(swaprr)/2;        		*(ptr++) = (Uint16) SDL_SwapBE16(swapwf);			break;		case 180:        		*(ptr++) = (Uint16) SDL_SwapBE16(swaprr);        		*(ptr++) = (Uint16) SDL_SwapBE16(swaplr);        		*(ptr++) = (Uint16) SDL_SwapBE16(swapr);        		*(ptr++) = (Uint16) SDL_SwapBE16(swapl);        		*(ptr++) = (Uint16) SDL_SwapBE16(swaprr)/2 + (Uint16) SDL_SwapBE16(swaplr)/2;        		*(ptr++) = (Uint16) SDL_SwapBE16(swapwf);			break;		case 270:        		*(ptr++) = (Uint16) SDL_SwapBE16(swaplr);        		*(ptr++) = (Uint16) SDL_SwapBE16(swapl);        		*(ptr++) = (Uint16) SDL_SwapBE16(swaprr);        		*(ptr++) = (Uint16) SDL_SwapBE16(swapr);        		*(ptr++) = (Uint16) SDL_SwapBE16(swapl)/2 + (Uint16) SDL_SwapBE16(swaplr)/2;        		*(ptr++) = (Uint16) SDL_SwapBE16(swapwf);			break;	}    }}static void _Eff_position_s16msb(int chan, void *stream, int len, void *udata){    /* 16 signed bits (lsb) * 2 channels. */    volatile position_args *args = (volatile position_args *) udata;    Sint16 *ptr = (Sint16 *) stream;    int i;    for (i = 0; i < len; i += sizeof (Sint16) * 2) {        Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+0))) *                                    args->left_f) * args->distance_f);        Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+1))) *                                    args->right_f) * args->distance_f);        *(ptr++) = (Sint16) SDL_SwapBE16(swapl);        *(ptr++) = (Sint16) SDL_SwapBE16(swapr);    }}static void _Eff_position_s16msb_c4(int chan, void *stream, int len, void *udata){    /* 16 signed bits (lsb) * 4 channels. */    volatile position_args *args = (volatile position_args *) udata;    Sint16 *ptr = (Sint16 *) stream;    int i;    for (i = 0; i < len; i += sizeof (Sint16) * 4) {        Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+0))) *                                    args->left_f) * args->distance_f);        Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+1))) *                                    args->right_f) * args->distance_f);        Sint16 swaplr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+2))) *                                    args->left_rear_f) * args->distance_f);        Sint16 swaprr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+3))) *                                    args->right_rear_f) * args->distance_f);	switch (args->room_angle) {		case 0:        		*(ptr++) = (Sint16) SDL_SwapBE16(swapl);        		*(ptr++) = (Sint16) SDL_SwapBE16(swapr);        		*(ptr++) = (Sint16) SDL_SwapBE16(swaplr);        		*(ptr++) = (Sint16) SDL_SwapBE16(swaprr);			break;		case 90:        		*(ptr++) = (Sint16) SDL_SwapBE16(swapr);        		*(ptr++) = (Sint16) SDL_SwapBE16(swaprr);        		*(ptr++) = (Sint16) SDL_SwapBE16(swapl);        		*(ptr++) = (Sint16) SDL_SwapBE16(swaplr);			break;		case 180:        		*(ptr++) = (Sint16) SDL_SwapBE16(swaprr);        		*(ptr++) = (Sint16) SDL_SwapBE16(swaplr);        		*(ptr++) = (Sint16) SDL_SwapBE16(swapr);        		*(ptr++) = (Sint16) SDL_SwapBE16(swapl);			break;		case 270:        		*(ptr++) = (Sint16) SDL_SwapBE16(swaplr);        		*(ptr++) = (Sint16) SDL_SwapBE16(swapl);        		*(ptr++) = (Sint16) SDL_SwapBE16(swaprr);        		*(ptr++) = (Sint16) SDL_SwapBE16(swapr);			break;	}    }}static void _Eff_position_s16msb_c6(int chan, void *stream, int len, void *udata){    /* 16 signed bits (lsb) * 6 channels. */    volatile position_args *args = (volatile position_args *) udata;    Sint16 *ptr = (Sint16 *) stream;    int i;    for (i = 0; i < len; i += sizeof (Sint16) * 6) {        Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+0))) *                                    args->left_f) * args->distance_f);        Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+1))) *                                    args->right_f) * args->distance_f);        Sint16 swaplr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+2))) *                                    args->left_rear_f) * args->distance_f);        Sint16 swaprr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+3))) *                                    args->right_rear_f) * args->distance_f);        Sint16 swapce = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+4))) *                                    args->center_f) * args->distance_f);        Sint16 swapwf = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+5))) *                                    args->lfe_f) * args->distance_f);	switch (args->room_angle) {		case 0:        		*(ptr++) = (Sint16) SDL_SwapBE16(swapl);        		*(ptr++) = (Sint16) SDL_SwapBE16(swapr);        		*(ptr++) = (Sint16) SDL_SwapBE16(swaplr);        		*(ptr++) = (Sint16) SDL_SwapBE16(swaprr);        		*(ptr++) = (Sint16) SDL_SwapBE16(swapce);        		*(ptr++) = (Sint16) SDL_SwapBE16(swapwf);			break;		case 90:        		*(ptr++) = (Sint16) SDL_SwapBE16(swapr);        		*(ptr++) = (Sint16) SDL_SwapBE16(swaprr);        		*(ptr++) = (Sint16) SDL_SwapBE16(swapl);        		*(ptr++) = (Sint16) SDL_SwapBE16(swaplr);        		*(ptr++) = (Sint16) SDL_SwapBE16(swapr)/2 + (Sint16) SDL_SwapBE16(swaprr)/2;        		*(ptr++) = (Sint16) SDL_SwapBE16(swapwf);			break;		case 180:        		*(ptr++) = (Sint16) SDL_SwapBE16(swaprr);        		*(ptr++) = (Sint16) SDL_SwapBE16(swaplr);        		*(ptr++) = (Sint16) SDL_SwapBE16(swapr);        		*(ptr++) = (Sint16) SDL_SwapBE16(swapl);        		*(ptr++) = (Sint16) SDL_SwapBE16(swaprr)/2 + (Sint16) SDL_SwapBE16(swaplr)/2;        		*(ptr++) = (Sint16) SDL_SwapBE16(swapwf);			break;		case 270:        		*(ptr++) = (Sint16) SDL_SwapBE16(swaplr);        		*(ptr++) = (Sint16) SDL_SwapBE16(swapl);        		*(ptr++) = (Sint16) SDL_SwapBE16(swaprr);        		*(ptr++) = (Sint16) SDL_SwapBE16(swapr);        		*(ptr++) = (Sint16) SDL_SwapBE16(swapl)/2 + (Sint16) SDL_SwapBE16(swaplr)/2;        		*(ptr++) = (Sint16) SDL_SwapBE16(swapwf);			break;	}    }}static void init_position_args(position_args *args){    memset(args, '\0', sizeof (position_args));    args->in_use = 0;    args->room_angle = 0;    args->left_u8 = args->right_u8 = args->distance_u8 = 255;    args->left_f  = args->right_f  = args->distance_f  = 1.0f;    args->left_rear_u8 = args->right_rear_u8 = args->center_u8 = args->lfe_u8 = 255;    args->left_rear_f = args->right_rear_f = args->center_f = args->lfe_f = 1.0f;    Mix_QuerySpec(NULL, NULL, (int *) &args->channels);}static position_args *get_position_arg(int channel){    void *rc;    int i;    if (channel < 0) {        if (pos_args_global == NULL) {            pos_args_global = malloc(sizeof (position_args));            if (pos_args_global == NULL) {                Mix_SetError("Out of memory");                return(NULL);            }            init_position_args(pos_args_global);        }        return(pos_args_global);    }    if (channel >= position_channels) {        rc = realloc(pos_args_array, (channel + 1) * sizeof (position_args *));        if (rc == NULL) {            Mix_SetError("Out of memory");            return(NULL);        }        pos_args_array = (position_args **) rc;        for (i = position_channels; i <= channel; i++) {            pos_args_array[i] = NULL;        }        position_channels = channel + 1;    }    if (pos_args_array[channel] == NULL) {        pos_args_array[channel] = (position_args *)malloc(sizeof(position_args));        if (pos_args_array[channel] == NULL) {            Mix_SetError("Out of memory");            return(NULL);        }        init_position_args(pos_args_array[channel]);    }    return(pos_args_array[channel]);}static Mix_EffectFunc_t get_position_effect_func(Uint16 format, int channels){    Mix_EffectFunc_t f = NULL;    switch (format) {        case AUDIO_U8:	    switch (channels) {		    case 1:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -