Music Information Retrieval
General Information
Music Information Retrieval (MIR) allows the extraction of meaningful features from audio files, such as pitch or the volume level of a sample. New KSP commands allow extraction of such parameters from samples via script. MIR functions are not asyncronous in the on init
callback, but in all other callbacks they will run asynchronous.
Note: the type detection functions listed below (Sample Type, Drum Type, and Instrument Type) are designed to process one-shot audio samples.
detect_pitch()
| |
---|---|
Returns a real value representing the fundamental frequency of an audio sample, in semitones and cents. If detection fails, the function will return | |
| The ID of the zone |
| The MIDI note value of the detected pitch |
detect_loudness()
| |
---|---|
Returns a real value representing the loudness of an audio sample in dB. Loudness is measured according to the standard established by the International Telecommunication Union: Algorithms to measure audio program loudness and true-peak audio level - ITU-R BS.1770-4 (2015). If detection fails, the function will return | |
| The ID of the zone |
| The real value of the detected loudness in dB |
detect_peak()
| |
---|---|
Returns a real value representing peak level of an audio sample in dB. Peak is measured according to the standard established by the International Telecommunication Union: Algorithms to measure audio program loudness and true-peak audio level - ITU-R BS.1770-4 (2015). If detection fails, the function will set | |
| The ID of the zone |
| The real value of the detected peak level in dB |
detect_rms()
| |
---|---|
Returns a real value representing the RMS level of an audio sample in dB. If detection fails, the function will return | |
| The ID of the zone |
| The real value of the RMS level of the audio sample in dB |
detect_sample_type()
| |
---|---|
Assigns | |
| The ID of the zone |
| The detected sample type, can be one of the following:
|
detect_drum_type()
| |
---|---|
Assigns | |
| The ID of the zone |
| The detected drum type, can be one of the following:
|
detect_instrument_type()
| |
---|---|
Assigns | |
| The ID of the zone |
| The detected instrument type, can be one of the following:
|
Examples
wait_async(detect_pitch(%NI_USER_ZONE_IDS[0], ~pitch_result)) wait_async(set_zone_par(%NI_USER_ZONE_IDS[0], $ZONE_PAR_ROOT_KEY, int(round(~pitch_result)))) wait_async(set_zone_par(%NI_USER_ZONE_IDS[0], $ZONE_PAR_TUNE, int(100.0 * (round(~pitch_result) - ~pitch_result)))
Set the zone root key by rounding the pitch result to an integer value. Then set the zone tune to correct for the pitch offset.
wait_async(detect_sample_type(%NI_USER_ZONE_IDS[0], $sample_type)) if ($sample_type = $NI_DETECT_SAMPLE_TYPE_INSTRUMENT) wait_async(detect_instrument_type(%NI_USER_ZONE_IDS[0], $instrument_type)) else wait_async(detect_drum_type(%NI_USER_ZONE_IDS[0], $drum_type)) end if if ($sample_type = $NI_DETECT_SAMPLE_TYPE_INSTRUMENT) if ($instrument_type = $NI_DETECT_INSTRUMENT_TYPE_BASS) set_text($label_5, "Bass") end if else if ($drum_type = $NI_DETECT_DRUM_TYPE_KICK) set_text($label_5, "Kick") end if end if
Detect whether a sample is of type instrument or drum, and detect the corresponding drum or instrument type.