Sound card is the cheapest A/D card. It has a A/D which can be used to acquire signal. It has a D/A which can be used to output a desired signal. For freshman, Sound card is the best one to learn PC based test and measurement. See "Sound Cards Work in Some Data-Acquisition Applications" by Brad Thompson. The control of sound card is complicate, it need some skills and knowledges. A DAQ dll of sound card is designed by me to overcome these problems. By help of it, you can record or play a signal from your program directly. The Sound DAQ is originally designed to help my students to design Sound Card based virtual instrument by VB. I wish it can also give you a help.
Sound DAQ is a freeware, you can use and distribute it freely. Press here to download. Sound DAQ package include four file: 1.sounddaq.h 2.sounddaq.lib 3.sounddaq.dll 5.sound_vb (VB Example program) 6.sound_vc (VC++ Example program) . Functions in Sound DAQ: 2. int recording(long
fs,long len,short *wave)
|
Example of VC++:
.
Below is main souce code of this program:
//====================================================
BOOL CSoundtestDlg::OnInitDialog()
{CDialog::OnInitDialog();
SetIcon(m_hIcon, TRUE);
SetIcon(m_hIcon, FALSE);
SetWindowPos(&wndTop,0,0,500,300,SWP_NOMOVE); // Set size of Dialog
return TRUE;
}void CSoundtestDlg::OnMenuitem32772() // Close
{CDialog::OnCancel();}void CSoundtestDlg::OnMenuitem32771() // OPEN a wave file
{CClientDC dc(this); // Get handle of dc
long rc,max=64534;
rc=openwav("example.wav",&chn,&fs,&len,max,wave[0],wave[1]); // Read WAV FILE
if (rc!=1) {outword(&dc,10,10,"Read file failed !"); return;}
draewave(&dc); // Show signal
}void CSoundtestDlg::OnMenuitem32773() // Save to a wav file
{savewav16("demo.wav",1,fs,len,wave[0],wave[1]);}void CSoundtestDlg::OnMenuitem32775() // Play from a wav file
{Playfile("1000.wav",2);}void CSoundtestDlg::OnMenuitem32776() // Stop play
{stopplay();}void CSoundtestDlg::OnMenuitem32779() // Recording
{CClientDC dc(this);
chn=1; fs=11025; len=4396;
recording(fs,len,wave[0]);
draewave(&dc);
}
Example of VB: Below is main souce code of this program:
Private Declare Function Playfile Lib "c:\temp\sounddaq.dll"
(ByVal name As String, ByVal w As Long) As Long
Private Declare Function Recordflie Lib "c:\temp\sounddaq.dll"
(ByVal name As String, ByVal fs As Long, ByVal length As Long) As Long
.
Private Sub play_Click()
Dim rc As Long
Dim name As String
name = Text1.Text
rc = Playfile(name, 1)
End Sub
.
Private Sub record_Click()
Dim rc As Long
Dim fs As Long
Dim length As Long
Dim name As String
fs = 11025
length = 110250
name = Text2.Text
rc = Recordflie(name, fs, length)
End Sub.
1999.12.20