Audio1 is a high-level audio-API that lets you directly play audio-files. Depending on the target-system it either sits directly on a high-level system audio-API or is implemented based on Audio2.
More...
#include <kinc/global.h>
#include "sound.h"
#include "soundstream.h"
#include <stdbool.h>
Go to the source code of this file.
|
|
typedef struct kinc_a1_channel | kinc_a1_channel_t |
|
typedef struct kinc_a1_stream_channel | kinc_a1_stream_channel_t |
|
|
KINC_FUNC void | kinc_a1_init (void) |
| | Initialize the Audio1-API.
|
| KINC_FUNC kinc_a1_channel_t * | kinc_a1_play_sound (kinc_a1_sound_t *sound, bool loop, float pitch, bool unique) |
| | Plays a sound immediately.
|
| KINC_FUNC void | kinc_a1_stop_sound (kinc_a1_sound_t *sound) |
| | Stops the sound from playing.
|
| KINC_FUNC void | kinc_a1_play_sound_stream (kinc_a1_sound_stream_t *stream) |
| | Starts playing a sound-stream.
|
| KINC_FUNC void | kinc_a1_stop_sound_stream (kinc_a1_sound_stream_t *stream) |
| | Stops a sound-stream from playing.
|
| KINC_FUNC float | kinc_a1_channel_get_volume (kinc_a1_channel_t *channel) |
| | Gets the current volume of a channel. Only works correctly if the channel is still playing.
|
| KINC_FUNC void | kinc_a1_channel_set_volume (kinc_a1_channel_t *channel, float volume) |
| | Sets the current volume of a channel. Only works correctly if the channel is still playing.
|
| KINC_FUNC void | kinc_a1_mix (kinc_a2_buffer_t *buffer, uint32_t samples) |
| | Mixes audio into the provided buffer. kinc_a1_init sets this as the callback for a2 but you can also call it manually to mix a1-audio with your own audio. To do that, first call kinc_a1_init, then call kinc_a2_set_callback to set it to your own callback and call kinc_a1_mix from within that callback. Please be aware that the callback will run in a separate audio-thread.
|
Audio1 is a high-level audio-API that lets you directly play audio-files. Depending on the target-system it either sits directly on a high-level system audio-API or is implemented based on Audio2.
◆ kinc_a1_channel_get_volume()
| KINC_FUNC float kinc_a1_channel_get_volume |
( |
kinc_a1_channel_t * | channel | ) |
|
Gets the current volume of a channel. Only works correctly if the channel is still playing.
- Parameters
-
| channel | The channel to get the volume from |
- Returns
- The volume
◆ kinc_a1_channel_set_volume()
| KINC_FUNC void kinc_a1_channel_set_volume |
( |
kinc_a1_channel_t * | channel, |
|
|
float | volume ) |
Sets the current volume of a channel. Only works correctly if the channel is still playing.
- Parameters
-
| channel | The channel to set the volume for |
| volume | The volume to set |
- Returns
◆ kinc_a1_mix()
| KINC_FUNC void kinc_a1_mix |
( |
kinc_a2_buffer_t * | buffer, |
|
|
uint32_t | samples ) |
Mixes audio into the provided buffer. kinc_a1_init sets this as the callback for a2 but you can also call it manually to mix a1-audio with your own audio. To do that, first call kinc_a1_init, then call kinc_a2_set_callback to set it to your own callback and call kinc_a1_mix from within that callback. Please be aware that the callback will run in a separate audio-thread.
- Parameters
-
| buffer | The audio-buffer to be filled |
| samples | The number of samples to be filled in |
◆ kinc_a1_play_sound()
| KINC_FUNC kinc_a1_channel_t * kinc_a1_play_sound |
( |
kinc_a1_sound_t * | sound, |
|
|
bool | loop, |
|
|
float | pitch, |
|
|
bool | unique ) |
Plays a sound immediately.
- Parameters
-
| sound | The sound to play |
| loop | Whether or not to automatically loop the sound |
| pitch | Changes the pitch by providing a value that's not 1.0f |
| unique | Makes 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.
◆ kinc_a1_play_sound_stream()
| KINC_FUNC void kinc_a1_play_sound_stream |
( |
kinc_a1_sound_stream_t * | stream | ) |
|
Starts playing a sound-stream.
- Parameters
-
◆ kinc_a1_stop_sound()
| KINC_FUNC void kinc_a1_stop_sound |
( |
kinc_a1_sound_t * | sound | ) |
|
Stops the sound from playing.
- Parameters
-
◆ kinc_a1_stop_sound_stream()
| KINC_FUNC void kinc_a1_stop_sound_stream |
( |
kinc_a1_sound_stream_t * | stream | ) |
|
Stops a sound-stream from playing.
- Parameters
-
| stream | The stream to stop. |