 |
|
 |
http://www.codeproject.com/KB/audio-video/PeakMeterCS.aspx[^]
Enjoy!
1. I will develop myself to the maximum of my potential in all ways
2. I will look for the good in all people and make them feel worthwhile.
3. If I have nothing good to say about a person, I will say nothing.
4. I will always be as enthusiastic about the success of others as I am about my own.
5. I will always remain loyal to God, my country, family and my friends - Chuck Norris
Ernest Laurentin
|
|
|
|
 |
|
 |
Please can you release a VB.NEt version of this article ? Thanks
|
|
|
|
 |
|
 |
I will consider creating a C# version when I have some time. Hopefully, that will work for you as well.
God bless,
Ernest Laurentin
|
|
|
|
 |
|
 |
This looks good to me. I was wondering if you have a C# version of this peakmeter? Thank you for sharing your code and knowledge.
Kamran
|
|
|
|
 |
|
 |
Great idea. It should be much simpler. Sorry for late reply.
God bless,
Ernest Laurentin
|
|
|
|
 |
|
 |
Thanks for a great article. For anyone wanting a vertical falloff effect try adding the following lines above (// Move to Next Vertical band):
// Draw vertical falloff effect
if (m_bShowFalloff)
{
CPen pen;
pen.CreatePen(PS_SOLID, 1, DarkenColor(m_clrBackground, FALL_INCREASEBY));
CPen* pOldPen = (CPen*) pDC->SelectObject(& pen );
int nMaxWidth = size.cx*nHorzBands;
POINT points[2] = { 0 };
points[0].y = rcPrev.TopLeft().y + yDecal;
points[0].x = rcPrev.TopLeft().x + m_MeterData.at(nVert).nFalloff*nMaxWidth/m_nMaxValue;
points[1].y = rcPrev.BottomRight().y - yDecal;
points[1].x = points[0].x;
pDC->Polyline( points, 2);
pDC->SelectObject( pOldPen );
}
|
|
|
|
 |
|
 |
I'm working on an audio application with 22 channel strips..
So I need to load a seperate meter for each channel...
But it won't let me go past 16 meters..
Any more than 16 and the rest stick at 100% and I can't update the other meters..
for(int i=1; i<22; i++){
m_PeakMeter[i].SetMeterBands(1, 23);
m_PeakMeter[i].Start(1000/25); // 25 fps - puts delay in ms
m_PeakMeter[i].ShowGrid(1);
}
I have No clue where to find the problem on this one..
I'll try to compile a stand alone and see if I can do more than 16 there..
Any help would be great
|
|
|
|
 |
|
 |
I've just noticed that the poblem is in the timers
If I exclude the line
m_PeakMeter[i].Start(1000/25); // 25 fps - puts delay in ms
All of the meters show up and stay maxed "no animation", But I can update them...
So My real problem is... I can only get 16 PeakMeter timers to work at a time..
Any way to solve this problem?
|
|
|
|
 |
|
 |
You do not need to call 'Start' multiple times. Just call 'SetData' to set the value of the bands.
|
|
|
|
 |
|
 |
The control doesn't have such limitation.
You should call 'SetMeterBands' outside of the loop.
|
|
|
|
 |
|
 |
I Don]'t quite get what ya mean...
I'm trying to get 22 "individual" meters to work from 22 static text objects.. not 1
CPeakMeterCtrl m_PeakMeter[22]; //an array of meters
for(int i=1; i<23; i++){
m_PeakMeter[i].SetMeterBands(1, 1); //create all of the single meters
}
how would I make 1 timer work them all?
The channel strips in my program require that I run 22 "seperate" single meters
A small slice of code would be great
Sry.. Still a bit of a novice P Thanks for your help..
|
|
|
|
 |
|
 |
I resulted in using a single timer to update all of the meters
CPeakMeterCtrl m_PeakMeter[22]; //an array of meters
for(int i=1; i<23; i++){
m_PeakMeter[i].SetMeterBands(1, 1); //create all of the single meters
}
//Start timer for meters
SetTimer(1,25,NULL);
void CMyApp::OnTimer(UINT nIDEvent)
{
//update all the meters
for(int i=2; i<23; i++){
m_PeakMeter[i].DoTimerProcessing(NULL);
}
}
I had to change virtual void DoTimerProcessing(UINT uID); to a public function for access...
But all seems to be working perfectly..
|
|
|
|
 |
|
 |
Hi
I have included PeakMeter control into my dialog, and been able to get it to display different levels - all working OK.
What I actually would like to do is link it to the input level of my microphone, so I can use it to set the level before I start recording - can this be done, if so, how?
I hope you can help
Mike
|
|
|
|
 |
|
 |
Did you want the control to link automatically to the input level of your microphone?
(if yes, then this is not directly supported and I have no plan to release such funtionality )
How to use wave devices is a bit out of scope of this article but let me try really quick.
You can implement such feature by opening the microphone device (see waveInOpen(), waveInStop(), etc). I think you could get some free code here from code project. Then, you will need to use some algorithm to find the RMS of the signal and display it in the control. You can use FFT if you want to show the RMS for different frequencies. Check here: http://www.codeproject.com/cpp/howtofft.asp[^]
Hope that was useful...good luck!
|
|
|
|
 |
|
 |
Thanks for this - sorry for a delay in getting back - been away from the PC for a few days!
I will have a stab at doing this, although it does sound a bit complex. I have managed to get a 'sort of' meter working, by opening the recording of a was file, and each time a buffer is loaded from the mic, taking an average of the bytes read, and displaying that. It works, but somewhere, I am not clearing a buffer, and eventually the program runs out of buffer, and the meter stops. That was the state of play on wednesday when I last looked at the proble, so hopefully I can get a go at this later this week.
Thanks for your advice!
Mike
|
|
|
|
 |
|
 |
You should take a look at portaudio. I've used it in a couple of projects, and it makes working with audio a breeze...
http://www.portaudio.com
|
|
|
|
 |
|
 |
Please check your file or guide me
|
|
|
|
 |
|
 |
DSP is include in zipfile!
ÿFor the bread of God is he who comes down from heaven and gives life to the world. - John 6:33
|
|
|
|
 |
|
 |
Last Update, June 16,2002. Seems to have a problem with the link, try it here:
http://www.luigibianchi.com/owl.htm
One good thing about getting older, you don't lose the ages you've been!
|
|
|
|
 |
|
 |
To answer your question, you need to know Digital Signal Processing (DSP) fundamentals, and Fast Fourier Transform (FFT) in particular. You need to convert peaks values into amplitude values of frequencies in Hz.
Salute to Math and complex numbers.
http://www.fullspectrum.com/deeth/programming/fft.html
This website provides a dll that performs such processing for you.
http://www.relisoft.com/freeware/freq.html
This website explains FFT and frequency analysis and provides C source.
|
|
|
|
 |
|
 |
Hi,
I thought that the idea behind showing fall-off lines,
was that they should linger a bit longer, not fall with
the same speed as the bar.
Regards,
Lars Wilhelmsen.
--
Lars Wilhelmsen
Software Engineer
Teleplan AS
Norway
|
|
|
|
 |
|
 |
You are right. But a closer look to the source code, you will notice that
the demo uses a contant timer (500ms) and the values shown are random.
See: CPeakMeterDlg::OnTimer()
Thanks for comments
Ernest
|
|
|
|
 |