Zrythm
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
clip.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 __AUDIO_CLIP_H__
11#define __AUDIO_CLIP_H__
12
13#include "utils/audio.h"
14#include "utils/types.h"
15#include "utils/yaml.h"
16
23#define AUDIO_CLIP_SCHEMA_VERSION 1
24
30typedef struct AudioClip
31{
32 int schema_version;
33
35 char * name;
36
39
42
47
50
56
62
68
72
75
78 char * file_hash;
79
86
95 gint64 last_write;
96} AudioClip;
97
98static inline bool
99audio_clip_use_flac (BitDepth bd)
100{
101 return false;
102 /* FLAC seems to fail writing sometimes so disable for now */
103#if 0
104 return bd < BIT_DEPTH_32;
105#endif
106}
107
111COLD NONNULL bool
112audio_clip_init_loaded (AudioClip * self, GError ** error);
113
119NONNULL_ARGS (1)
120AudioClip * audio_clip_new_from_file (const char * full_path, GError ** error);
121
129AudioClip *
131 const float * arr,
132 const unsigned_frame_t nframes,
133 const channels_t channels,
134 BitDepth bit_depth,
135 const char * name);
136
147AudioClip *
149 const channels_t channels,
150 const unsigned_frame_t nframes,
151 const char * name);
152
161NONNULL void
162audio_clip_update_channel_caches (AudioClip * self, size_t start_from);
163
178NONNULL AudioClip *
180
189WARN_UNUSED_RESULT NONNULL bool
191 AudioClip * self,
192 const char * filepath,
193 bool parts,
194 GError ** error);
195
206WARN_UNUSED_RESULT NONNULL bool
208 AudioClip * self,
209 bool parts,
210 bool is_backup,
211 GError ** error);
212
222NONNULL char *
224 const char * name,
225 bool use_flac,
226 bool is_backup);
227
233NONNULL char *
234audio_clip_get_path_in_pool (AudioClip * self, bool is_backup);
235
243NONNULL bool
244audio_clip_is_in_use (AudioClip * self, bool check_undo_stack);
245
255NONNULL void
257
258NONNULL AudioClip *
259audio_clip_clone (AudioClip * src);
260
264NONNULL void
266
271#endif
Audio utils.
NONNULL_ARGS(1) int undo_manager_undo(UndoManager *self
Undo last action.
AudioClip * audio_clip_new_from_file(const char *full_path, GError **error)
Creates an audio clip from a file.
NONNULL void audio_clip_remove_and_free(AudioClip *self, bool backup)
To be called by audio_pool_remove_clip().
NONNULL char * audio_clip_get_path_in_pool_from_name(const char *name, bool use_flac, bool is_backup)
Gets the path of a clip matching name from the pool.
AudioClip * audio_clip_new_recording(const channels_t channels, const unsigned_frame_t nframes, const char *name)
Create an audio clip while recording.
NONNULL void audio_clip_update_channel_caches(AudioClip *self, size_t start_from)
Updates the channel caches.
NONNULL void audio_clip_free(AudioClip *self)
Frees the audio clip.
WARN_UNUSED_RESULT NONNULL bool audio_clip_write_to_file(AudioClip *self, const char *filepath, bool parts, GError **error)
Writes the given audio clip data to a file.
NONNULL AudioClip * audio_clip_edit_in_ext_program(AudioClip *self, GError **error)
Shows a dialog with info on how to edit a file, with an option to open an app launcher.
WARN_UNUSED_RESULT NONNULL bool audio_clip_write_to_pool(AudioClip *self, bool parts, bool is_backup, GError **error)
Writes the clip to the pool as a wav file.
NONNULL char * audio_clip_get_path_in_pool(AudioClip *self, bool is_backup)
Gets the path of the given clip from the pool.
AudioClip * audio_clip_new_from_float_array(const float *arr, const unsigned_frame_t nframes, const channels_t channels, BitDepth bit_depth, const char *name)
Creates an audio clip by copying the given float array.
COLD NONNULL bool audio_clip_init_loaded(AudioClip *self, GError **error)
Inits after loading a Project.
NONNULL bool audio_clip_is_in_use(AudioClip *self, bool check_undo_stack)
Returns whether the clip is used inside the project.
uint_fast64_t unsigned_frame_t
Unsigned type for frame index.
Definition types.h:64
BitDepth
Bit depth.
Definition audio.h:28
float bpm_t
The BPM type.
Definition types.h:54
float sample_t
The sample type.
Definition types.h:51
unsigned int channels_t
Number of channels.
Definition types.h:48
Audio clips for the pool.
Definition clip.h:31
sample_t * frames
The audio frames, interleaved.
Definition clip.h:38
char * name
Name of the clip.
Definition clip.h:35
char * file_hash
File hash, used for checking if a clip is already written to the pool.
Definition clip.h:78
sample_t * ch_frames[16]
Per-channel frames for convenience.
Definition clip.h:46
int pool_id
ID in the audio pool.
Definition clip.h:74
unsigned_frame_t num_frames
Number of frames per channel.
Definition clip.h:41
unsigned_frame_t frames_written
Frames already written to the file, per channel.
Definition clip.h:85
BitDepth bit_depth
Bit depth of the clip when the clip was imported into the project.
Definition clip.h:67
bool use_flac
Whether the clip should use FLAC when being serialized.
Definition clip.h:71
gint64 last_write
Time the last write took place.
Definition clip.h:95
bpm_t bpm
BPM of the clip, or BPM of the project when the clip was first loaded.
Definition clip.h:55
int samplerate
Samplerate of the clip, or samplerate when the clip was imported into the project.
Definition clip.h:61
channels_t channels
Number of channels.
Definition clip.h:49
Custom types.
YAML utils.