#pragma once #include #include #include /*! \file soundstream.h \brief Sound-Streams are decoded while playing and as such are useful for large audio-files like music or speech. */ #ifdef __cplusplus extern "C" { #endif struct stb_vorbis; typedef struct kinc_a1_sound_stream { struct stb_vorbis *vorbis; int chans; int rate; bool myLooping; float myVolume; bool decoded; bool rateDecodedHack; bool end; float samples[2]; uint8_t *buffer; } kinc_a1_sound_stream_t; /// /// Create a sound-stream from a wav file. /// /// A path to a wav file /// Defines whether the stream will be looped automatically /// The newly created sound-stream KINC_FUNC kinc_a1_sound_stream_t *kinc_a1_sound_stream_create(const char *filename, bool looping); /// /// Gets the next audio-sample in the stream. /// /// The stream to extract the sample from /// The next sample KINC_FUNC float kinc_a1_sound_stream_next_sample(kinc_a1_sound_stream_t *stream); /// /// Gets the number of audio-channels the stream uses. /// /// The stream to extract the number of channels from /// The number of audio-channels KINC_FUNC int kinc_a1_sound_stream_channels(kinc_a1_sound_stream_t *stream); /// /// Gets the sample-rate used by the stream. /// /// The stream to extract the sample-rate from /// The sample-rate of the stream KINC_FUNC int kinc_a1_sound_stream_sample_rate(kinc_a1_sound_stream_t *stream); /// /// Returns whether the stream loops automatically. /// /// The stream to extract the looping-information from /// Whether the stream loops KINC_FUNC bool kinc_a1_sound_stream_looping(kinc_a1_sound_stream_t *stream); /// /// Changes whether the stream is looped automatically. /// /// The stream to change /// The new loop value to set KINC_FUNC void kinc_a1_sound_stream_set_looping(kinc_a1_sound_stream_t *stream, bool loop); /// /// Returns whether the stream finished playing. /// /// The stream to query /// Whether the stream finished playing KINC_FUNC bool kinc_a1_sound_stream_ended(kinc_a1_sound_stream_t *stream); /// /// Returns the length of the stream. /// /// The stream to query /// The length of the stream in seconds KINC_FUNC float kinc_a1_sound_stream_length(kinc_a1_sound_stream_t *stream); /// /// Returns the current playing-position of the stream. /// /// The stream to query /// The current playing-position in seconds KINC_FUNC float kinc_a1_sound_stream_position(kinc_a1_sound_stream_t *stream); /// /// Resets the stream to its start-position. /// /// The stream to change KINC_FUNC void kinc_a1_sound_stream_reset(kinc_a1_sound_stream_t *stream); /// /// Gets the stream's volume-multiplicator. /// /// The stream to query /// The volume-multiplicator KINC_FUNC float kinc_a1_sound_stream_volume(kinc_a1_sound_stream_t *stream); /// /// Sets the stream's volume-multiplicator. /// /// The stream to change /// The volume-multiplicator KINC_FUNC void kinc_a1_sound_stream_set_volume(kinc_a1_sound_stream_t *stream, float value); #ifdef __cplusplus } #endif