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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Log File..

Log File..

Scheduled Pinned Locked Moved C / C++ / MFC
databasegraphicsgame-devquestion
4 Posts 3 Posters 1 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
    mpallavi
    wrote on last edited by
    #1

    Hi.. I had posted this query few days back also.. i am still not able to get the solution.. I need to maintain a log file that should contain the entries for the time a playback started and the time it ended. I am playing the wave files using Directx's DirectSound.. A separate thread takes care of the playback.. Mr. cedric had told me to find out what the callback function does.. the SetCallback function gets the audio stream data.. Is it possible to record the start and end times of the playback??? I am giving the related code here... ================================================== void CPhoneDlg::OnPlay() { ...... CTime theTime=CTime::GetCurrentTime(); CString startTime=theTime.Format( "%H:%M:%S, %B %d, %Y" ); WriteLogFile(startTime); m_pMyDS->Play(); m_timerID = timeSetEvent(500, 100, TimerProc, (DWORD)this, TIME_PERIODIC | TIME_CALLBACK_FUNCTION); CTime getTime=CTime::GetCurrentTime(); CString endTime=getTime.Format( "%H:%M:%S, %B %d, %Y" ); WriteLogFile(endTime); ...... } void CPhoneDlg::WriteLogFile(const char* szString) { FILE* pFile = fopen("logFile.txt", "a"); fprintf(pFile, "%s\n",szString); fclose(pFile); } //Some methods in the MyDirSound Class void CALLBACK TimerProcess(UINT uTimerID, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2) { CMyDirSound *pDDS = (CMyDirSound *)dwUser; pDDS->TimerCallback(); } void CMyDirSound::SetCallback(LPGETAUDIOSAMPLES_PROGRESS Function_Callback, LPVOID lpData) { m_lpGETAUDIOSAMPLES = Function_Callback; m_lpData = lpData; } void CMyDirSound::Play() { //Check if the DirectSound was created successfully .......................... //Check if the callback function is valid .......................... //Check if SetFormat successfully .......................... if (0 == m_dwCircles1) { //Get audio data by callback function DWORD dwRetSamples = 0, dwRetBytes = 0; m_lpGETAUDIOSAMPLES(m_lpAudioBuf, m_WFE.nSamplesPerSec, dwRetSamples, m_lpData); dwRetBytes = dwRetSamples*m_WFE.nBlockAlign; //Write the audio data to DirectSoundBuffer ..... //Lock DirectSoundBuffer ..... //Copy Audio Buffer to DirectSoundBuffer ..... //Unlock DirectSoundBuffer .... } //Beging Play m_lpDSB->Play(0, 0, DSBPLAY_LOOPING); //timeSetEvent m_timerID = timeSetEvent(300, 100, TimerProcess, (DWORD)this, TIME_PERIODIC | TIME_CALLBACK_FUNCTION); } ============================================================== The waveforms which i play are

    C 1 Reply Last reply
    0
    • M mpallavi

      Hi.. I had posted this query few days back also.. i am still not able to get the solution.. I need to maintain a log file that should contain the entries for the time a playback started and the time it ended. I am playing the wave files using Directx's DirectSound.. A separate thread takes care of the playback.. Mr. cedric had told me to find out what the callback function does.. the SetCallback function gets the audio stream data.. Is it possible to record the start and end times of the playback??? I am giving the related code here... ================================================== void CPhoneDlg::OnPlay() { ...... CTime theTime=CTime::GetCurrentTime(); CString startTime=theTime.Format( "%H:%M:%S, %B %d, %Y" ); WriteLogFile(startTime); m_pMyDS->Play(); m_timerID = timeSetEvent(500, 100, TimerProc, (DWORD)this, TIME_PERIODIC | TIME_CALLBACK_FUNCTION); CTime getTime=CTime::GetCurrentTime(); CString endTime=getTime.Format( "%H:%M:%S, %B %d, %Y" ); WriteLogFile(endTime); ...... } void CPhoneDlg::WriteLogFile(const char* szString) { FILE* pFile = fopen("logFile.txt", "a"); fprintf(pFile, "%s\n",szString); fclose(pFile); } //Some methods in the MyDirSound Class void CALLBACK TimerProcess(UINT uTimerID, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2) { CMyDirSound *pDDS = (CMyDirSound *)dwUser; pDDS->TimerCallback(); } void CMyDirSound::SetCallback(LPGETAUDIOSAMPLES_PROGRESS Function_Callback, LPVOID lpData) { m_lpGETAUDIOSAMPLES = Function_Callback; m_lpData = lpData; } void CMyDirSound::Play() { //Check if the DirectSound was created successfully .......................... //Check if the callback function is valid .......................... //Check if SetFormat successfully .......................... if (0 == m_dwCircles1) { //Get audio data by callback function DWORD dwRetSamples = 0, dwRetBytes = 0; m_lpGETAUDIOSAMPLES(m_lpAudioBuf, m_WFE.nSamplesPerSec, dwRetSamples, m_lpData); dwRetBytes = dwRetSamples*m_WFE.nBlockAlign; //Write the audio data to DirectSoundBuffer ..... //Lock DirectSoundBuffer ..... //Copy Audio Buffer to DirectSoundBuffer ..... //Unlock DirectSoundBuffer .... } //Beging Play m_lpDSB->Play(0, 0, DSBPLAY_LOOPING); //timeSetEvent m_timerID = timeSetEvent(300, 100, TimerProcess, (DWORD)this, TIME_PERIODIC | TIME_CALLBACK_FUNCTION); } ============================================================== The waveforms which i play are

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      I presume there's a callback you can register for that will notify you when the file stops playing. Christian Graus - Microsoft MVP - C++

      M 1 Reply Last reply
      0
      • C Christian Graus

        I presume there's a callback you can register for that will notify you when the file stops playing. Christian Graus - Microsoft MVP - C++

        M Offline
        M Offline
        mpallavi
        wrote on last edited by
        #3

        Hi.. thank you.. Can you explain it in a bit detail.. I am new to DirectSound and programming multimedia applications.. What i should do exactly? regards pallavi

        PJ ArendsP 1 Reply Last reply
        0
        • M mpallavi

          Hi.. thank you.. Can you explain it in a bit detail.. I am new to DirectSound and programming multimedia applications.. What i should do exactly? regards pallavi

          PJ ArendsP Offline
          PJ ArendsP Offline
          PJ Arends
          wrote on last edited by
          #4

          Have a look at the IDirectSoundNotify interface.


          "You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ???  You're definitely a superstar!!!" mYkel - 21 Jun '04 Within you lies the power for good - Use it!


          Honoured as one of The Most Helpful Members of 2004

          Within you lies the power for good; Use it!

          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