|
hydrogen 1.1.1
|
#include <Sample.h>
Data Structures | |
| class | Loops |
| set of loop configuration flags More... | |
| class | Rubberband |
| set of rubberband configuration flags More... | |
Public Types | |
| using | PanEnvelope = std::vector< std::unique_ptr< EnvelopePoint > > |
| define the type used to store pan envelope points More... | |
| using | VelocityEnvelope = std::vector< std::unique_ptr< EnvelopePoint > > |
| define the type used to store velocity envelope points More... | |
Public Member Functions | |
| Sample (const QString &filepath, int frames=0, int sample_rate=0, float *data_l=nullptr, float *data_r=nullptr) | |
| Sample constructor. More... | |
| Sample (std::shared_ptr< Sample > other) | |
| copy constructor More... | |
| ~Sample () | |
| destructor More... | |
| bool | write (const QString &path, int format=(SF_FORMAT_WAV|SF_FORMAT_PCM_16)) |
| write sample to a file More... | |
| bool | load () |
| Load the sample stored in __filepath into __data_l and __data_r. More... | |
| void | unload () |
| Flush the current content of the left and right channel and the current metadata. More... | |
| void | apply (const Loops &loops, const Rubberband &rubber, const VelocityEnvelope &velocity, const PanEnvelope &pan) |
| Apply transformations to the sample data. More... | |
| bool | apply_loops (const Loops &lo) |
| apply loop transformation to the sample More... | |
| void | apply_velocity (const VelocityEnvelope &v) |
| apply velocity transformation to the sample More... | |
| void | apply_pan (const PanEnvelope &p) |
| apply velocity transformation to the sample More... | |
| void | apply_rubberband (const Rubberband &rb) |
| apply rubberband transformation to the sample More... | |
| bool | exec_rubberband_cli (const Rubberband &rb) |
| call rubberband cli to modify the sample More... | |
| bool | is_empty () const |
| const QString | get_filepath () const |
| const QString | get_filename () const |
| void | set_filename (const QString &filename) |
| void | set_frames (int value) |
| __frames setter More... | |
| int | get_frames () const |
| void | set_sample_rate (const int sampleRate) |
| int | get_sample_rate () const |
| double | get_sample_duration () const |
| int | get_size () const |
| float * | get_data_l () const |
| float * | get_data_r () const |
| void | set_is_modified (bool value) |
| __is_modified setter More... | |
| bool | get_is_modified () const |
| PanEnvelope * | get_pan_envelope () |
| VelocityEnvelope * | get_velocity_envelope () |
| Loops | get_loops () const |
| Rubberband | get_rubberband () const |
| QString | get_loop_mode_string () const |
| QString | toQString (const QString &sPrefix, bool bShort=true) const override |
| Formatted string version for debugging purposes. More... | |
Public Member Functions inherited from Object | |
| ~Object () | |
| destructor More... | |
| Object (const Object &obj) | |
| copy constructor More... | |
| Object (const char *class_name) | |
| constructor More... | |
| const char * | class_name () const |
| return the class name More... | |
| virtual QString | toQString (const QString &sPrefix, bool bShort=true) const |
| Formatted string version for debugging purposes. More... | |
| void | Print (bool bShort=true) const |
| Prints content of toQString() via DEBUGLOG. More... | |
Static Public Member Functions | |
| static std::shared_ptr< Sample > | load (const QString &filepath) |
| Load a sample from a file. More... | |
| static std::shared_ptr< Sample > | load (const QString &filepath, const Loops &loops, const Rubberband &rubber, const VelocityEnvelope &velocity, const PanEnvelope &pan) |
| static Loops::LoopMode | parse_loop_mode (const QString &string) |
| parse the given string and rturn the corresponding loop_mode More... | |
Static Public Member Functions inherited from Object | |
| static void | set_count (bool flag) |
| enable/disable class instances counting More... | |
| static bool | count_active () |
| return true if class instances counting is enabled More... | |
| static unsigned | objects_count () |
| return the number of objects More... | |
| static void | write_objects_map_to (std::ostream &out) |
| output the full objects map to a given ostream More... | |
| static void | write_objects_map_to_cerr () |
| output objects map to stderr More... | |
| static int | bootstrap (Logger *logger, bool count=false) |
| must be called before any Object instantiation ! More... | |
| static Logger * | logger () |
| return the logger instance More... | |
Private Attributes | |
| QString | __filepath |
| filepath of the sample More... | |
| int | __frames |
| number of frames in this sample More... | |
| int | __sample_rate |
| samplerate for this sample More... | |
| float * | __data_l |
| left channel data More... | |
| float * | __data_r |
| right channel data More... | |
| bool | __is_modified |
| true if sample is modified More... | |
| PanEnvelope | __pan_envelope |
| pan envelope vector More... | |
| VelocityEnvelope | __velocity_envelope |
| velocity envelope vector More... | |
| Loops | __loops |
| set of loop parameters More... | |
| Rubberband | __rubberband |
| set of rubberband parameters More... | |
Static Private Attributes | |
| static const std::vector< QString > | __loop_modes = { "forward", "reverse", "pingpong" } |
| loop modes string More... | |
Additional Inherited Members | |
Static Public Attributes inherited from Object | |
| static QString | sPrintIndention = " " |
| String used to format the debugging string output of some core classes. More... | |
Static Protected Attributes inherited from Object | |
| static Logger * | __logger = nullptr |
| logger instance pointer More... | |
| using PanEnvelope = std::vector<std::unique_ptr<EnvelopePoint> > |
define the type used to store pan envelope points
| using VelocityEnvelope = std::vector<std::unique_ptr<EnvelopePoint> > |
define the type used to store velocity envelope points
| Sample | ( | const QString & | filepath, |
| int | frames = 0, |
||
| int | sample_rate = 0, |
||
| float * | data_l = nullptr, |
||
| float * | data_r = nullptr |
||
| ) |
Sample constructor.
| filepath | the path to the sample |
| frames | the number of frames per channel in the sample |
| sample_rate | the sample rate of the sample |
| data_l | the left channel array of data |
| data_r | the right channel array of data |
| ~Sample | ( | ) |
destructor
| void apply | ( | const Loops & | loops, |
| const Rubberband & | rubber, | ||
| const VelocityEnvelope & | velocity, | ||
| const PanEnvelope & | pan | ||
| ) |
Apply transformations to the sample data.
The function is a wrapper around a specific apply_* functions.
| loops | Loops transformation parameters handed over to apply_loops(). |
| rubber | Rubber Band transformation parameters handed over to apply_rubberband() in case Hydrogen was compiled to use the Rubber Band library for audio time-stretching and pitch-shifting (H2CORE_HAVE_RUBBERBAND) or exec_rubberband_cli() if is wasn't. |
| velocity | Velocity envelope points handed over to apply_velocity(). |
| pan | Pan envelope points handed over to apply_pan(). |
| bool apply_loops | ( | const Loops & | lo | ) |
apply loop transformation to the sample
| lo | loops parameters |
| void apply_pan | ( | const PanEnvelope & | p | ) |
apply velocity transformation to the sample
| p | the pan vector |
| void apply_rubberband | ( | const Rubberband & | rb | ) |
apply rubberband transformation to the sample
| rb | rubberband parameters |
| void apply_velocity | ( | const VelocityEnvelope & | v | ) |
apply velocity transformation to the sample
| v | the velocity vector |
| bool exec_rubberband_cli | ( | const Rubberband & | rb | ) |
call rubberband cli to modify the sample
| rb | rubberband parameters |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
| load | ( | ) |
Load the sample stored in __filepath into __data_l and __data_r.
It uses libsndfile for reading both the content and the metadata of the sample file. The latter is stored in __frames and __sample_rate.
Hydrogen does only support up to SAMPLE_CHANNELS (two per default) channels in the audio file. If there are more, Hydrogen will NOT downmix its content but simply extract the first two channels and display a warning message. For mono file the same content will be assigned to both the left (__data_l) and right channel (__data_r).
If the total number of frames in the file is larger than the maximum value of an ‘int’, the content is truncated and a warning log message will be displayed.
|
static |
Load a sample from a file.
This function checks whether the filepath is readable, initializes a new Sample, and calls the load() member on it.
| filepath | the file to load audio data from |
|
static |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Wrapper around load(const QString& filepath), which calls apply() with loops, rubber, velocity, and pan as arguments after successfully loading the sample.
| filepath | the file to load audio data from |
| loops | transformation parameters |
| rubber | band transformation parameters |
| velocity | envelope points |
| pan | envelope points |
|
static |
parse the given string and rturn the corresponding loop_mode
| string | the loop mode text to be parsed |
| void set_filename | ( | const QString & | filename | ) |
| filename | Filename part of __filepath |
|
inline |
__is_modified setter
| value | the new value for __is_modified |
|
inline |
| sampleRate | Sets __sample_rate. |
|
overridevirtual |
Formatted string version for debugging purposes.
| sPrefix | String prefix which will be added in front of every new line |
| bShort | Instead of the whole content of all classes stored as members just a single unique identifier will be displayed without line breaks. |
Reimplemented from Object.
|
inline |
Flush the current content of the left and right channel and the current metadata.
| bool write | ( | const QString & | path, |
| int | format = ( SF_FORMAT_WAV|SF_FORMAT_PCM_16 ) |
||
| ) |
write sample to a file
| path | the path to write the sample to |
| format | the format of the output |
|
private |
left channel data
|
private |
right channel data
|
private |
filepath of the sample
|
private |
number of frames in this sample
|
private |
true if sample is modified
|
staticprivate |
loop modes string
|
private |
set of loop parameters
|
private |
pan envelope vector
|
private |
set of rubberband parameters
|
private |
samplerate for this sample
|
private |
velocity envelope vector