Initial
This commit is contained in:
54
mixer/MixerScope.cpp
Normal file
54
mixer/MixerScope.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
#include <mixer/MixerScope.hpp>
|
||||
#include <sample/puresmpl.hpp>
|
||||
#include <common/array.hpp>
|
||||
#include <common/purehdc.hpp>
|
||||
|
||||
MixerScope::MixerScope(GUIWindow &parentWnd,UINT controlID,UINT extraStyles,const Rect &initRect,const Font &bannerFont)
|
||||
: Graphic(parentWnd,"SCOPE",controlID,extraStyles,initRect,bannerFont)
|
||||
{
|
||||
}
|
||||
|
||||
MixerScope::~MixerScope()
|
||||
{
|
||||
}
|
||||
|
||||
bool MixerScope::setData(WaveForm &waveForm)
|
||||
{
|
||||
mWaveForm=waveForm;
|
||||
FormatChunk &formatChunk=mWaveForm.getFormatChunk();
|
||||
String strCaption=String("Ch:")+String().fromInt(formatChunk.channels())+String(" Bps:")+String().fromInt(formatChunk.bitsPerSample())+String(" Sps:")+String().fromInt(formatChunk.samplesPerSecond());
|
||||
setCaption(strCaption);
|
||||
invalidate(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
// **************************************************************************************************
|
||||
// virtuals
|
||||
|
||||
void MixerScope::postPaint(PureDevice &pureDevice)
|
||||
{
|
||||
int penWidth=2;
|
||||
PureSampleEx &pureSampleEx=mWaveForm.getPureSample();
|
||||
Pen pen(RGBColor(0,128,0));
|
||||
Pen outlinePen(RGBColor(255,255,255),Pen::PSolid,penWidth);
|
||||
int max=0;
|
||||
float factor;
|
||||
int x=0;
|
||||
|
||||
SampleData sample;
|
||||
for(int index=0;index<pureSampleEx.getNumSamples();index++)
|
||||
{
|
||||
pureSampleEx.getAt(index,sample);
|
||||
if(sample.b16>max)max=sample.b16;
|
||||
}
|
||||
factor=(float)height()/(float)max;
|
||||
for(index=0;index<pureSampleEx.getNumSamples();index++)
|
||||
{
|
||||
pureSampleEx.getAt(index,sample);
|
||||
Point p1(x,height());
|
||||
Point p2(x,height()-(sample.b16*factor));
|
||||
pureDevice.line(p1,p2,pen);
|
||||
x++;
|
||||
}
|
||||
pureDevice.outlineRect(Rect(0,0,width(),height()),outlinePen);
|
||||
}
|
||||
Reference in New Issue
Block a user