什么是 SDL 中的 &ff Mix_HookMusic文档中的说明

What is &ff in the SDL Mix_HookMusic clarification in documentation

本文关键字:文档 HookMusic 说明 Mix SDL 中的 ff 什么      更新时间:2023-10-16

我正在尝试编写自己的自定义播放函数,当我遇到&ff时,正在查看 SDL Mix_HookMusic函数的文档。这指的是什么?提前谢谢你!

// make a music play function
// it expects udata to be a pointer to an int
void myMusicPlayer(void *udata, Uint8 *stream, int len)
{
    int i, pos=*(int*)udata;
    // fill buffer with...uh...music...
    for(i=0; i<len; i++)
        stream[i]=(i+pos)&ff;
    // set udata for next time
    pos+=len;
    *(int*)udata=pos;
}
...
// use myMusicPlayer for playing...uh...music
int music_pos=0;
Mix_HookMusic(myMusicPlayer, &music_pos);

鉴于ipos都是变量,在这种情况下,所涉及的&似乎是按位和运算符。猜测(但不确定(,ff 可能是一个包含值的变量 0xff 。这意味着这将需要i+pos,检索最低有效的 8 位,并将该值写入stream[i](这在一定程度上是有意义的,因为stream是指向 Uint8 s 的指针,可以公平地假设它是 unsigned char 的 typedef。