Audio Sample Splitter
A program to read and split audio into instrument samples
 All Classes Functions
Public Member Functions | List of all members
SampleSplitter Class Reference

Takes audio data, splits it and exports it as several audio samples. More...

#include <SampleSplitter.h>

+ Inheritance diagram for SampleSplitter:
+ Collaboration diagram for SampleSplitter:

Public Member Functions

 SampleSplitter (double threshold, double grace_time, double updates_per_export_attempt)
 
 SampleSplitter (std::string filename)
 
void init ()
 Listens to the manager for its bit depth and sample rate when initialized.
 
void start ()
 
void update ()
 
void stop ()
 
void set_threshold (double threshold)
 
void set_grace_time (double grace_time)
 
double number_of_samples ()
 
double get_max ()
 
double get_min ()
 
void split_samples (double threshold, double grace_time)
 
void export_sample (double sample_number, std::string file_name)
 
void export_all_samples ()
 
void export_all_samples (vector< std::string > file_names)
 
void split_and_export_samples (double threshold, double grace_time, bool export_files)
 
void read_data_packet (json left_data, json right_data)
 
void attempt_live_export (double threshold, double grace_time)
 

Detailed Description

Takes audio data, splits it and exports it as several audio samples.

Definition at line 23 of file SampleSplitter.h.

Constructor & Destructor Documentation

SampleSplitter::SampleSplitter ( double  threshold,
double  grace_time,
double  updates_per_export_attempt 
)
inline

The live mode instantiator. Use this instantiator if you wish to use the sample splitter to split an audio file being recorded live. The export attempt time is how often you would like the sample splitter to attempt to export a new sample in seconds.

Parameters
thresholdThe minimum amplitude that must be surpased to start recording a single sample.
grace_timeThe minimum amount of time after one sample begins recording before another can start to be recorded.
updates_per_export_attemptThe number of updates between each attempt to export a sample.

Definition at line 32 of file SampleSplitter.h.

SampleSplitter::SampleSplitter ( std::string  filename)
inline

The non-live mode instantiator Use this instantiator if you wish to use the sample splitter to split a pre recorded .wav file.

Parameters
filenameThe .wav file to be read.

Definition at line 42 of file SampleSplitter.h.

Member Function Documentation

void SampleSplitter::attempt_live_export ( double  threshold,
double  grace_time 
)

For live mode use only. Attempts to export a sample from the backlog. If it does export a sample, the left over data is kept in the backlog to be used in the next sample.

Parameters
thresholdThe minimum amplitude that must be surpased to start recording a single sample.
grace_timeThe minimum amount of time after one sample begins recording before another can start to be recorded.

Definition at line 413 of file SampleSplitter.h.

void SampleSplitter::export_all_samples ( )

For non-live mode use only. Should only be called after the .wav file has been split. Exports all stored samples and names them sample_1, sample_2, etc.

Definition at line 372 of file SampleSplitter.h.

void SampleSplitter::export_all_samples ( vector< std::string >  file_names)

For non-live mode use only. Should only be called after the .wav file has been split. Exports all stored samples and names them according to user's input

Parameters
file_namesThe titles the user wishes name the .wav sample file exports.

Definition at line 391 of file SampleSplitter.h.

void SampleSplitter::export_sample ( double  sample_number,
std::string  file_name 
)

For non-live mode use only. Should only be called after the .wav file has been split. Exports a stored sample of the user's choosing.

Parameters
sample_numberThe 1 based index of the sample the user wishes to export.
file_nameThe title the user wishes name the .wav sample file export.

Definition at line 348 of file SampleSplitter.h.

double SampleSplitter::get_max ( )

For non-live mode use only.

Returns
The maximum value in the user provided .wav file.

Definition at line 200 of file SampleSplitter.h.

double SampleSplitter::get_min ( )

For non-live mode use only.

Returns
The minimum value in the user provided .wav file.

Definition at line 216 of file SampleSplitter.h.

double SampleSplitter::number_of_samples ( )

For non-live mode use only.

Returns
The number of samples in the user provided .wav file.

Definition at line 192 of file SampleSplitter.h.

void SampleSplitter::read_data_packet ( json  left_data,
json  right_data 
)

For live mode use only. Reads the json data from the audio channels and saves it to a backlog.

Parameters
left_dataThe left speaker audio data in json form.
right_dataThe right speaker audio data in json form.

Definition at line 472 of file SampleSplitter.h.

void SampleSplitter::set_grace_time ( double  grace_time)
Parameters
grace_timeThe minimum amount of time after one sample begins recording before another can start to be recorded.

Definition at line 187 of file SampleSplitter.h.

void SampleSplitter::set_threshold ( double  threshold)
Parameters
thresholdThe minimum amplitude that must be surpased to start recording a single sample.

Definition at line 183 of file SampleSplitter.h.

void SampleSplitter::split_and_export_samples ( double  threshold,
double  grace_time,
bool  export_files 
)

For non-live mode use only. Can be called before the .wav file has been split. This function is the quickest and dirtiest approach. In exchange for the variability of seperate split and export functions, it provides simplicity. Splits, names and exports files sample_1, sample_2, etc.

Parameters
thresholdThe minimum amplitude that must be surpased to start recording a single sample.
grace_timeThe minimum amount of time after one sample begins recording before another can start to be recorded.
export_filesA quick on/off switch to enable or disable exporting files.

Definition at line 233 of file SampleSplitter.h.

void SampleSplitter::split_samples ( double  threshold,
double  grace_time 
)

For non-live mode use only. Splits and stores the user provided .wav file into samples.

Parameters
thresholdThe minimum amplitude that must be surpased to start recording a single sample.
grace_timeThe minimum amount of time after one sample begins recording before another can start to be recorded.

Definition at line 295 of file SampleSplitter.h.

void SampleSplitter::update ( )
inline

Every update recieves the next json audio data packet through the left and right channels. Reads the json audio packet. Attempts to export a sample if the grace time and the user defined number updates since the last attempt has been surpassed.

Definition at line 62 of file SampleSplitter.h.


The documentation for this class was generated from the following file: