Files
k4/src/k3mix.h
2025-06-28 13:17:58 +03:00

53 lines
1.3 KiB
C

#pragma once
#include<stdint.h>
#include<stddef.h>
#include<stdbool.h>
struct k3MixWave;
typedef intmax_t(*k3MixWaveReadFunc)(struct k3MixWave *dis, size_t sampleCount, float *buf);
typedef void(*k3MixWaveCloseFunc)(struct k3MixWave *dis);
typedef void(*k3MixWaveCloneFunc)(struct k3MixWave *dis, struct k3MixWave *destination);
struct k3MixSource;
struct k3MixSource *k3MixSourceFile(const char *path);
void k3MixSourceClose(struct k3MixSource*);
struct k3MixWave {
size_t refs;
uint32_t sampleRate;
uint8_t channels;
void *data;
k3MixWaveReadFunc read;
k3MixWaveCloseFunc close;
k3MixWaveCloneFunc clone;
// All the cool things
bool loop;
bool end;
uint16_t dam;
float volume;
float fade;
};
void k3MixInit(uint32_t sampleRate, uint8_t channels);
struct k3MixWave *k3MixSimple(struct k3MixSource*);
void k3MixSimpleSeek(struct k3MixWave*, double t);
struct k3MixWave *k3MixQueue();
void k3MixQueueAdd(struct k3MixWave *this, struct k3MixWave *child);
void k3MixQueueClear(struct k3MixWave *this);
struct k3MixWave *k3MixPowerMeasurement(struct k3MixWave *child);
float k3MixPowerMeasurementGetRMS(struct k3MixWave*);
void k3MixStop(struct k3MixWave*);
void k3MixStopSmooth(struct k3MixWave*);
struct k3MixWave *k3MixPlay(struct k3MixWave*);
void k3MixPlayDirect(struct k3MixWave*);
void k3MixPortAudio();