SampleDescript:
Filter:
SuperSampler/Classes (extension) | VKey

SampleDescript
ExtensionExtension

Represents a sample file or a buffer with descriptive qualities.

Description

By Allen Wu

System Requirements:

1. SCMIR. See the link http://composerprogrammer.com/code.html

2. wslib Quark

SampleDescript uses music information retrieval technique to recognize features of a sound sample file.

Class Methods

.new

Creating a new SampleDescript instance. In most of case you don't need to care about other arguments besides filename.

Arguments:

filename

File name to analyse. It can also be a Buffer for live recording.

normtype

Type of normalization for SCMIR, 0 means not to normalize the data, 1 means to normalize all datas in between 0 and 1

start

Start time to analyze

dur

Duration to analyze

startThresh

Amplitude threshold to determine the starting point of each sections in the sample. The value will be multiplied by the peak amplitude.

endThresh

Amplitude threshold to determine the ending point of each sections in the sample. The value will be multiplied by the peak amplitude.

onsetThresh

Absolute amplitude threshold for onset detection.

groupingThresh

Temporal threshold in seconds to determine the distance of onsets to be considered as the same section.

filenameAsNote

Uses information from the end of file name if possible for anchored midi key note sending to sampler synthesizer. Informations can be note names like "C4" or MIDI key numbers like "60".

loadToBuffer

Load the sample file to a buffer while analysing.

server

Server to load the file.

action

Function to run when loading to buffer is finished.

.gui

Open a GUI window for SampleDescript. You can drag and drop a sound file onto the drop area to show the wavetable, and switch the buttons too show/hide various of parameters. Grid lines on the wavetable indecate the SCMIR frame hop.

The instance of the SamplerDescript generated with the GUI is stored in a global variable ~temp.

Instance Methods

For management:

.free

Free the instance and buffer.

.play

Play the sound sample for audition.

Arguments:

at

index of sections, nil for the whole file.

outbus

bus for playback.

server

server to load the file into server.

.loadToBuffer

Load sample file to Buffer.

Global information:

.filename

The file path and name of the instance loaded. If a Buffer is loaded, a tempbuffer.aiff file will be created in system temp folder.

.buffer

Buffer loaded the whole file.

.activeBuffer

An array of Buffers loaded with each sections of the sample.

.bufferServer

The server to load Buffer into.

.keynum

A MIDI key number for anchoring the original pitch of the sample.

.keynumFromFileName

nil if there is none.

.keynumFromPitchFound

Key number found from pitch detection, if no pitch is found, it will be replaced with frequency centorid mapped down by an octave.

.env

Returns:

An Envelope with the amplitude information of the whole file.

.sampleRate

.duration

.globalPeakTime

.globalPeakAmp

Local information of each active section

Local informations are descripted as an Array of numbers.

.activeEnv

Returns:

An Array of Envelops for each section detected.

.activeDuration

.startTime

Global time point of each section starts within the file.

.endTime

Global time point of each section ends within the file.

.peakTime

Global time point of each amplitude peak detected within the file.

.peakAmp

Peak amplitude of each section.

.attackDur

Conventional "attack time" for an envelope

.releaseDur

Conventional "release time" for an envelope

.temporalCentroid

Meaned each time frame weighted by amplitudes. Shorter value indicates percussive sounds. Longer value indicates sustained sounds.

Raw Data:

SampleDescript uses SCMIR to create analysis data. The default frame size for FFT and other analysis in SCMIR is 1024 samples. And default samplingrate of SCMIR is 44100Hz. Raw data methods contains analyzed datas by each frame.

.file

The instance of SCMIRAudioFile if needed.

.mirDataByFeatures

Data Array extracted from SCMIR grouped by features, the array of features will be:

[[RMS], [Pitch], [hasPitch], [centroid], [SensoryDissonance], [Specflatness]]

.frameTimes

Time point to the middle of each frame.

.rmsData

.pitchData

Pitch data is stored in this format of each frame:

[[Pitch, hasPitch], [Pitch, hasPitch], ......]

Pitch is defined by MIDI key number, it can be floating point numbers. hasPitch ranges from 0 to 1, 1 means a pitch is surely founded.

.centroidData

Spectral centroid is weighted mean of the frequencies by amplitude.

.activeCentroidData

Local centroid data of each section.

.activeDissonanceData

.activeSpecFlatness

Spectral flatness is an indicator of how flat of the spectrum to a frame. 0 means sinesoid wave, 1 means white noise. This indicates the degree of noiseness.

Examples