Kore 3
Loading...
Searching...
No Matches
mixer.h File Reference

Mixer is a high-level audio-API that lets you directly play audio-files. More...

#include <kore3/global.h>
#include "sound.h"
#include "soundstream.h"
#include <stdbool.h>

Go to the source code of this file.

Data Structures

struct  kore_mixer_channel

Typedefs

typedef struct kore_mixer_stream_channel kore_mixer_stream_channel
typedef struct kore_mixer_channel kore_mixer_channel

Functions

KORE_FUNC void kore_mixer_init (void)
 Initialize the Mixer-API.
KORE_FUNC kore_mixer_channel * kore_mixer_play_sound (kore_mixer_sound *sound, bool loop, float volume, float pitch, bool unique)
 Plays a sound immediately.
KORE_FUNC void kore_mixer_stop_sound (kore_mixer_sound *sound)
 Stops the sound from playing.
KORE_FUNC void kore_mixer_play_sound_stream (kore_mixer_sound_stream *stream)
 Starts playing a sound-stream.
KORE_FUNC void kore_mixer_stop_sound_stream (kore_mixer_sound_stream *stream)
 Stops a sound-stream from playing.
KORE_FUNC float kore_mixer_channel_get_volume (kore_mixer_channel *channel)
 Gets the current volume of a channel. Only works correctly if the channel is still playing.
KORE_FUNC void kore_mixer_channel_set_volume (kore_mixer_channel *channel, float volume)
 Sets the current volume of a channel. Only works correctly if the channel is still playing.
KORE_FUNC void kore_mixer_mix (kore_audio_buffer *buffer, uint32_t samples)
 Mixes audio into the provided buffer. kore_mixer_init sets this as the audio-callback but you can also call it manually to mix with your own audio. To do that, first call kore_mixer_init, then call kore_audio_set_callback to set it to your own callback and call kore_mixer_mix from within that callback. Please be aware that the callback will run in a separate audio-thread.

Detailed Description

Mixer is a high-level audio-API that lets you directly play audio-files.

Function Documentation

◆ kore_mixer_channel_get_volume()

KORE_FUNC float kore_mixer_channel_get_volume ( kore_mixer_channel * channel)

Gets the current volume of a channel. Only works correctly if the channel is still playing.

Parameters
channelThe channel to get the volume from
Returns
The volume

◆ kore_mixer_channel_set_volume()

KORE_FUNC void kore_mixer_channel_set_volume ( kore_mixer_channel * channel,
float volume )

Sets the current volume of a channel. Only works correctly if the channel is still playing.

Parameters
channelThe channel to set the volume for
volumeThe volume to set
Returns

◆ kore_mixer_mix()

KORE_FUNC void kore_mixer_mix ( kore_audio_buffer * buffer,
uint32_t samples )

Mixes audio into the provided buffer. kore_mixer_init sets this as the audio-callback but you can also call it manually to mix with your own audio. To do that, first call kore_mixer_init, then call kore_audio_set_callback to set it to your own callback and call kore_mixer_mix from within that callback. Please be aware that the callback will run in a separate audio-thread.

Parameters
bufferThe audio-buffer to be filled
samplesThe number of samples to be filled in

◆ kore_mixer_play_sound()

KORE_FUNC kore_mixer_channel * kore_mixer_play_sound ( kore_mixer_sound * sound,
bool loop,
float volume,
float pitch,
bool unique )

Plays a sound immediately.

Parameters
soundThe sound to play
loopWhether or not to automatically loop the sound
volumeScales the volume
pitchScales the pitch
uniqueMakes sure that a sound is not played more than once at the same time
Returns
A channel object that can be used to control the playing sound. Please be aware that NULL is returned when the maximum number of simultaneously played channels was reached.

◆ kore_mixer_play_sound_stream()

KORE_FUNC void kore_mixer_play_sound_stream ( kore_mixer_sound_stream * stream)

Starts playing a sound-stream.

Parameters
streamThe stream to play

◆ kore_mixer_stop_sound()

KORE_FUNC void kore_mixer_stop_sound ( kore_mixer_sound * sound)

Stops the sound from playing.

Parameters
soundThe sound to stop

◆ kore_mixer_stop_sound_stream()

KORE_FUNC void kore_mixer_stop_sound_stream ( kore_mixer_sound_stream * stream)

Stops a sound-stream from playing.

Parameters
streamThe stream to stop.