read buffer problem
-
my project is get the signal from pc mic to pc. below is one of the Cwavein class. i wan to read buffer to display graph and do signal processing. could anyone help me how to read the buffer? and i wan use 2dpushgraph that is in code project to display my graph. the statement is m_pushgraph.push(a,b),a is the magnitude in the buffer. b is how many line i wan display. could anyone tell me what magnitude should i put, how can i knw the magnitude(shw me example of programming), and should i put all the magnitude or jst push one magnitude and use looping for it and buffer will automatically get the data one by one in the array.thx for ur help. // WaveIn.cpp: implementation of the CWaveIn class. // ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "xxx.h" #include "WaveIn.h" #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW #endif ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// IMPLEMENT_DYNCREATE(CWaveIn, CWinThread) CWaveIn::CWaveIn(int iHertz) { memset(&m_WaveFormatEx,0x00,sizeof(m_WaveFormatEx)); // set the memory content to all zeros // configure the audio input record format m_WaveFormatEx.wFormatTag = WAVE_FORMAT_PCM; // Pulse Code Modulation m_WaveFormatEx.nChannels = 1; // mono m_WaveFormatEx.wBitsPerSample = 16; // 16-bit/sample m_WaveFormatEx.cbSize = 0; m_WaveFormatEx.nSamplesPerSec = iHertz; // sampling freq = 44.1kHz m_WaveFormatEx.nAvgBytesPerSec = m_WaveFormatEx.nSamplesPerSec*(m_WaveFormatEx.wBitsPerSample/8); m_WaveFormatEx.nBlockAlign = (m_WaveFormatEx.wBitsPerSample/8)*m_WaveFormatEx.nChannels; // initialize indicators m_bAudioIn = FALSE; m_bRecording = FALSE; // initialize pointers to NULL m_ptrWaveOut = NULL; m_ptrWaveFile = NULL; } CWaveIn::~CWaveIn() { } BOOL CWaveIn::InitInstance() { // TODO: perform any per-thread initializetion here return TRUE; } int CWaveIn::ExitInstance() { // TODO: perform any per-thread cleanup here return CWinThread::ExitInstance(); } //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// BEGIN_MESSAGE_MAP(CWaveIn, CWinThread) //{{AFX_MSG_MAP(CWaveIn) // NOTE - the ClassWizard will add and remove mapping macros here. //}}AFX_MSG_MAP ON_THREAD_MESSAGE(WM_WAVEI
-
my project is get the signal from pc mic to pc. below is one of the Cwavein class. i wan to read buffer to display graph and do signal processing. could anyone help me how to read the buffer? and i wan use 2dpushgraph that is in code project to display my graph. the statement is m_pushgraph.push(a,b),a is the magnitude in the buffer. b is how many line i wan display. could anyone tell me what magnitude should i put, how can i knw the magnitude(shw me example of programming), and should i put all the magnitude or jst push one magnitude and use looping for it and buffer will automatically get the data one by one in the array.thx for ur help. // WaveIn.cpp: implementation of the CWaveIn class. // ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "xxx.h" #include "WaveIn.h" #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW #endif ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// IMPLEMENT_DYNCREATE(CWaveIn, CWinThread) CWaveIn::CWaveIn(int iHertz) { memset(&m_WaveFormatEx,0x00,sizeof(m_WaveFormatEx)); // set the memory content to all zeros // configure the audio input record format m_WaveFormatEx.wFormatTag = WAVE_FORMAT_PCM; // Pulse Code Modulation m_WaveFormatEx.nChannels = 1; // mono m_WaveFormatEx.wBitsPerSample = 16; // 16-bit/sample m_WaveFormatEx.cbSize = 0; m_WaveFormatEx.nSamplesPerSec = iHertz; // sampling freq = 44.1kHz m_WaveFormatEx.nAvgBytesPerSec = m_WaveFormatEx.nSamplesPerSec*(m_WaveFormatEx.wBitsPerSample/8); m_WaveFormatEx.nBlockAlign = (m_WaveFormatEx.wBitsPerSample/8)*m_WaveFormatEx.nChannels; // initialize indicators m_bAudioIn = FALSE; m_bRecording = FALSE; // initialize pointers to NULL m_ptrWaveOut = NULL; m_ptrWaveFile = NULL; } CWaveIn::~CWaveIn() { } BOOL CWaveIn::InitInstance() { // TODO: perform any per-thread initializetion here return TRUE; } int CWaveIn::ExitInstance() { // TODO: perform any per-thread cleanup here return CWinThread::ExitInstance(); } //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// BEGIN_MESSAGE_MAP(CWaveIn, CWinThread) //{{AFX_MSG_MAP(CWaveIn) // NOTE - the ClassWizard will add and remove mapping macros here. //}}AFX_MSG_MAP ON_THREAD_MESSAGE(WM_WAVEI
There is an article in the audio section on building and dusplaying "peak files". A peak file is the bit representation of your waveform. The same code shows to display it. Bill Dennis Orlando, FL