|
Audio Sample Splitter
A program to read and split audio into instrument samples
|
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) |
Takes audio data, splits it and exports it as several audio samples.
Definition at line 23 of file SampleSplitter.h.
|
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.
| threshold | The minimum amplitude that must be surpased to start recording a single sample. |
| grace_time | The minimum amount of time after one sample begins recording before another can start to be recorded. |
| updates_per_export_attempt | The number of updates between each attempt to export a sample. |
Definition at line 32 of file SampleSplitter.h.
|
inline |
The non-live mode instantiator Use this instantiator if you wish to use the sample splitter to split a pre recorded .wav file.
| filename | The .wav file to be read. |
Definition at line 42 of file SampleSplitter.h.
| 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.
| threshold | The minimum amplitude that must be surpased to start recording a single sample. |
| grace_time | The 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
| file_names | The 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.
| sample_number | The 1 based index of the sample the user wishes to export. |
| file_name | The 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.
Definition at line 200 of file SampleSplitter.h.
| double SampleSplitter::get_min | ( | ) |
For non-live mode use only.
Definition at line 216 of file SampleSplitter.h.
| double SampleSplitter::number_of_samples | ( | ) |
For non-live mode use only.
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.
| left_data | The left speaker audio data in json form. |
| right_data | The right speaker audio data in json form. |
Definition at line 472 of file SampleSplitter.h.
| void SampleSplitter::set_grace_time | ( | double | grace_time | ) |
| grace_time | The 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 | ) |
| threshold | The 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.
| threshold | The minimum amplitude that must be surpased to start recording a single sample. |
| grace_time | The minimum amount of time after one sample begins recording before another can start to be recorded. |
| export_files | A 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.
| threshold | The minimum amplitude that must be surpased to start recording a single sample. |
| grace_time | The minimum amount of time after one sample begins recording before another can start to be recorded. |
Definition at line 295 of file SampleSplitter.h.
|
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.
1.8.8