2007-11-06 21:41:16 +00:00
|
|
|
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
|
|
|
|
|
|
|
|
|
/*
|
2012-09-09 16:57:42 +01:00
|
|
|
Rubber Band Library
|
2007-11-06 21:41:16 +00:00
|
|
|
An audio time-stretching and pitch-shifting library.
|
2015-07-09 15:26:08 +01:00
|
|
|
Copyright 2007-2015 Particular Programs Ltd.
|
2012-09-09 16:57:42 +01:00
|
|
|
|
2007-11-06 21:41:16 +00:00
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU General Public License as
|
|
|
|
|
published by the Free Software Foundation; either version 2 of the
|
|
|
|
|
License, or (at your option) any later version. See the file
|
|
|
|
|
COPYING included with this distribution for more information.
|
2012-09-09 16:57:42 +01:00
|
|
|
|
|
|
|
|
Alternatively, if you have a valid commercial licence for the
|
|
|
|
|
Rubber Band Library obtained by agreement with the copyright
|
|
|
|
|
holders, you may redistribute and/or modify it under the terms
|
|
|
|
|
described in that licence.
|
|
|
|
|
|
|
|
|
|
If you wish to distribute code using the Rubber Band Library
|
|
|
|
|
under terms other than those of the GNU General Public License,
|
|
|
|
|
you must obtain a valid commercial licence before doing so.
|
2007-11-06 21:41:16 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef _RUBBERBAND_PITCH_SHIFTER_H_
|
|
|
|
|
#define _RUBBERBAND_PITCH_SHIFTER_H_
|
|
|
|
|
|
2008-05-22 16:54:27 +00:00
|
|
|
#include <ladspa.h>
|
2007-11-06 21:41:16 +00:00
|
|
|
|
2009-09-17 13:01:21 +00:00
|
|
|
#include "base/RingBuffer.h"
|
2007-11-06 21:41:16 +00:00
|
|
|
|
|
|
|
|
namespace RubberBand {
|
|
|
|
|
class RubberBandStretcher;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class RubberBandPitchShifter
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
static const LADSPA_Descriptor *getDescriptor(unsigned long index);
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
RubberBandPitchShifter(int sampleRate, size_t channels);
|
|
|
|
|
~RubberBandPitchShifter();
|
|
|
|
|
|
|
|
|
|
enum {
|
|
|
|
|
LatencyPort = 0,
|
|
|
|
|
OctavesPort = 1,
|
|
|
|
|
SemitonesPort = 2,
|
|
|
|
|
CentsPort = 3,
|
2007-11-21 19:57:49 +00:00
|
|
|
CrispnessPort = 4,
|
2008-06-09 20:46:37 +00:00
|
|
|
FormantPort = 5,
|
2008-07-04 19:31:23 +00:00
|
|
|
FastPort = 6,
|
|
|
|
|
InputPort1 = 7,
|
|
|
|
|
OutputPort1 = 8,
|
2007-11-21 19:57:49 +00:00
|
|
|
PortCountMono = OutputPort1 + 1,
|
2008-07-04 19:31:23 +00:00
|
|
|
InputPort2 = 9,
|
|
|
|
|
OutputPort2 = 10,
|
2007-11-21 19:57:49 +00:00
|
|
|
PortCountStereo = OutputPort2 + 1
|
2007-11-06 21:41:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const char *const portNamesMono[PortCountMono];
|
|
|
|
|
static const LADSPA_PortDescriptor portsMono[PortCountMono];
|
|
|
|
|
static const LADSPA_PortRangeHint hintsMono[PortCountMono];
|
|
|
|
|
|
|
|
|
|
static const char *const portNamesStereo[PortCountStereo];
|
|
|
|
|
static const LADSPA_PortDescriptor portsStereo[PortCountStereo];
|
|
|
|
|
static const LADSPA_PortRangeHint hintsStereo[PortCountStereo];
|
|
|
|
|
|
|
|
|
|
static const LADSPA_Properties properties;
|
|
|
|
|
|
|
|
|
|
static const LADSPA_Descriptor ladspaDescriptorMono;
|
|
|
|
|
static const LADSPA_Descriptor ladspaDescriptorStereo;
|
|
|
|
|
|
|
|
|
|
static LADSPA_Handle instantiate(const LADSPA_Descriptor *, unsigned long);
|
|
|
|
|
static void connectPort(LADSPA_Handle, unsigned long, LADSPA_Data *);
|
|
|
|
|
static void activate(LADSPA_Handle);
|
|
|
|
|
static void run(LADSPA_Handle, unsigned long);
|
|
|
|
|
static void deactivate(LADSPA_Handle);
|
|
|
|
|
static void cleanup(LADSPA_Handle);
|
|
|
|
|
|
2008-07-04 14:19:32 +00:00
|
|
|
void activateImpl();
|
2007-11-06 21:41:16 +00:00
|
|
|
void runImpl(unsigned long);
|
2008-07-04 14:19:32 +00:00
|
|
|
void runImpl(unsigned long, unsigned long offset);
|
2007-11-06 21:41:16 +00:00
|
|
|
void updateRatio();
|
2007-11-21 19:57:49 +00:00
|
|
|
void updateCrispness();
|
2008-06-09 20:46:37 +00:00
|
|
|
void updateFormant();
|
2008-07-04 19:31:23 +00:00
|
|
|
void updateFast();
|
2007-11-06 21:41:16 +00:00
|
|
|
|
2014-09-03 17:11:07 +01:00
|
|
|
float **m_input;
|
|
|
|
|
float **m_output;
|
2007-11-06 21:41:16 +00:00
|
|
|
float *m_latency;
|
|
|
|
|
float *m_cents;
|
|
|
|
|
float *m_semitones;
|
|
|
|
|
float *m_octaves;
|
2007-11-21 19:57:49 +00:00
|
|
|
float *m_crispness;
|
2008-06-09 20:46:37 +00:00
|
|
|
float *m_formant;
|
2008-07-04 19:31:23 +00:00
|
|
|
float *m_fast;
|
2007-11-06 21:41:16 +00:00
|
|
|
double m_ratio;
|
|
|
|
|
double m_prevRatio;
|
2007-11-21 19:57:49 +00:00
|
|
|
int m_currentCrispness;
|
2008-06-09 20:46:37 +00:00
|
|
|
bool m_currentFormant;
|
2008-07-04 19:31:23 +00:00
|
|
|
bool m_currentFast;
|
2007-11-06 21:41:16 +00:00
|
|
|
|
2008-07-04 14:19:32 +00:00
|
|
|
size_t m_blockSize;
|
|
|
|
|
size_t m_reserve;
|
2008-07-06 19:24:53 +00:00
|
|
|
size_t m_minfill;
|
2007-11-06 21:41:16 +00:00
|
|
|
|
|
|
|
|
RubberBand::RubberBandStretcher *m_stretcher;
|
2014-09-03 17:11:07 +01:00
|
|
|
RubberBand::RingBuffer<float> **m_outputBuffer;
|
|
|
|
|
float **m_scratch;
|
2007-11-06 21:41:16 +00:00
|
|
|
|
|
|
|
|
int m_sampleRate;
|
|
|
|
|
size_t m_channels;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|