Spectrum analyzer demo, the HZ is 0 ~ 1000, how to change this?
-
I have the following :
Where exactly in spectrumanalyser demo is a code for getting the RAW PCM data from .wav file? and how to use this demo's functions to get it.
i'm working on sound processing system and i'm new with qt.
I would be grateful if someone could paste small example how to do get pcm data ;)
thanks for your reply ;)
-
thanks,
Ok, so I want to open the .wav file, get audio (PCM) data, and do some signal processing using external library (for example mel-cepstrum coefficients analysis)
so i open the wav file using:
@showFileDialog(){
}@
this function calls m_engine->loadFile(fileNames.front()); function
In next step i would like to create the buffer/vector for audio data and write this data to it and then analyse them. I don't know how to create this buffer and get the pcm data.
i look for adequate functions and find this:
@if (m_file) {
m_file->seek(0);
m_bufferPosition = 0;
m_dataLength = 0;
if (isPCMS16LE(m_file->fileFormat())) {
result = initialize();
}if(m_spectrumAnalyser.isReady()) {
m_spectrumBuffer = QByteArray::fromRawData(m_buffer.constData() + position m_bufferPosition, m_spectrumBufferLength);
m_spectrumPosition = position;
m_spectrumAnalyser.calculate(m_spectrumBuffer, m_format);
}@
so i see that i have to get some kind of m_buffer and m_format from .wav file and i don't see the proper way to do it. It would be great if someone could paste some simple code with solution to open .wav file, creating the buffer, getting the necessary parameters from this file (for example number of samples, m_format?), writting pcm data to the buffer, and how to read this data. In MATLAB there is wavread function for reading this kind of data.
thanks for your reply ;) -
Thank you shoyeb ;)
ok, I created the pushbutton and and i want to calculate the spectrum of 30000 us with step of 10000 us. how can i set up this values for my use?
I connected my slot to this button and this work properly spectrum. How to enable that the spectrum is calculated only if the position of calculating is less than the signal? - my program is still crushing after a few click ;(
@my function{
if (isPCMS16LE(m_file->fileFormat())) {
result = initialize();
}
if (m_file) {
m_file->seek(0);
m_bufferPosition = 0;
m_dataLength = 0;
}//bufor itd if(m_spectrumAnalyser.isReady()) { m_spectrumBuffer = QByteArray::fromRawData(m_buffer.constData() + classify_position - m_bufferPosition, m_spectrumBufferLength); m_spectrumPosition = classify_position + 10000;// step of windowing m_spectrumAnalyser.calculate(m_spectrumBuffer, m_format);
}
}@ how to initialize m_spectrumBufferLength and position to the values i mentioned?
and where/how i can add spectrumanalyser functions to calculate the spectrum only if the position is less than duration of signal?please help me
-
in engine.cpp file on top there are two constants..
@const qint64 BufferDurationUs = 1 * 1000000;
const int NotifyIntervalMs = 10;@where first value is amount of data to be processed in microseconds and second one is to set the notify interval, watever value u set in notify interval after that duration only ur data processing is done...
m_spectrumBufferLength is fixed and its value is initialized in utils.h or utils.h u dat can check ...