用vc编写一个程序只存储左声道或是右声道的波形数据,大神们给点想法吧...
发布网友
发布时间:2024-08-07 00:55
我来回答
共1个回答
热心网友
时间:2024-08-10 13:01
1、于“stdafx.h”文件内添加包含语句
// stdafx.h : include file for standard system include files,
...
#endif // _AFX_NO_AFXCMN_SUPPORT
#include<mmsystem.h>
#pragma comment(lib,"winmm.lib")
//{{AFX_INSERT_LOCATION}}
#endif
2、添加初始化代码
BOOL CSoundDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
m_left.SetRange(0,200);
m_right.SetRange(0,200);
return TRUE; // return TRUE unless you set the focus to a control
}
3、为函数添加代码
void CSoundDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: Add your message handler code here and/or call default
DWORD pos;
int scrollpos;
if(pScrollBar->m_hWnd==m_left.m_hWnd) //移动左声道控件
{
scrollpos=m_left.GetPos();
::waveOutGetVolume(0,&pos); //获得当前信息
pos=pos&0x0000ffff|(scrollpos<<8);
::waveOutSetVolume(0,pos); //设置声音信息
}
if(pScrollBar->m_hWnd==m_right.m_hWnd) //移动右声道控件
{
scrollpos=m_right.GetPos();
::waveOutGetVolume(0,&pos); //修改音量
pos=pos&0xffff0000|(scrollpos<<24);
::waveOutSetVolume(0,pos);
}
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}