22#ifndef SDL2PP_MIXER_HH
23#define SDL2PP_MIXER_HH
28#include <SDL_stdinc.h>
31#include <SDL2pp/Export.hh>
52 typedef void (*ChannelFinishedHandler)(int);
53 typedef void (*MusicFinishedHandler)();
55 typedef std::function<void(Uint8 *stream,
int len)>
MusicHook;
59 std::unique_ptr<MusicHook> current_music_hook_;
84 Mixer(
int frequency, Uint16 format,
int channels,
int chunksize);
148 int AllocateChannels(
int numchans);
158 int GetNumChannels()
const;
174 int SetVolume(
int channel,
int volume);
188 int GetVolume(
int channel)
const;
211 int PlayChannel(
int channel,
const Chunk& chunk,
int loops = 0);
233 int PlayChannel(
int channel,
const Chunk& chunk,
int loops,
int ticks);
253 int FadeInChannel(
int channel,
const Chunk& chunk,
int loops,
int ms);
277 int FadeInChannel(
int channel,
const Chunk& chunk,
int loops,
int ms,
int ticks);
292 void PauseChannel(
int channel = -1);
302 void ResumeChannel(
int channel = -1);
317 void HaltChannel(
int channel = -1);
330 int ExpireChannel(
int channel,
int ticks);
344 int FadeOutChannel(
int channel,
int ms);
359 void SetChannelFinishedHandler(ChannelFinishedHandler channel_finished);
367 void RemoveChannelFinishedHandler();
388 int IsChannelPlaying(
int channel)
const;
404 int IsChannelPaused(
int channel)
const;
416 Mix_Fading GetChannelFading(
int which)
const;
437 int ReserveChannels(
int num);
452 void GroupChannel(
int which,
int tag);
468 void GroupChannels(
int from,
int to,
int tag);
485 int GetGroupNumChannels(
int tag)
const;
498 int GetGroupAvailableChannel(
int tag)
const;
511 int GetGroupOldestChannel(
int tag)
const;
524 int GetGroupNewestChannel(
int tag)
const;
543 int FadeOutGroup(
int tag,
int ms);
553 void HaltGroup(
int tag);
571 void PlayMusic(
const Music& music,
int loops = -1);
585 void FadeInMusic(
const Music& music,
int loops = -1,
int ms = 0);
612 int SetMusicVolume(
int volume);
622 int GetMusicVolume()
const;
656 void SetMusicPosition(
double position);
682 bool FadeOutMusic(
int ms);
696 void SetMusicFinishedHandler(MusicFinishedHandler music_finished);
704 void RemoveMusicFinishedHandler();
719 bool IsMusicPlaying()
const;
729 bool IsMusicPaused()
const;
739 Mix_Fading GetMusicFading()
const;
763 void SetPanning(
int channel, Uint8 left, Uint8 right);
776 void UnsetPanning(
int channel);
791 void SetDistance(
int channel, Uint8 distance);
804 void UnsetDistance(
int channel);
823 void SetPosition(
int channel, Sint16 angle, Uint8 distance);
836 void UnsetPosition(
int channel);
849 void SetReverseStereo(
int channel);
862 void UnsetReverseStereo(
int channel);
Fragment of audio data.
Definition: Chunk.hh:43
Audio mixer.
Definition: Mixer.hh:50
Mixer(const Mixer &other)=delete
Deleted copy constructor.
Mixer & operator=(const Mixer &other)=delete
Deleted assignment operator.
std::function< void(Uint8 *stream, int len)> MusicHook
Custom music hook.
Definition: Mixer.hh:55
Music data
Definition: Music.hh:43