Zrythm
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
stretcher.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: © 2019-2020 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
10#ifndef __AUDIO_STRETCHER_H__
11#define __AUDIO_STRETCHER_H__
12
13#include <stdbool.h>
14#include <stddef.h>
15#include <sys/types.h>
16
17#include "utils/types.h"
18
19#include <rubberband/rubberband-c.h>
20
39
43typedef struct Stretcher
44{
45 StretcherBackend backend;
46
48 RubberBandState rubberband_state;
49
50 unsigned int samplerate;
51 unsigned int channels;
52
53 bool is_realtime;
54
60 unsigned int block_size;
61} Stretcher;
62
76 unsigned int samplerate,
77 unsigned int channels,
78 double time_ratio,
79 double pitch_ratio,
80 bool realtime);
81
94ssize_t
96 Stretcher * self,
97 float * in_samples_l,
98 float * in_samples_r,
99 size_t in_samples_size,
100 float * out_samples_l,
101 float * out_samples_r,
102 size_t out_samples_wanted);
103
107unsigned int
109
110void
111stretcher_set_time_ratio (Stretcher * self, double ratio);
112
124ssize_t
126 Stretcher * self,
127 float * in_samples,
128 size_t in_samples_size,
129 float ** _out_samples);
130
134void
136
141#endif
ssize_t stretcher_stretch_interleaved(Stretcher *self, float *in_samples, size_t in_samples_size, float **_out_samples)
Perform stretching.
ssize_t stretcher_stretch(Stretcher *self, float *in_samples_l, float *in_samples_r, size_t in_samples_size, float *out_samples_l, float *out_samples_r, size_t out_samples_wanted)
Perform stretching.
unsigned int stretcher_get_latency(Stretcher *self)
Get latency in number of samples.
StretcherBackend
Definition stretcher.h:28
Stretcher * stretcher_new_rubberband(unsigned int samplerate, unsigned int channels, double time_ratio, double pitch_ratio, bool realtime)
Create a new Stretcher using the rubberband backend.
void stretcher_free(Stretcher *self)
Frees the resampler.
@ STRETCHER_BACKEND_SBSMS
SBSMS - Subband Sinusoidal Modeling Synthesis.
Definition stretcher.h:37
@ STRETCHER_BACKEND_RUBBERBAND
Lib rubberband.
Definition stretcher.h:30
@ STRETCHER_BACKEND_PAULSTRETCH
Paulstretch.
Definition stretcher.h:33
Stretcher interface.
Definition stretcher.h:44
RubberBandState rubberband_state
For rubberband API.
Definition stretcher.h:48
unsigned int block_size
Size of the block to process in each iteration.
Definition stretcher.h:60
Custom types.