Spectrum analyzer demo, the HZ is 0 ~ 1000, how to change this?
-
spectrum analyzer demo, the supported HZ is 0 ~ 1000
how to change this? fro example 0 ~20000HzI have change this in http://doc.qt.nokia.com/latest/demos-spectrum-app-spectrum-h.html but it will not work.
// Lower bound of first band in the spectrum
const qreal SpectrumLowFreq = 0.0; // Hz// Upper band of last band in the spectrum
const qreal SpectrumHighFreq = 1000.0; // Hz -
You don't know grep, do you?
@
Qt/qt-everywhere-commercial-src-4.7.1/demos/spectrum/app $ grep 1000 *
engine.cpp:const qint64 BufferDurationUs = 10 * 1000000;
engine.cpp:const int LevelWindowUs = 0.1 * 1000000;
spectrum.h:const qreal SpectrumHighFreq = 1000.0; // Hz
spectrum.h:const qint64 WaveformWindowDuration = 500 * 1000;
tonegeneratordialog.cpp:const int ToneGeneratorFreqMax = 1000;
utils.cpp: return (bytes * 1000000) /
utils.cpp: * microSeconds / 1000000;
@I leave it to your eyes to grab the right file.
And yes, I would call it probably a bug, that the constant of spectrum.h is not used.
-
dear my friends, I do not fully understand you.
I have already changed :
// Lower bound of first band in the spectrum
const qreal SpectrumLowFreq = 0.0; // Hz// Upper band of last band in the spectrum
const qreal SpectrumHighFreq = 1000.0; // Hzbut this will not work.
what should I change?
thanks
-
there are 3 mode for this demo:
- play the generated tone.
- recode the sound
- play the file
I changed the ToneGeneratorFreqMax = 1000 to 20000.
from the sound that I heard, the Frequency is changed.
But the spectrograph is not changed accordingly, which means the bars shown to the user do not work well. -
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 ...