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

Sounds are pre-decoded on load and therefore primarily useful for playing sound-effects. More...

#include <kore3/global.h>
#include <kore3/audio/audio.h>
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  kore_mixer_sound

Typedefs

typedef struct kore_mixer_sound kore_mixer_sound

Enumerations

enum  kore_mixer_audioformat { KORE_MIXER_AUDIOFORMAT_WAV , KORE_MIXER_AUDIOFORMAT_OGG }

Functions

KORE_FUNC kore_mixer_sound * kore_mixer_sound_create_from_file (const char *filename)
 Create a sound from a wav or ogg file.
KORE_FUNC kore_mixer_sound * kore_mixer_sound_create_from_file_buffer (uint8_t *audio_data, uint32_t size, kore_mixer_audioformat format)
 Create a sound from the contents of a wav or ogg file.
KORE_FUNC kore_mixer_sound * kore_mixer_sound_create_from_samples (int16_t *samples, uint32_t samples_count, uint32_t samples_per_second, bool stereo)
 Create a sound from an array of samples.
KORE_FUNC void kore_mixer_sound_destroy (kore_mixer_sound *sound)
 Destroy a sound.
KORE_FUNC float kore_mixer_sound_volume (kore_mixer_sound *sound)
 Gets the current volume-multiplicator that's used when playing the sound.
KORE_FUNC void kore_mixer_sound_set_volume (kore_mixer_sound *sound, float value)
 Sets the volume-multiplicator that's used when playing the sound.

Detailed Description

Sounds are pre-decoded on load and therefore primarily useful for playing sound-effects.

Function Documentation

◆ kore_mixer_sound_create_from_file()

KORE_FUNC kore_mixer_sound * kore_mixer_sound_create_from_file ( const char * filename)

Create a sound from a wav or ogg file.

Parameters
filenamePath to a wav or ogg file
Returns
The newly created sound

◆ kore_mixer_sound_create_from_file_buffer()

KORE_FUNC kore_mixer_sound * kore_mixer_sound_create_from_file_buffer ( uint8_t * audio_data,
uint32_t size,
kore_mixer_audioformat format )

Create a sound from the contents of a wav or ogg file.

Parameters
audio_dataPath to ogg or mp3 data
sizeSize of the audio_data
formatType of the audio_data (wav or ogg)
Returns
The newly created sound

◆ kore_mixer_sound_create_from_samples()

KORE_FUNC kore_mixer_sound * kore_mixer_sound_create_from_samples ( int16_t * samples,
uint32_t samples_count,
uint32_t samples_per_second,
bool stereo )

Create a sound from an array of samples.

Parameters
samplesThe samples
samples_countNumber of samples
samples_per_secondThe sample rate
stereoWhether the samples are interleaved stereo or mono
Returns
The newly created sound

◆ kore_mixer_sound_destroy()

KORE_FUNC void kore_mixer_sound_destroy ( kore_mixer_sound * sound)

Destroy a sound.

Parameters
soundThe sound to destroy.

◆ kore_mixer_sound_set_volume()

KORE_FUNC void kore_mixer_sound_set_volume ( kore_mixer_sound * sound,
float value )

Sets the volume-multiplicator that's used when playing the sound.

Parameters
soundThe sound to modify
valueThe volume-multiplicator to set

◆ kore_mixer_sound_volume()

KORE_FUNC float kore_mixer_sound_volume ( kore_mixer_sound * sound)

Gets the current volume-multiplicator that's used when playing the sound.

Parameters
soundThe sound to query
Returns
The volume-multiplicator