Beispiel #1
0
 Spectrogram::Spectrogram(FramesCollection& frames):
     m_frameCount(frames.count()),
     m_spectrumSize(frames.getSamplesPerFrame()),
     m_fft(FftFactory::getFft(m_spectrumSize)),
     m_data(new SpectrogramDataType(m_frameCount))
 {
     std::size_t i = 0;
     for (auto it = frames.begin(); it != frames.end(); ++it, ++i)
     {
         (*m_data)[i] = m_fft->fft(it->toArray());
     }
 }
Beispiel #2
0
    Spectrogram::Spectrogram(FramesCollection& frames):
        m_frameCount(frames.count()),
        m_spectrumSize(frames.getSamplesPerFrame()),
        // the following line converts an auto_ptr<Fft> returned by getFft
        // to a shared_ptr<Fft> stored in m_fft class member
        m_fft(FftFactory::getFft(m_spectrumSize).release()),
        m_data(new SpectrogramDataType(m_frameCount))
    {
        std::size_t i = 0;

        ComplexType* spectrumArray = new ComplexType[m_spectrumSize];
        for (FramesCollection::iterator iFrame = frames.begin(); iFrame != frames.end(); ++iFrame, ++i)
        {
            // a reference to ease typing
            SpectrumType& frameSpectrum = (*m_data)[i];
            std::memset(spectrumArray, 0, m_spectrumSize * sizeof(ComplexType));
            m_fft->fft(iFrame->toArray(), spectrumArray);
            frameSpectrum.assign(spectrumArray, spectrumArray + m_spectrumSize);
        }

        delete [] spectrumArray;
    }