summaryrefslogtreecommitdiff
path: root/wav_writer.h
blob: 2239ba883babe7ca9c0fabb6926ea1a5cbf5aab7 (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
#ifndef STEMSEP_WAV_WRITER_H
#define STEMSEP_WAV_WRITER_H

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

typedef struct WavWriter WavWriter;

/* Takes ownership of file; on success it is closed by finish()/abort(), and on
   failure it is closed before this returns NULL. */
WavWriter *wav_writer_open(FILE *file, const char *path, uint32_t sample_rate,
                           uint16_t channels, uint64_t total_frames, char *message,
                           size_t message_size);

bool wav_writer_write(WavWriter *writer, const float *interleaved,
                      size_t frame_count, char *message, size_t message_size);

/* Finalizes and frees the writer, on success and on failure. */
bool wav_writer_finish(WavWriter *writer, char *message, size_t message_size);

/* Releases the writer without publishing the output. */
void wav_writer_abort(WavWriter *writer);

#endif