Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
sample_playback.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: © 2019, 2024 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
11
12#ifndef __AUDIO_SAMPLE_PLAYBACK_H__
13#define __AUDIO_SAMPLE_PLAYBACK_H__
14
15#include <utility>
16
17#include "utils/types.h"
18
19#include "juce_wrapper.h"
20
26
30struct SamplePlayback
31{
32public:
33 SamplePlayback () = default;
34 SamplePlayback (
35 std::shared_ptr<zrythm::utils::audio::AudioBuffer> buf,
36 float volume,
37 nframes_t start_offset,
38 const char * file,
39 const char * func,
40 int lineno)
41 : buf_ (std::move (buf)), volume_ (volume), start_offset_ (start_offset),
42 file_ (file), func_ (func), lineno_ (lineno)
43 {
44 }
46 std::shared_ptr<zrythm::utils::audio::AudioBuffer> buf_;
47
49 // channels_t channels_ = 0;
50
52 // unsigned_frame_t buf_size_ = 0;
53
56
59 float volume_ = 1.0f;
60
64
66 const char * file_ = nullptr;
67
69 const char * func_ = nullptr;
70
72 int lineno_ = 0;
73};
74
78#define sample_playback_init( \
79 self, _buf, _buf_size, _channels, _vol, _start_offset) \
80 if (_channels <= 0) \
81 { \
82 z_error ("channels: {}", _channels); \
83 } \
84 (self)->buf = _buf; \
85 (self)->buf_size = _buf_size; \
86 (self)->volume = _vol; \
87 (self)->offset = 0; \
88 (self)->channels = _channels; \
89 (self)->start_offset = _start_offset; \
90 (self)->file = __FILE__; \
91 (self)->func = __func__; \
92 (self)->lineno = __LINE__
93
97
98#endif
uint_fast64_t unsigned_frame_t
Unsigned type for frame index.
Definition types.h:78
uint32_t nframes_t
Frame count.
Definition types.h:58
nframes_t start_offset_
Offset relative to the current processing cycle to start playing the sample.
float volume_
The volume to play the sample at (ratio from 0.0 to 2.0, where 1.0 is the normal volume).
std::shared_ptr< zrythm::utils::audio::AudioBuffer > buf_
A pointer to the original buffer.
const char * func_
Function initialized from.
const char * file_
Source file initialized from.
unsigned_frame_t offset_
The number of channels.
int lineno_
Line no initialized from.