当前位置: 技术问答>linux和unix
有分了--高分求救:Linux下如何将声卡输出的声音以波形显示出来?
来源: 互联网 发布时间:2016-03-11
本文导语: 我想作成一个类似于win下的播放器的波形条上下跳动的效果? 怎么来采集实时频率信号呀?原理是什么呀? 多谢了! | 这是我做这方面画波形的一段代码,仅供参考。 CDC * pDC = CDC::Fro...
我想作成一个类似于win下的播放器的波形条上下跳动的效果?
怎么来采集实时频率信号呀?原理是什么呀?
多谢了!
怎么来采集实时频率信号呀?原理是什么呀?
多谢了!
|
这是我做这方面画波形的一段代码,仅供参考。
CDC * pDC = CDC::FromHandle( lpDrawItemStruct -> hDC );
int erg = pDC->SelectClipRgn(&ShapeDCRegion);
CRect rect = lpDrawItemStruct -> rcItem;
UINT state = lpDrawItemStruct -> itemState;
UINT nStyle = GetStyle( );
int nSavedDC = pDC -> SaveDC( );
COLORREF backcolor = GetSysColor(COLOR_BTNFACE);
CBrush brush;
CMemDC *memDC = new CMemDC(pDC);
CFile myFileW;
CFile myFile;
RECT clipRect;
if(initalized == TRUE)
{
memDC->GetClipBox(&clipRect);
memDC->FillSolidRect(&clipRect,backcolor);
CFont *oldFont;
// int xp, yp, xx, yy;
int xp, yp;
orgBrushOrigin = memDC->GetBrushOrg();
oldFont = memDC->SelectObject(&smallFont);
double scale = (double)TGSize.cy / (double)MaxTrafficAmount;
yp = TrafficDrawRectangle.bottom;
xp = TrafficDrawRectangle.left;
// RECT fillrect;
CString tmp;
// Fill the background
back = memDC->GetBkColor();
brush.CreateSolidBrush(black);//back);
memDC->FillRect(&TrafficDrawRectangle, &brush);
// draw the grid
int xgridlines, ygridlines;
xgridlines = TGSize.cx / gridxresolution;
ygridlines = TGSize.cy / gridyresolution;
CPen* oldPen = memDC->SelectObject(&GridPen);
// Create the vertical lines
for (int x=0; xMoveTo(x*gridxresolution + gridxstartpos, 0 );
memDC->LineTo(x*gridxresolution + gridxstartpos, TGSize.cy );
}
// And the horizontal lines
for (int y=0; yMoveTo(0 , gridystartpos + TGSize.cy - y*gridyresolution - 2);
memDC->LineTo(TGSize.cx , gridystartpos + TGSize.cy - y*gridyresolution - 2);
}
gridxstartpos += gridscrollxspeed;//Grid Move speed
gridystartpos += gridscrollyspeed;
if(gridxstartpos gridxresolution ) gridxstartpos = 0;
if(gridystartpos gridyresolution ) gridystartpos = 0;
if (lpDrawItemStruct->CtlID == 1001)
{
CString str;
int temp=0;
if ((myFileW.Open("Rstd.txt",CFile::modeRead)))
{
// Create a loading archive.
myFileW.SeekToBegin();
CArchive arLoadW(&myFileW, CArchive::load);
CPen* oldPenW = memDC->SelectObject(&StadPen );
for (int iw=0; iwMoveTo(iw, 15-temp);
}
arLoadW.ReadString( str );
temp = atoi(str);
memDC->LineTo(iw, 15-temp);
}
arLoadW.Close();
myFileW.Close();
}
if ((myFile.Open("dbOutRight.txt",CFile::modeRead)))
{
// Create a loading archive.
myFile.SeekToBegin();
CArchive arLoad(&myFile, CArchive::load);
CPen* oldPen1 = memDC->SelectObject(&WavePen);
for (int i=0; iMoveTo(i, 15-temp);
}
arLoad.ReadString( str );
temp = atoi(str);
memDC->LineTo(i, 15-temp);
}
arLoad.Close();
myFile.Close();
}
}
else
{
CString str;
int temp=0;
if ((myFileW.Open("Lstd.txt",CFile::modeRead)))
{
// Create a loading archive.
myFileW.SeekToBegin();
CArchive arLoadW(&myFileW, CArchive::load);
CPen* oldPenW = memDC->SelectObject(&StadPen );
for (int iw=0; iwMoveTo(iw, 15-temp);
}
arLoadW.ReadString( str );
temp = atoi(str);
memDC->LineTo(iw, 15-temp);
}
arLoadW.Close();
myFileW.Close();
}
if ((myFile.Open("dbOutLeft.txt",CFile::modeRead)))
{
// Create a loading archive.
myFile.SeekToBegin();
CArchive arLoad(&myFile, CArchive::load);
CPen* oldPen1 = memDC->SelectObject(&WavePen);
for (int i=0; iMoveTo(i, 15-temp);
}
arLoad.ReadString( str );
temp = atoi(str);
memDC->LineTo(i, 15-temp);
}
arLoad.Close();
myFile.Close();
}
}
}
delete memDC;
pDC -> RestoreDC( nSavedDC );
CDC * pDC = CDC::FromHandle( lpDrawItemStruct -> hDC );
int erg = pDC->SelectClipRgn(&ShapeDCRegion);
CRect rect = lpDrawItemStruct -> rcItem;
UINT state = lpDrawItemStruct -> itemState;
UINT nStyle = GetStyle( );
int nSavedDC = pDC -> SaveDC( );
COLORREF backcolor = GetSysColor(COLOR_BTNFACE);
CBrush brush;
CMemDC *memDC = new CMemDC(pDC);
CFile myFileW;
CFile myFile;
RECT clipRect;
if(initalized == TRUE)
{
memDC->GetClipBox(&clipRect);
memDC->FillSolidRect(&clipRect,backcolor);
CFont *oldFont;
// int xp, yp, xx, yy;
int xp, yp;
orgBrushOrigin = memDC->GetBrushOrg();
oldFont = memDC->SelectObject(&smallFont);
double scale = (double)TGSize.cy / (double)MaxTrafficAmount;
yp = TrafficDrawRectangle.bottom;
xp = TrafficDrawRectangle.left;
// RECT fillrect;
CString tmp;
// Fill the background
back = memDC->GetBkColor();
brush.CreateSolidBrush(black);//back);
memDC->FillRect(&TrafficDrawRectangle, &brush);
// draw the grid
int xgridlines, ygridlines;
xgridlines = TGSize.cx / gridxresolution;
ygridlines = TGSize.cy / gridyresolution;
CPen* oldPen = memDC->SelectObject(&GridPen);
// Create the vertical lines
for (int x=0; xMoveTo(x*gridxresolution + gridxstartpos, 0 );
memDC->LineTo(x*gridxresolution + gridxstartpos, TGSize.cy );
}
// And the horizontal lines
for (int y=0; yMoveTo(0 , gridystartpos + TGSize.cy - y*gridyresolution - 2);
memDC->LineTo(TGSize.cx , gridystartpos + TGSize.cy - y*gridyresolution - 2);
}
gridxstartpos += gridscrollxspeed;//Grid Move speed
gridystartpos += gridscrollyspeed;
if(gridxstartpos gridxresolution ) gridxstartpos = 0;
if(gridystartpos gridyresolution ) gridystartpos = 0;
if (lpDrawItemStruct->CtlID == 1001)
{
CString str;
int temp=0;
if ((myFileW.Open("Rstd.txt",CFile::modeRead)))
{
// Create a loading archive.
myFileW.SeekToBegin();
CArchive arLoadW(&myFileW, CArchive::load);
CPen* oldPenW = memDC->SelectObject(&StadPen );
for (int iw=0; iwMoveTo(iw, 15-temp);
}
arLoadW.ReadString( str );
temp = atoi(str);
memDC->LineTo(iw, 15-temp);
}
arLoadW.Close();
myFileW.Close();
}
if ((myFile.Open("dbOutRight.txt",CFile::modeRead)))
{
// Create a loading archive.
myFile.SeekToBegin();
CArchive arLoad(&myFile, CArchive::load);
CPen* oldPen1 = memDC->SelectObject(&WavePen);
for (int i=0; iMoveTo(i, 15-temp);
}
arLoad.ReadString( str );
temp = atoi(str);
memDC->LineTo(i, 15-temp);
}
arLoad.Close();
myFile.Close();
}
}
else
{
CString str;
int temp=0;
if ((myFileW.Open("Lstd.txt",CFile::modeRead)))
{
// Create a loading archive.
myFileW.SeekToBegin();
CArchive arLoadW(&myFileW, CArchive::load);
CPen* oldPenW = memDC->SelectObject(&StadPen );
for (int iw=0; iwMoveTo(iw, 15-temp);
}
arLoadW.ReadString( str );
temp = atoi(str);
memDC->LineTo(iw, 15-temp);
}
arLoadW.Close();
myFileW.Close();
}
if ((myFile.Open("dbOutLeft.txt",CFile::modeRead)))
{
// Create a loading archive.
myFile.SeekToBegin();
CArchive arLoad(&myFile, CArchive::load);
CPen* oldPen1 = memDC->SelectObject(&WavePen);
for (int i=0; iMoveTo(i, 15-temp);
}
arLoad.ReadString( str );
temp = atoi(str);
memDC->LineTo(i, 15-temp);
}
arLoad.Close();
myFile.Close();
}
}
}
delete memDC;
pDC -> RestoreDC( nSavedDC );
|
老渠,我来接分了