Zrythm
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
audio.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: © 2019-2023 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
10#ifndef __UTILS_AUDIO_H__
11#define __UTILS_AUDIO_H__
12
13#include <cstdarg>
14
15#include "utils/types.h"
16#include "utils/yaml.h"
17
27enum class BitDepth
28{
29 BIT_DEPTH_16,
30 BIT_DEPTH_24,
31 BIT_DEPTH_32
32};
33
34static inline int
35audio_bit_depth_enum_to_int (BitDepth depth)
36{
37 switch (depth)
38 {
39 case BitDepth::BIT_DEPTH_16:
40 return 16;
41 case BitDepth::BIT_DEPTH_24:
42 return 24;
43 case BitDepth::BIT_DEPTH_32:
44 return 32;
45 default:
46 g_return_val_if_reached (-1);
47 }
48}
49
50static inline BitDepth
51audio_bit_depth_int_to_enum (int depth)
52{
53 switch (depth)
54 {
55 case 16:
56 return BitDepth::BIT_DEPTH_16;
57 case 24:
58 return BitDepth::BIT_DEPTH_24;
59 case 32:
60 return BitDepth::BIT_DEPTH_32;
61 default:
62 g_return_val_if_reached (BitDepth::BIT_DEPTH_16);
63 }
64}
65
67audio_bit_depth_from_pretty_str (const char * str);
68
69const char *
70audio_bit_depth_to_pretty_str (BitDepth depth);
71
75#define STRIP_SIZE 9
76
88WARN_UNUSED_RESULT bool
90 float * buff,
91 size_t frames_already_written,
92 size_t nframes,
93 uint32_t samplerate,
94 bool flac,
95 BitDepth bit_depth,
96 channels_t channels,
97 const char * filename,
98 GError ** error);
99
105audio_get_num_frames (const char * filepath);
106
110bool
112 const float * src1,
113 const float * src2,
114 size_t num_frames,
115 float epsilon);
116
123bool
125 const char * f1,
126 const char * f2,
127 size_t num_frames,
128 float epsilon);
129
133bool
134audio_frames_empty (float * src, size_t num_frames);
135
141float
143 float * src,
144 size_t num_frames,
145 unsigned int samplerate,
146 GArray * candidates);
147
148bool
149audio_file_is_silent (const char * filepath);
150
154int
156
161#endif
int audio_get_num_cores(void)
Returns the number of CPU cores.
uint_fast64_t unsigned_frame_t
Unsigned type for frame index.
Definition types.h:64
BitDepth
Bit depth.
Definition audio.h:28
bool audio_frames_equal(const float *src1, const float *src2, size_t num_frames, float epsilon)
Returns whether the frame buffers are equal.
bool audio_files_equal(const char *f1, const char *f2, size_t num_frames, float epsilon)
Returns whether the file contents are equal.
bool audio_frames_empty(float *src, size_t num_frames)
Returns whether the frame buffer is empty (zero).
unsigned_frame_t audio_get_num_frames(const char *filepath)
Returns the number of frames in the given audio file.
float audio_detect_bpm(float *src, size_t num_frames, unsigned int samplerate, GArray *candidates)
Detect BPM.
WARN_UNUSED_RESULT bool audio_write_raw_file(float *buff, size_t frames_already_written, size_t nframes, uint32_t samplerate, bool flac, BitDepth bit_depth, channels_t channels, const char *filename, GError **error)
Writes the buffer as a raw file to the given path.
unsigned int channels_t
Number of channels.
Definition types.h:48
Custom types.
YAML utils.