8 #ifndef GROOVE_GROOVE_H
9 #define GROOVE_GROOVE_H
12 #include <soundio/soundio.h>
16 #define GROOVE_EXTERN_C extern "C"
18 #define GROOVE_EXTERN_C
22 #if defined(GROOVE_BUILDING_LIBRARY)
23 #define GROOVE_EXPORT GROOVE_EXTERN_C __declspec(dllexport)
25 #define GROOVE_EXPORT GROOVE_EXTERN_C __declspec(dllimport)
28 #define GROOVE_EXPORT GROOVE_EXTERN_C __attribute__((visibility ("default")))
85 #define GROOVE_LOG_QUIET -8
86 #define GROOVE_LOG_ERROR 16
87 #define GROOVE_LOG_WARNING 24
88 #define GROOVE_LOG_INFO 32
91 #define GROOVE_TAG_MATCH_CASE 1
92 #define GROOVE_TAG_DONT_OVERWRITE 16
96 #define GROOVE_TAG_APPEND 32
100 #define GROOVE_BUFFER_NO 0
101 #define GROOVE_BUFFER_YES 1
102 #define GROOVE_BUFFER_END 2
281 const char *key,
const struct GrooveTag *prev,
int flags);
290 const char *value,
int flags);
struct GroovePlaylistItem * next
Definition: groove.h:141
double gain
This volume adjustment only applies to this sink.
Definition: groove.h:217
void(* pause)(struct GrooveSink *)
called when the playlist is paused
Definition: groove.h:228
void groove_finish(void)
call at the end of your program to clean up.
double pos
read-only
Definition: groove.h:181
struct GroovePlaylistItem * item
read-only when encoding, if item is NULL, this is a format header or trailer.
Definition: groove.h:179
int groove_file_metadata_set(struct GrooveFile *file, const char *key, const char *value, int flags)
key entry to add to metadata.
struct GrooveFile * file
read-only
Definition: groove.h:120
int groove_file_save_as(struct GrooveFile *file, const char *filename)
void groove_playlist_seek(struct GroovePlaylist *playlist, struct GroovePlaylistItem *item, double seconds)
void groove_playlist_position(struct GroovePlaylist *playlist, struct GroovePlaylistItem **item, double *seconds)
Get the position of the decode head both the current playlist item and the position in seconds in the...
int groove_sink_buffer_peek(struct GrooveSink *sink, int block)
returns < 0 on error, 0 on no buffer ready, 1 on buffer ready if block is 1, block until buffer is re...
struct GroovePlaylistItem * tail
read-only.
Definition: groove.h:152
void groove_file_close(struct GrooveFile *file)
uint8_t ** data
read-only.
Definition: groove.h:165
const char * groove_tag_key(struct GrooveTag *tag)
void groove_playlist_set_fill_mode(struct GroovePlaylist *playlist, enum GrooveFillMode mode)
Use this to set the fill mode using the constants above.
void groove_sink_destroy(struct GrooveSink *sink)
int groove_audio_formats_equal(const struct GrooveAudioFormat *a, const struct GrooveAudioFormat *b)
returns 1 if the audio formats have the same sample rate, channel layout, and sample format...
int disable_resample
Set this flag to ignore audio_format.
Definition: groove.h:200
void(* purge)(struct GrooveSink *, struct GroovePlaylistItem *)
called when a playlist item is deleted.
Definition: groove.h:226
const char * filename
read-only
Definition: groove.h:113
struct GrooveFile * groove_file_open(const char *filename)
you are responsible for calling groove_file_close on the returned GrooveFile.
double gain
Read-only.
Definition: groove.h:126
char * groove_create_rand_name(int *out_len, const char *file, int file_len)
given a file path and the length of the file path, allocates a new file path which is in the same dir...
void(* play)(struct GrooveSink *)
called when the playlist is played
Definition: groove.h:230
const char * groove_file_short_names(struct GrooveFile *file)
a comma separated list of short names for the format
struct GroovePlaylistItem * head
read-only.
Definition: groove.h:148
void groove_playlist_set_item_gain_peak(struct GroovePlaylist *playlist, struct GroovePlaylistItem *item, double gain, double peak)
const char * groove_strerror(int error)
struct GrooveAudioFormat audio_format
set this to the audio format you want the sink to output
Definition: groove.h:197
With this behavior, the playlist will stop decoding audio when any attached sink is full...
Definition: groove.h:78
struct GrooveAudioFormat format
read-only
Definition: groove.h:168
struct GroovePlaylistItem * prev
A GroovePlaylist is a doubly linked list.
Definition: groove.h:140
int groove_file_save(struct GrooveFile *file)
write changes made to metadata to disk.
int groove_sink_attach(struct GrooveSink *sink, struct GroovePlaylist *playlist)
before calling this, set audio_format returns 0 on success, < 0 on error
struct GroovePlaylistItem * groove_playlist_insert(struct GroovePlaylist *playlist, struct GrooveFile *file, double gain, double peak, struct GroovePlaylistItem *next)
Once you add a file to the playlist, you must not destroy it until you first remove it from the playl...
GrooveError
See also groove_strerror.
Definition: groove.h:67
void groove_playlist_pause(struct GroovePlaylist *playlist)
use this to get access to a realtime raw audio buffer for example you could use it to draw a waveform...
Definition: groove.h:195
int groove_sink_get_fill_level(struct GrooveSink *sink)
Returns the number of bytes contained in this sink.
int groove_sink_set_gain(struct GrooveSink *sink, double gain)
See the gain property of GrooveSink.
int groove_version_patch(void)
int buffer_sample_count
If you leave this to its default of 0, frames pulled from the sink will have sample count determined ...
Definition: groove.h:205
int groove_playlist_playing(struct GroovePlaylist *playlist)
return 1 if the playlist is playing; 0 if it is not.
int size
read-only total number of bytes contained in this buffer
Definition: groove.h:185
int dirty
read-only
Definition: groove.h:112
int groove_sink_buffer_get(struct GrooveSink *sink, struct GrooveBuffer **buffer, int block)
returns < 0 on error, GROOVE_BUFFER_NO on aborted (block=1) or no buffer ready (block=0), GROOVE_BUFFER_YES on buffer returned, and GROOVE_BUFFER_END on end of playlist.
int frame_count
read-only number of audio frames described by this buffer for encoded audio, this is unknown and set ...
Definition: groove.h:173
const char * groove_tag_value(struct GrooveTag *tag)
int groove_playlist_count(struct GroovePlaylist *playlist)
return the count of playlist items
void(* flush)(struct GrooveSink *)
called when the audio queue is flushed.
Definition: groove.h:223
int groove_init(void)
call once at the beginning of your program from the main thread returns 0 on success, < 0 on error
int groove_sink_detach(struct GrooveSink *sink)
returns 0 on success, < 0 on error
void groove_playlist_clear(struct GroovePlaylist *playlist)
Remove all playlist items.
void groove_playlist_play(struct GroovePlaylist *playlist)
struct GroovePlaylist * groove_playlist_create(void)
A playlist keeps its sinks full.
struct GroovePlaylist * playlist
read-only.
Definition: groove.h:234
double peak
Read-only.
Definition: groove.h:134
const char * groove_version(void)
void groove_buffer_unref(struct GrooveBuffer *buffer)
int groove_version_minor(void)
struct GrooveTag * groove_file_metadata_get(struct GrooveFile *file, const char *key, const struct GrooveTag *prev, int flags)
double gain
read-only.
Definition: groove.h:157
struct GrooveSink * groove_sink_create(void)
uint64_t pts
read-only presentation time stamp of the buffer
Definition: groove.h:189
int buffer_size
how big the buffer queue should be, in sample frames.
Definition: groove.h:209
void * userdata
set to whatever you want, defaults to NULL.
Definition: groove.h:220
void groove_set_logging(int level)
enable/disable logging of errors
int groove_sink_contains_end_of_playlist(struct GrooveSink *sink)
Returns 1 if the sink contains the end of playlist sentinel, 0 otherwise.
void groove_playlist_remove(struct GroovePlaylist *playlist, struct GroovePlaylistItem *item)
This will not call groove_file_close on item->file Item is destroyed and the address it points to is ...
int groove_version_major(void)
double groove_file_duration(struct GrooveFile *file)
main audio stream duration in seconds.
void groove_buffer_ref(struct GrooveBuffer *buffer)
GrooveFillMode
Specifies when the sink will stop decoding.
Definition: groove.h:74
int bytes_per_sec
read-only.
Definition: groove.h:238
void groove_playlist_destroy(struct GroovePlaylist *playlist)
This will not call groove_file_close on any files.
void groove_playlist_set_gain(struct GroovePlaylist *playlist, double gain)
With this behavior, the playlist will decode audio if any sinks are not full.
Definition: groove.h:82
void groove_file_audio_format(struct GrooveFile *file, struct GrooveAudioFormat *audio_format)
get the audio format of the main audio stream of a file