📄 sdl_mixer.h
字号:
#define MIX_EFFECTSMAXSPEED "MIX_EFFECTSMAXSPEED"/* * These are the internally-defined mixing effects. They use the same API that * effects defined in the application use, but are provided here as a * convenience. Some effects can reduce their quality or use more memory in * the name of speed; to enable this, make sure the environment variable * MIX_EFFECTSMAXSPEED (see above) is defined before you call * Mix_OpenAudio(). *//* Set the panning of a channel. The left and right channels are specified * as integers between 0 and 255, quietest to loudest, respectively. * * Technically, this is just individual volume control for a sample with * two (stereo) channels, so it can be used for more than just panning. * If you want real panning, call it like this: * * Mix_SetPanning(channel, left, 255 - left); * * ...which isn't so hard. * * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and * the panning will be done to the final mixed stream before passing it on * to the audio device. * * This uses the Mix_RegisterEffect() API internally, and returns without * registering the effect function if the audio device is not configured * for stereo output. Setting both (left) and (right) to 255 causes this * effect to be unregistered, since that is the data's normal state. * * returns zero if error (no such channel or Mix_RegisterEffect() fails), * nonzero if panning effect enabled. Note that an audio device in mono * mode is a no-op, but this call will return successful in that case. * Error messages can be retrieved from Mix_GetError(). */extern DECLSPEC int SDLCALL Mix_SetPanning(int channel, Uint8 left, Uint8 right);/* Set the position of a channel. (angle) is an integer from 0 to 360, that * specifies the location of the sound in relation to the listener. (angle) * will be reduced as neccesary (540 becomes 180 degrees, -100 becomes 260). * Angle 0 is due north, and rotates clockwise as the value increases. * For efficiency, the precision of this effect may be limited (angles 1 * through 7 might all produce the same effect, 8 through 15 are equal, etc). * (distance) is an integer between 0 and 255 that specifies the space * between the sound and the listener. The larger the number, the further * away the sound is. Using 255 does not guarantee that the channel will be * culled from the mixing process or be completely silent. For efficiency, * the precision of this effect may be limited (distance 0 through 5 might * all produce the same effect, 6 through 10 are equal, etc). Setting (angle) * and (distance) to 0 unregisters this effect, since the data would be * unchanged. * * If you need more precise positional audio, consider using OpenAL for * spatialized effects instead of SDL_mixer. This is only meant to be a * basic effect for simple "3D" games. * * If the audio device is configured for mono output, then you won't get * any effectiveness from the angle; however, distance attenuation on the * channel will still occur. While this effect will function with stereo * voices, it makes more sense to use voices with only one channel of sound, * so when they are mixed through this effect, the positioning will sound * correct. You can convert them to mono through SDL before giving them to * the mixer in the first place if you like. * * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and * the positioning will be done to the final mixed stream before passing it * on to the audio device. * * This is a convenience wrapper over Mix_SetDistance() and Mix_SetPanning(). * * returns zero if error (no such channel or Mix_RegisterEffect() fails), * nonzero if position effect is enabled. * Error messages can be retrieved from Mix_GetError(). */extern DECLSPEC int SDLCALL Mix_SetPosition(int channel, Sint16 angle, Uint8 distance);/* Set the "distance" of a channel. (distance) is an integer from 0 to 255 * that specifies the location of the sound in relation to the listener. * Distance 0 is overlapping the listener, and 255 is as far away as possible * A distance of 255 does not guarantee silence; in such a case, you might * want to try changing the chunk's volume, or just cull the sample from the * mixing process with Mix_HaltChannel(). * For efficiency, the precision of this effect may be limited (distances 1 * through 7 might all produce the same effect, 8 through 15 are equal, etc). * (distance) is an integer between 0 and 255 that specifies the space * between the sound and the listener. The larger the number, the further * away the sound is. * Setting (distance) to 0 unregisters this effect, since the data would be * unchanged. * If you need more precise positional audio, consider using OpenAL for * spatialized effects instead of SDL_mixer. This is only meant to be a * basic effect for simple "3D" games. * * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and * the distance attenuation will be done to the final mixed stream before * passing it on to the audio device. * * This uses the Mix_RegisterEffect() API internally. * * returns zero if error (no such channel or Mix_RegisterEffect() fails), * nonzero if position effect is enabled. * Error messages can be retrieved from Mix_GetError(). */extern DECLSPEC int SDLCALL Mix_SetDistance(int channel, Uint8 distance);/* * !!! FIXME : Haven't implemented, since the effect goes past the * end of the sound buffer. Will have to think about this. * --ryan. */#if 0/* Causes an echo effect to be mixed into a sound. (echo) is the amount * of echo to mix. 0 is no echo, 255 is infinite (and probably not * what you want). * * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and * the reverbing will be done to the final mixed stream before passing it on * to the audio device. * * This uses the Mix_RegisterEffect() API internally. If you specify an echo * of zero, the effect is unregistered, as the data is already in that state. * * returns zero if error (no such channel or Mix_RegisterEffect() fails), * nonzero if reversing effect is enabled. * Error messages can be retrieved from Mix_GetError(). */extern no_parse_DECLSPEC int SDLCALL Mix_SetReverb(int channel, Uint8 echo);#endif/* Causes a channel to reverse its stereo. This is handy if the user has his * speakers hooked up backwards, or you would like to have a minor bit of * psychedelia in your sound code. :) Calling this function with (flip) * set to non-zero reverses the chunks's usual channels. If (flip) is zero, * the effect is unregistered. * * This uses the Mix_RegisterEffect() API internally, and thus is probably * more CPU intensive than having the user just plug in his speakers * correctly. Mix_SetReverseStereo() returns without registering the effect * function if the audio device is not configured for stereo output. * * If you specify MIX_CHANNEL_POST for (channel), then this the effect is used * on the final mixed stream before sending it on to the audio device (a * posteffect). * * returns zero if error (no such channel or Mix_RegisterEffect() fails), * nonzero if reversing effect is enabled. Note that an audio device in mono * mode is a no-op, but this call will return successful in that case. * Error messages can be retrieved from Mix_GetError(). */extern DECLSPEC int SDLCALL Mix_SetReverseStereo(int channel, int flip);/* end of effects API. --ryan. *//* Reserve the first channels (0 -> n-1) for the application, i.e. don't allocate them dynamically to the next sample if requested with a -1 value below. Returns the number of reserved channels. */extern DECLSPEC int SDLCALL Mix_ReserveChannels(int num);/* Channel grouping functions *//* Attach a tag to a channel. A tag can be assigned to several mixer channels, to form groups of channels. If 'tag' is -1, the tag is removed (actually -1 is the tag used to represent the group of all the channels). Returns true if everything was OK. */extern DECLSPEC int SDLCALL Mix_GroupChannel(int which, int tag);/* Assign several consecutive channels to a group */extern DECLSPEC int SDLCALL Mix_GroupChannels(int from, int to, int tag);/* Finds the first available channel in a group of channels, returning -1 if none are available. */extern DECLSPEC int SDLCALL Mix_GroupAvailable(int tag);/* Returns the number of channels in a group. This is also a subtle way to get the total number of channels when 'tag' is -1 */extern DECLSPEC int SDLCALL Mix_GroupCount(int tag);/* Finds the "oldest" sample playing in a group of channels */extern DECLSPEC int SDLCALL Mix_GroupOldest(int tag);/* Finds the "most recent" (i.e. last) sample playing in a group of channels */extern DECLSPEC int SDLCALL Mix_GroupNewer(int tag);/* Play an audio chunk on a specific channel. If the specified channel is -1, play on the first free channel. If 'loops' is greater than zero, loop the sound that many times. If 'loops' is -1, loop inifinitely (~65000 times). Returns which channel was used to play the sound.*/#define Mix_PlayChannel(channel,chunk,loops) Mix_PlayChannelTimed(channel,chunk,loops,-1)/* The same as above, but the sound is played at most 'ticks' milliseconds */extern DECLSPEC int SDLCALL Mix_PlayChannelTimed(int channel, Mix_Chunk *chunk, int loops, int ticks);extern DECLSPEC int SDLCALL Mix_PlayMusic(Mix_Music *music, int loops);/* Fade in music or a channel over "ms" milliseconds, same semantics as the "Play" functions */extern DECLSPEC int SDLCALL Mix_FadeInMusic(Mix_Music *music, int loops, int ms);extern DECLSPEC int SDLCALL Mix_FadeInMusicPos(Mix_Music *music, int loops, int ms, double position);#define Mix_FadeInChannel(channel,chunk,loops,ms) Mix_FadeInChannelTimed(channel,chunk,loops,ms,-1)extern DECLSPEC int SDLCALL Mix_FadeInChannelTimed(int channel, Mix_Chunk *chunk, int loops, int ms, int ticks);/* Set the volume in the range of 0-128 of a specific channel or chunk. If the specified channel is -1, set volume for all channels. Returns the original volume. If the specified volume is -1, just return the current volume.*/extern DECLSPEC int SDLCALL Mix_Volume(int channel, int volume);extern DECLSPEC int SDLCALL Mix_VolumeChunk(Mix_Chunk *chunk, int volume);extern DECLSPEC int SDLCALL Mix_VolumeMusic(int volume);/* Halt playing of a particular channel */extern DECLSPEC int SDLCALL Mix_HaltChannel(int channel);extern DECLSPEC int SDLCALL Mix_HaltGroup(int tag);extern DECLSPEC int SDLCALL Mix_HaltMusic(void);/* Change the expiration delay for a particular channel. The sample will stop playing after the 'ticks' milliseconds have elapsed, or remove the expiration if 'ticks' is -1*/extern DECLSPEC int SDLCALL Mix_ExpireChannel(int channel, int ticks);/* Halt a channel, fading it out progressively till it's silent The ms parameter indicates the number of milliseconds the fading will take. */extern DECLSPEC int SDLCALL Mix_FadeOutChannel(int which, int ms);extern DECLSPEC int SDLCALL Mix_FadeOutGroup(int tag, int ms);extern DECLSPEC int SDLCALL Mix_FadeOutMusic(int ms);/* Query the fading status of a channel */extern DECLSPEC Mix_Fading SDLCALL Mix_FadingMusic(void);extern DECLSPEC Mix_Fading SDLCALL Mix_FadingChannel(int which);/* Pause/Resume a particular channel */extern DECLSPEC void SDLCALL Mix_Pause(int channel);extern DECLSPEC void SDLCALL Mix_Resume(int channel);extern DECLSPEC int SDLCALL Mix_Paused(int channel);/* Pause/Resume the music stream */extern DECLSPEC void SDLCALL Mix_PauseMusic(void);extern DECLSPEC void SDLCALL Mix_ResumeMusic(void);extern DECLSPEC void SDLCALL Mix_RewindMusic(void);extern DECLSPEC int SDLCALL Mix_PausedMusic(void);/* Set the current position in the music stream. This returns 0 if successful, or -1 if it failed or isn't implemented. This function is only implemented for MOD music formats (set pattern order number) and for OGG music (set position in seconds), at the moment.*/extern DECLSPEC int SDLCALL Mix_SetMusicPosition(double position);/* Check the status of a specific channel. If the specified channel is -1, check all channels.*/extern DECLSPEC int SDLCALL Mix_Playing(int channel);extern DECLSPEC int SDLCALL Mix_PlayingMusic(void);/* Stop music and set external music playback command */extern DECLSPEC int SDLCALL Mix_SetMusicCMD(const char *command);/* Synchro value is set by MikMod from modules while playing */extern DECLSPEC int SDLCALL Mix_SetSynchroValue(int value);extern DECLSPEC int SDLCALL Mix_GetSynchroValue(void);/* Get the Mix_Chunk currently associated with a mixer channel Returns NULL if it's an invalid channel, or there's no chunk associated.*/extern DECLSPEC Mix_Chunk * SDLCALL Mix_GetChunk(int channel);/* Close the mixer, halting all playing audio */extern DECLSPEC void SDLCALL Mix_CloseAudio(void);/* We'll use SDL for reporting errors */#define Mix_SetError SDL_SetError#define Mix_GetError SDL_GetError/* Ends C function definitions when using C++ */#ifdef __cplusplus}#endif#include "close_code.h"#endif /* _SDL_MIXER_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -