Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. read buffer problem

read buffer problem

Scheduled Pinned Locked Moved C / C++ / MFC
data-structureshelptutorialquestionc++
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    meiyueh
    wrote on last edited by
    #1

    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

    B 1 Reply Last reply
    0
    • M meiyueh

      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

      B Offline
      B Offline
      billiam904
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups