summaryrefslogtreecommitdiff
path: root/audio.h
blob: c570968e0d201b2691c96ee2d7bbe7d52c42435e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#ifndef STEMSEP_AUDIO_H
#define STEMSEP_AUDIO_H

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

typedef struct AudioSource AudioSource;

typedef struct {
    bool (*read_frames)(AudioSource *source, float *stereo, size_t requested,
                        size_t *frames_read, char *message, size_t message_size);
    void (*close)(AudioSource *source);
} AudioSourceOps;

struct AudioSource {
    const char *format_name;
    uint32_t sample_rate;
    uint16_t channels;
    uint64_t total_frames;
    uint64_t frames_read;
    const AudioSourceOps *ops;
    void *impl;
};

bool audio_source_open(AudioSource *source, const char *path, char *message,
                       size_t message_size);

void audio_source_close(AudioSource *source);

#endif