@@ -1160,6 +1160,37 @@ chan_unpause(PyObject *self, PyObject *_null)
11601160 Py_RETURN_NONE ;
11611161}
11621162
1163+ static PyObject *
1164+ chan_set_source_location (PyObject * self , PyObject * args )
1165+ {
1166+ int channelnum = pgChannel_AsInt (self );
1167+ Sint16 angle ;
1168+ float angle_f ;
1169+ Uint8 distance ;
1170+ float distance_f ;
1171+ PyThreadState * _save ;
1172+
1173+ if (!PyArg_ParseTuple (args , "ff" , & angle_f , & distance_f ))
1174+ return NULL ;
1175+
1176+ angle = (Sint16 )roundf (fmodf (angle_f , 360 ));
1177+ distance_f = roundf (distance_f );
1178+ if (0 > distance_f || 256 <= distance_f ) {
1179+ return RAISE (PyExc_ValueError ,
1180+ "distance out of range, expected (0, 255)" );
1181+ }
1182+ distance = (Uint8 )distance_f ;
1183+
1184+ MIXER_INIT_CHECK ();
1185+ _save = PyEval_SaveThread ();
1186+ if (!Mix_SetPosition (channelnum , angle , distance )) {
1187+ PyEval_RestoreThread (_save );
1188+ return RAISE (pgExc_SDLError , Mix_GetError ());
1189+ }
1190+ PyEval_RestoreThread (_save );
1191+ Py_RETURN_NONE ;
1192+ }
1193+
11631194static PyObject *
11641195chan_set_volume (PyObject * self , PyObject * args )
11651196{
@@ -1290,6 +1321,8 @@ static PyMethodDef channel_methods[] = {
12901321 {"pause" , (PyCFunction )chan_pause , METH_NOARGS , DOC_MIXER_CHANNEL_PAUSE },
12911322 {"unpause" , (PyCFunction )chan_unpause , METH_NOARGS ,
12921323 DOC_MIXER_CHANNEL_UNPAUSE },
1324+ {"set_source_location" , chan_set_source_location , METH_VARARGS ,
1325+ DOC_MIXER_CHANNEL_SETSOURCELOCATION },
12931326 {"set_volume" , chan_set_volume , METH_VARARGS , DOC_MIXER_CHANNEL_SETVOLUME },
12941327 {"get_volume" , (PyCFunction )chan_get_volume , METH_NOARGS ,
12951328 DOC_MIXER_CHANNEL_GETVOLUME },
0 commit comments