bool MF0UA::initialise(size_t channels, size_t stepSize, size_t blockSize) { if (channels < getMinChannelCount() || channels > getMaxChannelCount()) return false; // Real initialisation work goes here! m_stepSize = stepSize; m_blockSize = blockSize; // Initialize spectruminfo initializeSpectrumInfo(); // Memory allocation for window window = (double*) malloc(sizeof(double)*(spectruminfo.winsize)); // Creation of the Hanning window Hanning(window,spectruminfo.N); // Bands generation (Only when the algorithm is onset-based) if (algorithm==2) { generatebands(spectruminfo.first_band_freq, spectruminfo.samplerate/2, spectralbands, spectruminfo.freq_resolution); spectruminfo.numbands=spectralbands.size(); // Do not compute differences for the first frame resolutiondiff=(getPreferredBlockSize()/2)/getPreferredStepSize(); } // This is the first frame firstframe=true; n_time=0; return true; }
SpeechMusicSegmenter::OutputList SpeechMusicSegmenter::getOutputDescriptors() const { OutputList list; OutputDescriptor segmentation; segmentation.identifier = "segmentation"; segmentation.name = "Segmentation"; segmentation.description = "Segmentation"; segmentation.unit = "segment-type"; segmentation.hasFixedBinCount = true; segmentation.binCount = 1; segmentation.hasKnownExtents = true; segmentation.minValue = 0; segmentation.maxValue = 2; segmentation.isQuantized = true; segmentation.quantizeStep = 1; segmentation.sampleType = OutputDescriptor::VariableSampleRate; segmentation.sampleRate = m_inputSampleRate / getPreferredStepSize(); OutputDescriptor skewness; skewness.identifier = "skewness"; skewness.name = "Detection function"; skewness.description = "Detection function"; skewness.unit = "segment-type"; skewness.hasFixedBinCount = true; skewness.binCount = 1; skewness.hasKnownExtents = true; skewness.minValue = 0; skewness.maxValue = 2; skewness.isQuantized = true; skewness.quantizeStep = 1; skewness.sampleType = OutputDescriptor::VariableSampleRate; skewness.sampleRate = m_inputSampleRate / getPreferredStepSize(); list.push_back(segmentation); list.push_back(skewness); return list; }
TonalChangeDetect::OutputList TonalChangeDetect::getOutputDescriptors() const { OutputList list; OutputDescriptor hc; hc.identifier = "tcstransform"; hc.name = "Transform to 6D Tonal Content Space"; hc.unit = ""; hc.description = "Representation of content in a six-dimensional tonal space"; hc.hasFixedBinCount = true; hc.binCount = 6; hc.hasKnownExtents = true; hc.minValue = -1.0; hc.maxValue = 1.0; hc.isQuantized = false; hc.sampleType = OutputDescriptor::OneSamplePerStep; OutputDescriptor d; d.identifier = "tcfunction"; d.name = "Tonal Change Detection Function"; d.unit = ""; d.description = "Estimate of the likelihood of a tonal change occurring within each spectral frame"; d.minValue = 0; d.minValue = 2; d.hasFixedBinCount = true; d.binCount = 1; d.hasKnownExtents = false; d.isQuantized = false; d.sampleType = OutputDescriptor::VariableSampleRate; double dStepSecs = double(getPreferredStepSize()) / m_inputSampleRate; d.sampleRate = 1.0f / dStepSecs; OutputDescriptor changes; changes.identifier = "changepositions"; changes.name = "Tonal Change Positions"; changes.unit = ""; changes.description = "Estimated locations of tonal changes"; changes.hasFixedBinCount = true; changes.binCount = 0; changes.hasKnownExtents = false; changes.isQuantized = false; changes.sampleType = OutputDescriptor::VariableSampleRate; changes.sampleRate = 1.0 / dStepSecs; list.push_back(hc); list.push_back(d); list.push_back(changes); return list; }
void MF0UA::initializeSpectrumInfo() { spectruminfo.first_band_freq=kMINBANDFREQ; // Minimum frequency for band processing spectruminfo.samplerate= sr; spectruminfo.N=getPreferredBlockSize(); spectruminfo.res=kRES; // 4 by default, for zero padding spectruminfo.percentage=100-(getPreferredStepSize()/(float)(spectruminfo.N))*100; spectruminfo.freq_resolution=(double)(spectruminfo.samplerate)/((double)(spectruminfo.N)*spectruminfo.res); spectruminfo.winsize= spectruminfo.N*spectruminfo.res; spectruminfo.firstsample=(int)round(spectruminfo.W/spectruminfo.freq_resolution); // Convert bandwidth (Hz->Samples) if (spectruminfo.percentage!=0) spectruminfo.time_resolution= (1.0-((double)spectruminfo.percentage/100.0))* (spectruminfo.N) / spectruminfo.samplerate; else spectruminfo.time_resolution=(double)(spectruminfo.N)/(double)(spectruminfo.samplerate); spectruminfo.min_sample=(int)floor(spectruminfo.first_band_freq/spectruminfo.freq_resolution); }