예제 #1
0
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;
}
예제 #2
0
bool
MyPlugin::initialise(size_t channels, size_t stepSize, size_t blockSize)
{
    if (channels < getMinChannelCount() ||
	channels > getMaxChannelCount()) return false;

    // Real initialisation work goes here!

    return true;
}
예제 #3
0
bool Rhythm::initialise(size_t channels, size_t stepSize, size_t blockSize) {
  if (channels < getMinChannelCount() || channels > getMaxChannelCount())
    return false;

  m_blockSize = blockSize;
  m_stepSize = stepSize;
  reset();

  return true;
}
bool
SpeechMusicSegmenter::initialise(size_t channels, size_t stepSize, size_t blockSize)
{
    if (channels < getMinChannelCount() ||
	channels > getMaxChannelCount()) return false;

    // Real initialisation work goes here!
    m_blockSize = blockSize;

    return true;
}
예제 #5
0
bool
SpectralCentroid::initialise(size_t channels, size_t stepSize, size_t blockSize)
{
    if (channels < getMinChannelCount() ||
    channels > getMaxChannelCount()) return false;

    // Real initialisation work goes here!
    m_blockSize = blockSize;
    m_stepSize = stepSize;

    return true;
}
예제 #6
0
bool
TemporalCentroid::initialise(size_t channels, size_t stepSize, size_t blockSize)
{
    if (channels < getMinChannelCount() ||
    channels > getMaxChannelCount()) return false;

    // Real initialisation work goes here!
    m_blockSize = blockSize;
    m_stepSize = stepSize;

    m_rms.clear();
    m_timestamps.clear();

    return true;
}
bool
MusicHackChord::initialise(size_t channels, size_t stepSize, size_t blockSize)
{
    if (channels < getMinChannelCount() ||
	channels > getMaxChannelCount()) return false;

    // Real initialisation work goes here!
	memset(xhs, 0, sizeof(xhs));
	m_counter=0;

	m_stepSize = stepSize;
	m_blockSize = blockSize;
	m_startPos = blockSize - stepSize;
	if(m_startPos < 0)
		m_startPos = 0;

    return true;
}
예제 #8
0
bool TonalChangeDetect::initialise(size_t channels, size_t stepSize, size_t blockSize)
{
    if (m_chromagram) {
        delete m_chromagram;
        m_chromagram = 0;
    }

    if (channels < getMinChannelCount() ||
            channels > getMaxChannelCount()) {
        std::cerr << "TonalChangeDetect::initialise: Given channel count " << channels << " outside acceptable range (" << getMinChannelCount() << " to " << getMaxChannelCount() << ")" << std::endl;
        return false;
    }

    m_chromagram = new Chromagram(m_config);
    m_step = m_chromagram->getHopSize();
    m_block = m_chromagram->getFrameSize();

    if (stepSize != m_step) {
        std::cerr << "TonalChangeDetect::initialise: Given step size " << stepSize << " differs from only acceptable value " << m_step << std::endl;
        delete m_chromagram;
        m_chromagram = 0;
        return false;
    }
    if (blockSize != m_block) {
        std::cerr << "TonalChangeDetect::initialise: Given step size " << stepSize << " differs from only acceptable value " << m_step << std::endl;
        delete m_chromagram;
        m_chromagram = 0;
        return false;
    }

    //    m_stepDelay = (blockSize - stepSize) / 2;
    //    m_stepDelay = m_stepDelay / stepSize;
    m_stepDelay = (blockSize - stepSize) / stepSize; //!!! why? seems about right to look at, but...

//    std::cerr << "TonalChangeDetect::initialise: step " << stepSize << ", block "
//              << blockSize << ", delay " << m_stepDelay << std::endl;

    m_vaCurrentVector.resize(12, 0.0);

    return true;

}
bool MzSpectrogramFFTW::initialise(size_t channels, size_t stepsize, 
      size_t blocksize) {

   if (channels < getMinChannelCount() || channels > getMaxChannelCount()) {
      return false;
   }

   // step size and block size should never be zero
   if (stepsize <= 0 || blocksize <= 0) {
      return false;
   }

   setChannelCount(channels);
   setBlockSize(blocksize);
   setStepSize(stepsize);

   mz_minbin = getParameterInt("minbin");
   mz_maxbin = getParameterInt("maxbin");

   if (mz_minbin >= getBlockSize()/2) { mz_minbin = getBlockSize()/2-1; }
   if (mz_maxbin >= getBlockSize()/2) { mz_maxbin = getBlockSize()/2-1; }
   if (mz_maxbin <  0)                { mz_maxbin = getBlockSize()/2-1; }
   if (mz_maxbin <  mz_minbin)        { std::swap(mz_minbin, mz_maxbin); }

   // The signal size/transform size are equivalent for this
   // plugin but the FFTW can handle any size transform.
   // If the size of the transform is a multiple of small
   // prime numbers the FFT will be used, otherwise it will
   // be slow (when block size=1021 for example).

   mz_transformer.setSize(getBlockSize());
   delete [] mz_wind_buff;
   mz_wind_buff = new double[getBlockSize()];
   makeHannWindow(mz_wind_buff, getBlockSize());

   return true;
}
예제 #10
0
bool
NNLSBase::initialise(size_t channels, size_t stepSize, size_t blockSize)
{	
    if (debug_on) {
        cerr << "--> initialise";
    }
	
	dictionaryMatrix(m_dict, m_s);
	
	// make things for tuning estimation
	for (int iBPS = 0; iBPS < nBPS; ++iBPS) {
        sinvalues.push_back(sin(2*M_PI*(iBPS*1.0/nBPS)));
        cosvalues.push_back(cos(2*M_PI*(iBPS*1.0/nBPS)));
    }
    
	
	// make hamming window of length 1/2 octave
	int hamwinlength = nBPS * 6 + 1;
    float hamwinsum = 0;
    for (int i = 0; i < hamwinlength; ++i) { 
        hw.push_back(0.54 - 0.46 * cos((2*M_PI*i)/(hamwinlength-1)));    
        hamwinsum += 0.54 - 0.46 * cos((2*M_PI*i)/(hamwinlength-1));
    }
    for (int i = 0; i < hamwinlength; ++i) hw[i] = hw[i] / hamwinsum;
    
    
    // initialise the tuning
    for (int iBPS = 0; iBPS < nBPS; ++iBPS) {
        m_meanTunings.push_back(0);
        m_localTunings.push_back(0);
    }
	
    if (channels < getMinChannelCount() ||
	channels > getMaxChannelCount()) return false;
    m_blockSize = blockSize;
    m_stepSize = stepSize;
    m_frameCount = 0;
    int tempn = nNote * m_blockSize/2;
    // cerr << "length of tempkernel : " <<  tempn << endl;
    float *tempkernel;

    tempkernel = new float[tempn];

    logFreqMatrix(m_inputSampleRate, m_blockSize, tempkernel);
    m_kernelValue.clear();
    m_kernelFftIndex.clear();
    m_kernelNoteIndex.clear();
    int countNonzero = 0;
    for (int iNote = 0; iNote < nNote; ++iNote) { // I don't know if this is wise: manually making a sparse matrix
        for (int iFFT = 0; iFFT < static_cast<int>(blockSize/2); ++iFFT) {
            if (tempkernel[iFFT + blockSize/2 * iNote] > 0) {
                m_kernelValue.push_back(tempkernel[iFFT + blockSize/2 * iNote]);
                if (tempkernel[iFFT + blockSize/2 * iNote] > 0) {
                    countNonzero++;
                }
                m_kernelFftIndex.push_back(iFFT);
                m_kernelNoteIndex.push_back(iNote);				
            }
        }
    }
    // cerr << "nonzero count : " << countNonzero << endl;
    delete [] tempkernel;
/*
    ofstream myfile;
    myfile.open ("matrix.txt");
    // myfile << "Writing this to a file.\n";	
    for (int i = 0; i < nNote * 84; ++i) {
        myfile << m_dict[i] << endl;		
    }
    myfile.close();
*/
    return true;
}